Please wait, loading...

 

How to create and use the Web Resources in Microsoft Dynamics 365 CE/CRM.

June 20, 2023
How to Create a Web Resource in Microsoft Dynamics 365 CE/CRM
  • First go the CRM -> Settings
  • Select the Advanced Settings option ,
https://dvmske.com/wp-content/uploads/2023/06/2023-06-14_13-40-52-768x349.png
  • Click in front of Settings and append it.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-14_13-48-34-768x350.png
  • Go to Customization Section ,
  • click onĀ Solutions option .
https://dvmske.com/wp-content/uploads/2023/06/2023-06-13_22-58-59.png
  • Select the particular Solution in which you want to create the web resource.
  • Or you can create your new solution.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-13_23-11-43.png
  • OnĀ  Solution that we have selected under Component
  • Click on the Web Resource .
https://dvmske.com/wp-content/uploads/2023/06/2023-06-14_00-36-48.png
  • Click on New to create a Web Resource.
  • Give appropriate Name to your Web Resource and
  • Copy the same name to Display Name.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-14_00-45-47-768x342.png
  • On Content select Type of language on which you want to work on,
  • We select Script(JScript).
  • Select Language
https://dvmske.com/wp-content/uploads/2023/06/2023-06-14_01-09-19-768x288.png
  • Click on Text Editor to open it.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-14_01-16-56.png

Scenario - How to get the GUID and logical name of a record of particular entity (table) using JavaScript in D365 CRM/CE.

In this scenario We have a requirement from a Customer to get the GUID and logical name of a recordĀ  of the entity(table) while updating the record .

Syntax to get the GUID:
var recordId = formContext.data.entity.getId();
Syntax to get the Entity Name:
var entityName = formContext.data.entity.getEntityName();
Code:
function (executionContext) {
Ā  Ā  Ā  Ā  var formContext = executionContext.getFormContext();
Ā  Ā  Ā  Ā  var recordId = formContext.data.entity.getId();
Ā  Ā  Ā  Ā  var entityName = formContext.data.entity.getEntityName();
Ā  Ā  Ā  Ā  alert(`Record GUID: ${recordId} and Entity Name: ${entityName}`);
Ā  Ā  }
  • Copy the above code .
  • Paste your Code in Text Editor.
  • And click on ok.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-17_16-51-51-2.png
  • After adding your code in Text Editor click on Save.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-14_01-24-59.png
  • Click on Publish to publish your Web Resource .
  • As your customizations start publishing it will take few minutes to publish it.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-11_03-13-03.png
OUTPUT
https://dvmske.com/wp-content/uploads/2023/06/2023-06-18_00-37-01-768x479.png
How to use a Web Resource in Microsoft Dynamics 365 CE/CRM ?
  • Select the particular Entity on which you want to add your Web Resource .
  • Expand it and click on Forms
  • Then again click on main form of your selected Entity.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-18_00-47-39-768x474.png
  • Open the form by Double click on main form of your selected Entity.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-18_01-02-22-768x483.png
  • Click on Form PropertiesĀ to open it.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-14_14-00-16-1.png
  • On Form Properties page click on Add in Form Libraries to add the web resource.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-14_14-02-59-1.png
  • On Lookup record page search for your Web Resource that you have created.
  • and click on Add.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-14_14-10-12.png
  • After finding the web resource click on Add.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-14_14-13-44.png
  • After adding the web resource .
  • Add the Event according to your requirements .
  • Click on Add
https://dvmske.com/wp-content/uploads/2023/06/2023-06-18_02-05-43.png
  • Select the web resource in the Library option.
  • Paste the name of the function in the Function option.
  • Check both the option Enabled and Pass execution context as first parameter .
https://dvmske.com/wp-content/uploads/2023/06/2023-06-18_02-16-39.png
  • Click on Save.
  • After saving click on Publish to publish all the customizations.
https://dvmske.com/wp-content/uploads/2023/06/2023-06-18_02-48-07-640x420.png
  • Go to CRM and click onĀ  Account Entity .
  • Open the particular record on which you want to update.
  • Suppose we want to update the Fax fieldĀ 
  • After updating the fax field click on Save as you can se one alert message is pop-up containing record GUID and logical name of the Entity
https://dvmske.com/wp-content/uploads/2023/06/2023-06-18_02-54-31-640x307.png
OUTPUT
https://dvmske.com/wp-content/uploads/2023/06/2023-06-19_16-56-03.png

Nisha Kumari