How to Create a Web Resource in Microsoft Dynamics 365 CE/CRM
- First go the CRM -> Settings
- Select the Advanced Settings option ,
- Click in front of Settings and append it.
- Go to Customization Section ,
- click onĀ Solutions option .
- Select the particular Solution in which you want to create the web resource.
- Or you can create your new solution.
- OnĀ Solution that we have selected under Component
- Click on the Web Resource .
- Click on New to create a Web Resource.
- Give appropriate Name to your Web Resource and
- Copy the same name to Display Name.
- On Content select Type of language on which you want to work on,
- We select Script(JScript).
- Select Language
- Click on Text Editor to open it.
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.
- After adding your code in Text Editor click on Save.
- Click on Publish to publish your Web Resource .
- As your customizations start publishing it will take few minutes to publish it.
OUTPUT
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.
- Open the form by Double click on main form of your selected Entity.
- Click on Form PropertiesĀ to open it.
- On Form Properties page click on Add in Form Libraries to add the web resource.
- On Lookup record page search for your Web Resource that you have created.
- and click on Add.
- After finding the web resource click on Add.
- After adding the web resource .
- Add the Event according to your requirements .
- Click on Add
- 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 .
- Click on Save.
- After saving click on Publish to publish all the customizations.
- 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