UrbanPro
true

Learn MS Dynamics CRM from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

MS Dynamic CRM Client Side Scripts

Jayakar Reddy
11/10/2017 0 0

Get the value from a CRM field:

var value = Xrm.Page.getAttribute(“CRMFieldLogicalName”).getValue();

Set the value of a CRM field:
Xrm.Page.getAttribute(“CRMFieldLogicalName”).setValue(“New Value”);

Get the value from a CRM OptionSet field:
var value = Xrm.Page.getAttribute(“CRMOptionSetLogicalName”).getValue();

Get the text from a CRM OptionSet field:
var text = Xrm.Page.getAttribute(“CRMOptionSetLogicalName”).getText();

Set the value of a CRM OptionSet field:
Xrm.Page.getAttribute(“CRMOptionSetLogicalName”).setValue(“1″); // OptionSet Value

Get the selected text of a CRM OptionSet field:
Xrm.Page.getAttribute(“CRMOptionSetLogicalName”).getSelectedOption().text;

Get the selected value of a CRM OptionSet field:
Xrm.Page.getAttribute(“CRMOptionSetLogicalName”).getSelectedOption().value;

Get the text and value of a CRM Lookup field:
var lookupObject = Xrm.Page.getAttribute(“CRMLookupLogicalName”).getValue();
lookupObject[0].name; // text of lookup
lookupObject[0].id; // Guid of lookup

Set the value of a CRM Lookup field:
var lookupData = new Array();
var lookupItem = new Object();
lookupItem.id = “4A2A54CB-349C-E111-8D26-1CC1DEE8DA78″; // Guid of record
lookupItem.name = “New Contact”; // Entity record name
lookupItem.entityType = “EntityLogicalName”;
lookupData[0] = lookupItem;
Xrm.Page.getAttribute(“CRMLookupLogicalName”).setValue(lookupData);

Disable CRM field:
Xrm.Page.ui.controls.get(“CRMFieldLogicalName”).setDisabled(true);

Hide CRM field:
Xrm.Page.ui.controls.get(“CRMFieldLogicalName”).setVisible(false);

Hide a Tab in CRM:
Xrm.Page.ui.tabs.get(“tabName”).setVisible(false);

Hide a Section in CRM:
var tab = Xrm.Page.ui.tabs.get(“tabName”);
tab.sections.get(“sectionName”).setVisible(false);

Set the Requirement level in CRM:
Xrm.Page.getAttribute(“CRMFieldLogicalName”).setRequiredLevel(“required”);
Xrm.Page.getAttribute(“CRMFieldLogicalName”).setRequiredLevel(“none”);
Xrm.Page.getAttribute(“CRMFieldLogicalName”).setRequiredLevel(“recommended”);

Set Focus on a field in CRM:
Xrm.Page.ui.controls.get(“CRMFieldLogicalName”).setFocus(true);

Cancelling Onsave Event in CRM:
event.returnValue = false;
return false;

Check IsDirty in CRM field:
var isDirty = Xrm.Page.getAttribute(“CRMFieldLogicalName”).getIsDirty();
alert(isDirty); // returns true if the field is dirty

Check IsDirty for all the fields in CRM:
var isDirty = Xrm.Page.data.entity.getIsDirty();
alert(isDirty); // returns true if any of the field is dirty in the entire form.

Force Submit a read only field in CRM:
Xrm.Page.getAttribute(“CRMFieldLogicalName”).setSubmitMode(“always”);

Preventing an attribute to be saved in CRM form:
Xrm.Page.getAttribute(“CRMFieldLogicalName”).setSubmitMode(“never”);

Get Unique Organization Name in CRM:
Xrm.Page.context.getOrgUniqueName();

Get Server url in CRM:
Xrm.Page.context.getServerUrl();

Get the record Id in CRM:
Xrm.Page.data.entity.getId();

Get the User Id in CRM:
Xrm.Page.context.getUserId();

Get the Entity Logical Name in CRM:
Xrm.Page.data.entity.getEntityName();

Get the UserRole Id’s in CRM:
var userRoles = Xrm.Page.context.getUserRoles();
for (var i = 0; i < userRoles.length; i++)
{
var userRole = userRoles[i]; // returns the Role Id
}

Get the Form Type in CRM:
Xrm.Page.ui.getFormType();

Form Types in CRM:
Is the user creating a new record?
Xrm.Page.ui.getFormType() == 1

Is the user updating an existing record?
Xrm.Page.ui.getFormType() == 2

Is the user unable to update this record?
Xrm.Page.ui.getFormType() == 3

Is this record deactivated?
Xrm.Page.ui.getFormType() == 4

Is the user using the Quick Create form?
Xrm.Page.ui.getFormType() == 5

Is the user using the Bulk Edit form?
Xrm.Page.ui.getFormType() == “6″

Save a record in CRM:
Xrm.Page.data.entity.save(); // for saving a record
Xrm.Page.data.entity.save(“saveandclose”); // for save and close
Xrm.Page.data.entity.save(“saveandnew”); // for save and new

Close the form in CRM:
Xrm.Page.ui.close();

Open EntityForm in CRM:

Xrm.Utility.openEntityForm(“opportunity”, Xrm.Page.data.entity.getId());

Get all Active process Stages:

var ProcessStages = Xrm.Page.data.process.getActiveProcess().getStages().getAll();

Set Business process Satage:

Xrm.Page.getAttribute(“stageid”).setValue(ProcessStages[0].getId());

0 Dislike
Follow 2

Please Enter a comment

Submit

Other Lessons for You

Plugins In Microsoft Dynamics CRM
Microsoft Dynamics CRM plug-ins are one of the most commonly used and powerful approaches to extending the application. A plug-in for CRM is custom code, written and compiled in .Net, that is “triggered”...

Developing integration utility with Microsoft Dynamics
We all know that the evolution of the technologies has been tremendous in couple of years, leading to development and implementation of the systems in more compact and well integarted way. Each day a...

Architecture of Business Process Flow in Dynamics 365
Business Process Flows till CRM 2016 Every record with Business process flow till Microsoft Dynamics 2016 , used to have two attributes specific to them:- Process ID : Process Stage ID. To set a desired...

What is M.S.Project ?
MICROSOFT PROJECT contains project work and project groups, schedules and finances.Microsoft Project permits its users to line realistic goals for project groups and customers by making schedules, distributing...

Creating/Setting/Admin Center of Dynamics CRM - Office 365
Introduction Dynamics 365 is a cloud service launched by Microsoft. It combines its Cloud CRM and ERP services into a single offering.Microsoft Dynamics 365 is the next generation of intelligent business...

Looking for MS Dynamics CRM Training?

Learn from Best Tutors on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for MS Dynamics CRM Classes?

The best tutors for MS Dynamics CRM Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn MS Dynamics CRM with the Best Tutors

The best Tutors for MS Dynamics CRM Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more