SlideShare une entreprise Scribd logo
1  sur  56
JavaScript 101 –
Creating your first JavaScript in
Microsoft Dynamics CRM 2011
Will Slade
Senior CRM Consultant
linkedin.com/in/WillSlade
Objective
 Review basic steps for
creating your first JavaScript
 Change how JavaScript is
perceived in the user
community
 Show how non-developers
can use basic JavaScript in
Microsoft Dynamics CRM
Agenda
1. What is JavaScript (aka: form scripting)?
2. Examples of JavaScript
3. The Basic Elements of JavaScript
4. JavaScript on Classic Forms in Microsoft Dynamics CRM 2011
What is JavaScript?
What is JavaScript?
 It is code
 Made for web browsers
 Alters the content that is displayed
JavaScript
aka: Jscript
aka: Form Scripting
In some documentation, there
is reference to “Form Scripting”
and “Jscript”,…
Are these the same thing as
JavaScript?
JavaScript and Form Scripting
Form Scripting - Jscript - JavaScript
Microsoft refers to using JavaScript in CRM as Form Scripting. For the purposes of this presentation,
scripting will simply be referred to as JavaScript. Here are some other helpful definitions:
JavaScript from Wikipedia:
JavaScript (JS) is an interpreted computer programming language. It was originally implemented as part of web
browsers so that client-side scripts could interact with the user, control the browser, communicate asynchronously,
and alter the document content that was displayed. More recently, however, it has become common in server-side
programming, game development and the creation of desktop applications.
jQuery from Wikipedia
jQuery is a multi-browser JavaScript library designed to simplify the client-side scripting of JavaScript and HTML.
Jscript vs. JavaScript from Wikipedia
…..” A lot of people think that JScript and JavaScript are different but similar languages. That's not the case. They
are just different names for the same language, and the reason the names are different was to get around
trademark issues”,….
JavaScript as a “Web Resource” in Microsoft CRM
JavaScript in Microsoft Dynamics CRM 2011
 Microsoft Dynamics CRM is
a browser based application
 Basically a bunch of webpages
 JavaScript is included in a
CRM webpage as a ‘Web
Resource’ Types of Web
Resources
When does a JavaScript do its thing?
When does JavaScript do its thing?
 OnLoad
 When the page opens
 OnChange
 When a field value changes on a form
 OnSave
 When a record is saved
Why use JavaScript?
(here are some quick examples)
Basic examples of how JavaScript can be used
 Change the color of a label on a field based on the value
 Hide fields based on another value on the form
 Display a map to a contact form that shows the contact address
Writing Code Sounds Intimidating
Maybe not so intimidating after all,…
 Before we show actual
code, keep in mind that it
might not be that
intimidating
 JavaScript is code but if
