This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set Date field with date from OData query | |
// Set a variable with the value of the date field from OData query (query not shown here) | |
var date = data.d.results[0].DateField; | |
if (date != null) { | |
// Format the date field | |
var formattedDate = new Date(parseInt(date.replace("/Date(", "").replace(")/", ""), 10)); | |
Xrm.Page.data.entity.attributes.get("new_datefield").setValue(formattedDate); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="true"?> | |
-<service xmlns="http://www.w3.org/2007/app" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xml:base="https://yourorg.crm.dynamics.com/XRMServices/2011/OrganizationData.svc/"> | |
-<workspace> | |
<atom:title>Default</atom:title> | |
-<collection href="OpportunityCompetitorsSet"> | |
<atom:title>OpportunityCompetitorsSet</atom:title> | |
</collection> | |
-<collection href="SystemFormSet"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------------------- | |
// getContactData | |
// Query of the Contact entity from the Opportunity, based on Primary Contact | |
//------------------------------------------------------------------------------------------- | |
function getContactData() { | |
// Get Contact object | |
try {var contactObject = Xrm.Page.getAttribute("parentcontactid");} | |
catch(err){} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function showForm() { | |
//if the form is update form | |
if (Xrm.Page.ui.getFormType()==2) | |
// variable to store the name of the form | |
var lblForm; | |
// get the value picklist field | |
var relType = Xrm.Page.getAttribute("customertypecode").getValue(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use the value of an Option Set to set up a custom form layout | |
// This example assumes a company uses the same Opportunity form, | |
// but shows/hides sections and makes fields required/optional based | |
// on the value of a new_division field | |
// Consider using Business Rules before using this code | |
function opportunity_onLoad () { | |
// hook this up to the onLoad event and the onChange event of the new_division field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Consider using Business Rules before using this code | |
// Set Opportunity Est. Close Date as optional | |
Xrm.Page.getAttribute("estimatedclosedate").setRequiredLevel("none"); | |
// Set Opportunity Est. Close Date as required | |
Xrm.Page.getAttribute("estimatedclosedate").setRequiredLevel("required"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Consider using Business Rules before using this code | |
// Create variables for the tab an section | |
var tab=Xrm.Page.ui.tabs.get("TabName"); | |
var section = tab.sections.get("SectionName"); | |
// Hide a section | |
section.setVisible(false); | |
// Show a section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the value of the Opportunity Est. Close Date | |
var date = Xrm.Page.data.entity.attributes.get("estimatedclosedate").getValue(); | |
if (date != null) { | |
var day = date.getDate(); | |
var month = date.getMonth(); | |
var year = date.getFullYear(); | |
month++; | |
// Add leading 0's to single digit days and months | |
if (day < 10) {day = "0" + day;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set the value of the Opportunity Status Reason field | |
// Note: Option Set fields are set based on the database id, rather than the name | |
Xrm.Page.data.entity.attributes.get("statuscode").setValue(100000001); | |
// Set the value of the Opportunity Status Reason field to a variable | |
var statusReasonId = 100000001; | |
Xrm.Page.data.entity.attributes.get("statuscode").setValue(statusReasonId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the value of a Contact's first name | |
var firstName = Xrm.Page.data.entity.attributes.get("firstname").getValue(); |
OlderNewer