you break it down into its
basic elements, it is often
easier to understand
JavaScript Code Elements
JavaScript code sample
function alertVIP()
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
This JavaScript
changes the label
color to red for
the field ‘VIP’
Note: This is JavaScript for CRM 2011 which is different than CRM version 4.0. Some examples provided may not be supported in future versions
JavaScript code elements
function alertVIP()
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
function name
JavaScript code elements
function alertVIP()
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
Beginning bracket
Ending bracket
JavaScript code elements
function alertVIP()
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
Semicolon
that ends a
line
JavaScript code elements
function alertVIP()
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
Exact field name in CRM
JavaScript code elements
function alertVIP()
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
CRM code and method for getting the field HTML
Copy this exactly how it is here including parentheses and quotes
JavaScript code is case-sensitive
JavaScript code elements
function alertVIP()
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
Replacement HTML code for this field’s label
#ff000 is the color red
JavaScript code elements
function alertVIP()
{
document.getElementById("new_vip_c").innerHTML = "<b>VIP</b>";
}
… and this is a different example that
makes the field label Bold
Adding Logic
JavaScript code sample – adding logic
function alertVIP()
{
var VIP = Xrm.Page.getAttribute("new_vip").getValue();
if(VIP == true)
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
else
{
document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>";
}
}
JavaScript code elements
function alertVIP()
{
var VIP = Xrm.Page.getAttribute("new_vip").getValue();
if(VIP == true)
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
else
{
document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>";
}
}
var = Variable
JavaScript code elements
function alertVIP()
{
var VIP = Xrm.Page.getAttribute("new_vip").getValue();
if(VIP == true)
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
else
{
document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>";
}
}
VIP is the unique name for this variable
that is used in this code
JavaScript code elements
function alertVIP()
{
var VIP = Xrm.Page.getAttribute("new_vip").getValue();
if(VIP == true)
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
else
{
document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>";
}
}
Field name in CRM
JavaScript code elements
function alertVIP()
{
var VIP = Xrm.Page.getAttribute("new_vip").getValue();
if(VIP == true)
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
else
{
document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>";
}
}
Method for getting the field value
JavaScript code elements
function alertVIP()
{
var VIP = Xrm.Page.getAttribute("new_vip").getValue();
if(VIP == true)
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
else
{
document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>";
}
}
Entire Logic statement
JavaScript code elements
function alertVIP()
{
var VIP = Xrm.Page.getAttribute("new_vip").getValue();
if(VIP == true)
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
else
{
document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>";
}
}
If asks the question:
If the value for VIP equals (==) true
note: the field “new_vip” is a bit value
JavaScript code elements
function alertVIP()
{
var VIP = Xrm.Page.getAttribute("new_vip").getValue();
if(VIP == true)
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
else
{
document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>";
}
}
If true then do this part of the code which
turns the label red
JavaScript code elements
function alertVIP()
{
var VIP = Xrm.Page.getAttribute("new_vip").getValue();
if(VIP == true)
{
document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>";
}
else
{
document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>";
}
}
If NOT true then do this part of the code which
turns the label black
Examples of frequently used code
(the Microsoft CRM parts)
Frequently used Microsoft CRM parts of the code
 Hide a Field: Xrm.Page.getControl("name").setVisible(false);
 Get a Value: Xrm.Page.getAttribute("name").getValue();
 Set a Value: Xrm.Page.getAttribute("name").setValue(“Information");
 Set as Read-Only: Xrm.Page.ui.controls.get("accountnumber").setDisabled (true)
Online Guide from Microsoft
Quick Online Reference from Microsoft
 Direct Link: http://msdn.microsoft.com/en-us/library/jj602964#BKMK_AccessingAttributes
 Microsoft Developer Network: http://msdn.microsoft.com/library
Adding JavaScript to a Contact Form
Classic Form – not the Process Form in Microsoft Dynamics CRM 2011
Open the Contact Form
 Settings > Customization > Solutions > Your Custom Solution
 Components > Entities > Contact > Forms
Go to Form Properties1 then click Add2
1
2
Click New to add new Web Resource
Type = Script (Jscript) then click Text Editor
Paste your code into the Text Editor and Save
Add OnLoad
 Your new JavaScript has now
been added to the Form
Libraries list
 In Form Properties under
Event Handlers, click Add to
add a new OnLoad event for
the form
Enable Function
 Select your new JavaScript from
the Library dropdown
 Put in the function name to the
script. In our example, it was
alertVIP
 Make sure the Enabled
checkbox is checked for the
JavaScript to run when the page
loads
 Note: The field new_vip must
be on the form or the page will
show an error
OnLoad Added
 Our new OnLoad event
should now show in the
Event Handlers list
Add OnChange to VIP field
 On the Field Properties for
the VIP field, click on the
Event tab
Enable Function
 Adding an OnChange is very
similar to adding the OnLoad
 Save and now the JavaScript
will run every time you
change the field value for
VIP
Contact with OnLoad and OnChange JavaScript
Contact with OnLoad and OnChange JavaScript
Additional Examples
Calculating a Field
Adding an Image
Summary
 JavaScript is code added to a webpage to modify
the display
 JavaScript does not have to be that intimidating
 Each element of a JavaScript serves a purpose
and must be entered exactly - it is case-sensitive
 JavaScript can help enhance design and usability
Thank You
Will Slade
Senior CRM Consultant
linkedin.com/in/WillSlade

Contenu connexe

Tendances

Dynamics CRM 2013 Advanced Customizations
Dynamics CRM 2013 Advanced CustomizationsDynamics CRM 2013 Advanced Customizations
Dynamics CRM 2013 Advanced CustomizationsSatish
 
What Is Salesforce CRM, Editions, Licenses?
What Is Salesforce CRM, Editions, Licenses?What Is Salesforce CRM, Editions, Licenses?
What Is Salesforce CRM, Editions, Licenses?Thinqloud
 
Introduction to Custom Development in Microsoft Dynamics CRM 2015
Introduction to Custom Development in Microsoft Dynamics CRM 2015Introduction to Custom Development in Microsoft Dynamics CRM 2015
Introduction to Custom Development in Microsoft Dynamics CRM 2015Ashish Vishwakarma
 
Salesforce.com Prezo
Salesforce.com PrezoSalesforce.com Prezo
Salesforce.com Prezominihane88
 
Whats newinmicrosoftdynamicsgp2013r2
Whats newinmicrosoftdynamicsgp2013r2Whats newinmicrosoftdynamicsgp2013r2
Whats newinmicrosoftdynamicsgp2013r2Brandon Mitchell
 
#ImpactSalesforceSaturday: Salesforce Solution design – Performance Considera...
#ImpactSalesforceSaturday: Salesforce Solution design – Performance Considera...#ImpactSalesforceSaturday: Salesforce Solution design – Performance Considera...
#ImpactSalesforceSaturday: Salesforce Solution design – Performance Considera...New Delhi Salesforce Developer Group
 
Salesforce administrator training presentation slides
Salesforce administrator training presentation slides Salesforce administrator training presentation slides
Salesforce administrator training presentation slides Salesforce Associates
 
Javascript & OData Microsoft Dynamics CRM
Javascript & OData Microsoft Dynamics CRMJavascript & OData Microsoft Dynamics CRM
Javascript & OData Microsoft Dynamics CRMAshish Vishwakarma
 
Tuga IT 2016 Dynamics CRM with Office 365 and Azure
Tuga IT 2016 Dynamics CRM with Office 365 and AzureTuga IT 2016 Dynamics CRM with Office 365 and Azure
Tuga IT 2016 Dynamics CRM with Office 365 and AzurePedro Azevedo
 
Designing salesforce solutions for reuse - Josh Dennis
Designing salesforce solutions for reuse - Josh DennisDesigning salesforce solutions for reuse - Josh Dennis
Designing salesforce solutions for reuse - Josh DennisSakthivel Madesh
 
Salesforce Person accounts overview
Salesforce Person accounts   overviewSalesforce Person accounts   overview
Salesforce Person accounts overviewNaveen Gabrani
 
#ImpactSalesforceSaturday:360 degree view of salesforce integrations
#ImpactSalesforceSaturday:360 degree view of salesforce integrations#ImpactSalesforceSaturday:360 degree view of salesforce integrations
#ImpactSalesforceSaturday:360 degree view of salesforce integrationsNew Delhi Salesforce Developer Group
 
Dynamics 365 introduction and functional
Dynamics 365 introduction and functionalDynamics 365 introduction and functional
Dynamics 365 introduction and functionalSatish Reddy
 
Ms dynamics 365 First Overview
Ms dynamics 365 First OverviewMs dynamics 365 First Overview
Ms dynamics 365 First OverviewSameh Senosi
 
Building a CRM Application
Building a CRM ApplicationBuilding a CRM Application
Building a CRM ApplicationIron Speed
 
Forms and surveys for smart data collection
Forms and surveys for smart data collectionForms and surveys for smart data collection
Forms and surveys for smart data collectionNadia Adriana Negoita
 
Microsoft Dynamics CRM vs Salesforce
Microsoft Dynamics CRM vs SalesforceMicrosoft Dynamics CRM vs Salesforce
Microsoft Dynamics CRM vs SalesforceAccent Gold Solutions
 

Tendances (20)

Dynamics CRM 2013 Advanced Customizations
Dynamics CRM 2013 Advanced CustomizationsDynamics CRM 2013 Advanced Customizations
Dynamics CRM 2013 Advanced Customizations
 
Salesforce platform
Salesforce platformSalesforce platform
Salesforce platform
 
What Is Salesforce CRM, Editions, Licenses?
What Is Salesforce CRM, Editions, Licenses?What Is Salesforce CRM, Editions, Licenses?
What Is Salesforce CRM, Editions, Licenses?
 
Introduction to Custom Development in Microsoft Dynamics CRM 2015
Introduction to Custom Development in Microsoft Dynamics CRM 2015Introduction to Custom Development in Microsoft Dynamics CRM 2015
Introduction to Custom Development in Microsoft Dynamics CRM 2015
 
Mvp showcase
Mvp showcaseMvp showcase
Mvp showcase
 
Salesforce.com Prezo
Salesforce.com PrezoSalesforce.com Prezo
Salesforce.com Prezo
 
Whats newinmicrosoftdynamicsgp2013r2
Whats newinmicrosoftdynamicsgp2013r2Whats newinmicrosoftdynamicsgp2013r2
Whats newinmicrosoftdynamicsgp2013r2
 
#ImpactSalesforceSaturday: Salesforce Solution design – Performance Considera...
#ImpactSalesforceSaturday: Salesforce Solution design – Performance Considera...#ImpactSalesforceSaturday: Salesforce Solution design – Performance Considera...
#ImpactSalesforceSaturday: Salesforce Solution design – Performance Considera...
 
Salesforce administrator training presentation slides
Salesforce administrator training presentation slides Salesforce administrator training presentation slides
Salesforce administrator training presentation slides
 
Javascript & OData Microsoft Dynamics CRM
Javascript & OData Microsoft Dynamics CRMJavascript & OData Microsoft Dynamics CRM
Javascript & OData Microsoft Dynamics CRM
 
Tuga IT 2016 Dynamics CRM with Office 365 and Azure
Tuga IT 2016 Dynamics CRM with Office 365 and AzureTuga IT 2016 Dynamics CRM with Office 365 and Azure
Tuga IT 2016 Dynamics CRM with Office 365 and Azure
 
Designing salesforce solutions for reuse - Josh Dennis
Designing salesforce solutions for reuse - Josh DennisDesigning salesforce solutions for reuse - Josh Dennis
Designing salesforce solutions for reuse - Josh Dennis
 
Salesforce Person accounts overview
Salesforce Person accounts   overviewSalesforce Person accounts   overview
Salesforce Person accounts overview
 
#ImpactSalesforceSaturday:360 degree view of salesforce integrations
#ImpactSalesforceSaturday:360 degree view of salesforce integrations#ImpactSalesforceSaturday:360 degree view of salesforce integrations
#ImpactSalesforceSaturday:360 degree view of salesforce integrations
 
Salesforce
SalesforceSalesforce
Salesforce
 
Dynamics 365 introduction and functional
Dynamics 365 introduction and functionalDynamics 365 introduction and functional
Dynamics 365 introduction and functional
 
Ms dynamics 365 First Overview
Ms dynamics 365 First OverviewMs dynamics 365 First Overview
Ms dynamics 365 First Overview
 
Building a CRM Application
Building a CRM ApplicationBuilding a CRM Application
Building a CRM Application
 
Forms and surveys for smart data collection
Forms and surveys for smart data collectionForms and surveys for smart data collection
Forms and surveys for smart data collection
 
Microsoft Dynamics CRM vs Salesforce
Microsoft Dynamics CRM vs SalesforceMicrosoft Dynamics CRM vs Salesforce
Microsoft Dynamics CRM vs Salesforce
 

En vedette

Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript TutorialDHTMLExtreme
 
Interview Questions For Microsoft Dynamics CRM
Interview Questions For Microsoft Dynamics CRMInterview Questions For Microsoft Dynamics CRM
Interview Questions For Microsoft Dynamics CRMKumari Warsha Goel
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An IntroductionManvendra Singh
 

En vedette (6)

Introduction to JavaScript Basics.
Introduction to JavaScript Basics.Introduction to JavaScript Basics.
Introduction to JavaScript Basics.
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
 
Interview Questions For Microsoft Dynamics CRM
Interview Questions For Microsoft Dynamics CRMInterview Questions For Microsoft Dynamics CRM
Interview Questions For Microsoft Dynamics CRM
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 

Similaire à JavaScript 101 for Microsoft CRM 2011

CRM 2011 JavaScript: Learn how to customize the new CRM 2011 UR12 process dri...
CRM 2011 JavaScript: Learn how to customize the new CRM 2011 UR12 process dri...CRM 2011 JavaScript: Learn how to customize the new CRM 2011 UR12 process dri...
CRM 2011 JavaScript: Learn how to customize the new CRM 2011 UR12 process dri...Dynamic-CRM
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students shafiq sangi
 
HTML5 Up and Running
HTML5 Up and RunningHTML5 Up and Running
HTML5 Up and RunningCodemotion
 
Rits Brown Bag - Extending and Integrating in Microsoft Dynamics CRM
Rits Brown Bag - Extending and Integrating in Microsoft Dynamics CRMRits Brown Bag - Extending and Integrating in Microsoft Dynamics CRM
Rits Brown Bag - Extending and Integrating in Microsoft Dynamics CRMRight IT Services
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteRavi Bhadauria
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptdominion
 
Scripting languages
Scripting languagesScripting languages
Scripting languagesteach4uin
 
Rutgers - FrontPage 98 (Advanced)
Rutgers - FrontPage 98 (Advanced)Rutgers - FrontPage 98 (Advanced)
Rutgers - FrontPage 98 (Advanced)Michael Dobe, Ph.D.
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
Overview of atg framework
Overview of atg frameworkOverview of atg framework
Overview of atg frameworkYousuf Roushan
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Jonas Follesø
 
Hnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
Hnd201 Building Ibm Lotus Domino Applications With Ajax PluginsHnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
Hnd201 Building Ibm Lotus Domino Applications With Ajax Pluginsdominion
 
Headless commerce for developers - How to start a store
Headless commerce for developers - How to start a storeHeadless commerce for developers - How to start a store
Headless commerce for developers - How to start a storeGiacomo Lamonaco
 

Similaire à JavaScript 101 for Microsoft CRM 2011 (20)

CRM 2011 JavaScript: Learn how to customize the new CRM 2011 UR12 process dri...
CRM 2011 JavaScript: Learn how to customize the new CRM 2011 UR12 process dri...CRM 2011 JavaScript: Learn how to customize the new CRM 2011 UR12 process dri...
CRM 2011 JavaScript: Learn how to customize the new CRM 2011 UR12 process dri...
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students
 
HTML5 Up and Running
HTML5 Up and RunningHTML5 Up and Running
HTML5 Up and Running
 
Javascript session 1
Javascript session 1Javascript session 1
Javascript session 1
 
Rits Brown Bag - Extending and Integrating in Microsoft Dynamics CRM
Rits Brown Bag - Extending and Integrating in Microsoft Dynamics CRMRits Brown Bag - Extending and Integrating in Microsoft Dynamics CRM
Rits Brown Bag - Extending and Integrating in Microsoft Dynamics CRM
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScript
 
DITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NETDITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NET
 
Atlas Php
Atlas PhpAtlas Php
Atlas Php
 
web designing course bangalore
web designing course bangaloreweb designing course bangalore
web designing course bangalore
 
Scripting languages
Scripting languagesScripting languages
Scripting languages
 
Rutgers - FrontPage 98 (Advanced)
Rutgers - FrontPage 98 (Advanced)Rutgers - FrontPage 98 (Advanced)
Rutgers - FrontPage 98 (Advanced)
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Java script
Java scriptJava script
Java script
 
Overview of atg framework
Overview of atg frameworkOverview of atg framework
Overview of atg framework
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 
Hnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
Hnd201 Building Ibm Lotus Domino Applications With Ajax PluginsHnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
Hnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
 
C# with Renas
C# with RenasC# with Renas
C# with Renas
 
Headless commerce for developers - How to start a store
Headless commerce for developers - How to start a storeHeadless commerce for developers - How to start a store
Headless commerce for developers - How to start a store
 

Dernier

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Dernier (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

JavaScript 101 for Microsoft CRM 2011

  • 1. JavaScript 101 – Creating your first JavaScript in Microsoft Dynamics CRM 2011 Will Slade Senior CRM Consultant linkedin.com/in/WillSlade
  • 2. Objective  Review basic steps for creating your first JavaScript  Change how JavaScript is perceived in the user community  Show how non-developers can use basic JavaScript in Microsoft Dynamics CRM
  • 3. Agenda 1. What is JavaScript (aka: form scripting)? 2. Examples of JavaScript 3. The Basic Elements of JavaScript 4. JavaScript on Classic Forms in Microsoft Dynamics CRM 2011
  • 5. What is JavaScript?  It is code  Made for web browsers  Alters the content that is displayed
  • 7. In some documentation, there is reference to “Form Scripting” and “Jscript”,… Are these the same thing as JavaScript? JavaScript and Form Scripting
  • 8. Form Scripting - Jscript - JavaScript Microsoft refers to using JavaScript in CRM as Form Scripting. For the purposes of this presentation, scripting will simply be referred to as JavaScript. Here are some other helpful definitions: JavaScript from Wikipedia: JavaScript (JS) is an interpreted computer programming language. It was originally implemented as part of web browsers so that client-side scripts could interact with the user, control the browser, communicate asynchronously, and alter the document content that was displayed. More recently, however, it has become common in server-side programming, game development and the creation of desktop applications. jQuery from Wikipedia jQuery is a multi-browser JavaScript library designed to simplify the client-side scripting of JavaScript and HTML. Jscript vs. JavaScript from Wikipedia …..” A lot of people think that JScript and JavaScript are different but similar languages. That's not the case. They are just different names for the same language, and the reason the names are different was to get around trademark issues”,….
  • 9. JavaScript as a “Web Resource” in Microsoft CRM
  • 10. JavaScript in Microsoft Dynamics CRM 2011  Microsoft Dynamics CRM is a browser based application  Basically a bunch of webpages  JavaScript is included in a CRM webpage as a ‘Web Resource’ Types of Web Resources
  • 11. When does a JavaScript do its thing?
  • 12. When does JavaScript do its thing?  OnLoad  When the page opens  OnChange  When a field value changes on a form  OnSave  When a record is saved
  • 13. Why use JavaScript? (here are some quick examples)
  • 14. Basic examples of how JavaScript can be used  Change the color of a label on a field based on the value  Hide fields based on another value on the form  Display a map to a contact form that shows the contact address
  • 15. Writing Code Sounds Intimidating
  • 16. Maybe not so intimidating after all,…  Before we show actual code, keep in mind that it might not be that intimidating  JavaScript is code but if you break it down into its basic elements, it is often easier to understand
  • 18. JavaScript code sample function alertVIP() { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } This JavaScript changes the label color to red for the field ‘VIP’ Note: This is JavaScript for CRM 2011 which is different than CRM version 4.0. Some examples provided may not be supported in future versions
  • 19. JavaScript code elements function alertVIP() { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } function name
  • 20. JavaScript code elements function alertVIP() { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } Beginning bracket Ending bracket
  • 21. JavaScript code elements function alertVIP() { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } Semicolon that ends a line
  • 22. JavaScript code elements function alertVIP() { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } Exact field name in CRM
  • 23. JavaScript code elements function alertVIP() { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } CRM code and method for getting the field HTML Copy this exactly how it is here including parentheses and quotes JavaScript code is case-sensitive
  • 24. JavaScript code elements function alertVIP() { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } Replacement HTML code for this field’s label #ff000 is the color red
  • 25. JavaScript code elements function alertVIP() { document.getElementById("new_vip_c").innerHTML = "<b>VIP</b>"; } … and this is a different example that makes the field label Bold
  • 27. JavaScript code sample – adding logic function alertVIP() { var VIP = Xrm.Page.getAttribute("new_vip").getValue(); if(VIP == true) { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } else { document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>"; } }
  • 28. JavaScript code elements function alertVIP() { var VIP = Xrm.Page.getAttribute("new_vip").getValue(); if(VIP == true) { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } else { document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>"; } } var = Variable
  • 29. JavaScript code elements function alertVIP() { var VIP = Xrm.Page.getAttribute("new_vip").getValue(); if(VIP == true) { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } else { document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>"; } } VIP is the unique name for this variable that is used in this code
  • 30. JavaScript code elements function alertVIP() { var VIP = Xrm.Page.getAttribute("new_vip").getValue(); if(VIP == true) { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } else { document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>"; } } Field name in CRM
  • 31. JavaScript code elements function alertVIP() { var VIP = Xrm.Page.getAttribute("new_vip").getValue(); if(VIP == true) { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } else { document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>"; } } Method for getting the field value
  • 32. JavaScript code elements function alertVIP() { var VIP = Xrm.Page.getAttribute("new_vip").getValue(); if(VIP == true) { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } else { document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>"; } } Entire Logic statement
  • 33. JavaScript code elements function alertVIP() { var VIP = Xrm.Page.getAttribute("new_vip").getValue(); if(VIP == true) { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } else { document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>"; } } If asks the question: If the value for VIP equals (==) true note: the field “new_vip” is a bit value
  • 34. JavaScript code elements function alertVIP() { var VIP = Xrm.Page.getAttribute("new_vip").getValue(); if(VIP == true) { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } else { document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>"; } } If true then do this part of the code which turns the label red
  • 35. JavaScript code elements function alertVIP() { var VIP = Xrm.Page.getAttribute("new_vip").getValue(); if(VIP == true) { document.getElementById("new_vip_c").innerHTML = "<font color=#ff0000>VIP</font>"; } else { document.getElementById("new_vip_c").innerHTML = "<font color=#000000>VIP</font>"; } } If NOT true then do this part of the code which turns the label black
  • 36. Examples of frequently used code (the Microsoft CRM parts)
  • 37. Frequently used Microsoft CRM parts of the code  Hide a Field: Xrm.Page.getControl("name").setVisible(false);  Get a Value: Xrm.Page.getAttribute("name").getValue();  Set a Value: Xrm.Page.getAttribute("name").setValue(“Information");  Set as Read-Only: Xrm.Page.ui.controls.get("accountnumber").setDisabled (true) Online Guide from Microsoft
  • 38. Quick Online Reference from Microsoft  Direct Link: http://msdn.microsoft.com/en-us/library/jj602964#BKMK_AccessingAttributes  Microsoft Developer Network: http://msdn.microsoft.com/library
  • 39. Adding JavaScript to a Contact Form Classic Form – not the Process Form in Microsoft Dynamics CRM 2011
  • 40. Open the Contact Form  Settings > Customization > Solutions > Your Custom Solution  Components > Entities > Contact > Forms
  • 41. Go to Form Properties1 then click Add2 1 2
  • 42. Click New to add new Web Resource
  • 43. Type = Script (Jscript) then click Text Editor
  • 44. Paste your code into the Text Editor and Save
  • 45. Add OnLoad  Your new JavaScript has now been added to the Form Libraries list  In Form Properties under Event Handlers, click Add to add a new OnLoad event for the form
  • 46. Enable Function  Select your new JavaScript from the Library dropdown  Put in the function name to the script. In our example, it was alertVIP  Make sure the Enabled checkbox is checked for the JavaScript to run when the page loads  Note: The field new_vip must be on the form or the page will show an error
  • 47. OnLoad Added  Our new OnLoad event should now show in the Event Handlers list
  • 48. Add OnChange to VIP field  On the Field Properties for the VIP field, click on the Event tab
  • 49. Enable Function  Adding an OnChange is very similar to adding the OnLoad  Save and now the JavaScript will run every time you change the field value for VIP
  • 50. Contact with OnLoad and OnChange JavaScript
  • 51. Contact with OnLoad and OnChange JavaScript
  • 55. Summary  JavaScript is code added to a webpage to modify the display  JavaScript does not have to be that intimidating  Each element of a JavaScript serves a purpose and must be entered exactly - it is case-sensitive  JavaScript can help enhance design and usability
  • 56. Thank You Will Slade Senior CRM Consultant linkedin.com/in/WillSlade