Technology. People. Progress.
Development

Create and use web resources in Dynamics 365

Add web resources to your Dynamics 365 CE environment.

Create and use web resources in Dynamics 365

1.What are Web Resources and their different types in Microsoft Dynamics 365 CE/CRM

2.Different types of Events on form and events handlers using JavaScript with example Microsoft Dynamics 365 CE/CRM

3.Call Xrm.WebApi.retrieve Record using JavaScript MSCRM/CE , Retrieving lookup / related entity using Web API JavaScript FetchXML Microsoft Dynamics CE / CRM

How to Create a Web Resource in Microsoft Dynamics 365 CE/CRM

  • First go the CRM -> Settings
  • Select the Advanced Settings option ,
Screenshot from the DVMSKE tutorial
How to Create a Web Resource in Microsoft Dynamics 365 CE/CRM — screenshot 1 View full size
  • Click in front of Settings and append it.
Screenshot from the DVMSKE tutorial
How to Create a Web Resource in Microsoft Dynamics 365 CE/CRM — screenshot 2 View full size
  • Go to Customization Section ,
  • click on Solutions option .
Screenshot from the DVMSKE tutorial
How to Create a Web Resource in Microsoft Dynamics 365 CE/CRM — screenshot 3 View full size
  • Select the particular Solution in which you want to create the web resource.
  • Or you can create your new solution.
Screenshot from the DVMSKE tutorial
How to Create a Web Resource in Microsoft Dynamics 365 CE/CRM — screenshot 4 View full size
  • On  Solution that we have selected under Component
  • Click on the Web Resource .
Screenshot from the DVMSKE tutorial
How to Create a Web Resource in Microsoft Dynamics 365 CE/CRM — screenshot 5 View full size
  • Click on New to create a Web Resource.
  • Give appropriate Name to your Web Resource and
  • Copy the same name to Display Name.
Screenshot from the DVMSKE tutorial
How to Create a Web Resource in Microsoft Dynamics 365 CE/CRM — screenshot 6 View full size
  • On Content select Type of language on which you want to work on,
  • We select Script(JScript).
  • Select Language
Screenshot from the DVMSKE tutorial
How to Create a Web Resource in Microsoft Dynamics 365 CE/CRM — screenshot 7 View full size
  • Click on Text Editor to open it.
Screenshot from the DVMSKE tutorial
How to Create a Web Resource in Microsoft Dynamics 365 CE/CRM — screenshot 8 View full size

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:

Code example
var recordId = formContext.data.entity.getId();

Syntax to get the Entity Name:

Code example
var entityName = formContext.data.entity.getEntityName();

Code:

Code example
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.
Screenshot from the DVMSKE tutorial
Code: — screenshot 9 View full size
  • After adding your code in Text Editor click on Save.
Screenshot from the DVMSKE tutorial
Code: — screenshot 10 View full size
  • Click on Publish to publish your Web Resource .
  • As your customizations start publishing it will take few minutes to publish it.
Screenshot from the DVMSKE tutorial
Code: — screenshot 11 View full size

OUTPUT

Screenshot from the DVMSKE tutorial
OUTPUT — screenshot 12 View full size

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.
Screenshot from the DVMSKE tutorial
How to use a Web Resource in Microsoft Dynamics 365 CE/CRM ? — screenshot 13 View full size
  • Open the form by Double click on main form of your selected Entity.
Screenshot from the DVMSKE tutorial
How to use a Web Resource in Microsoft Dynamics 365 CE/CRM ? — screenshot 14 View full size
  • Click on Form Properties to open it.
Screenshot from the DVMSKE tutorial
How to use a Web Resource in Microsoft Dynamics 365 CE/CRM ? — screenshot 15 View full size
  • On Form Properties page click on Add in Form Libraries to add the web resource.
Screenshot from the DVMSKE tutorial
How to use a Web Resource in Microsoft Dynamics 365 CE/CRM ? — screenshot 16 View full size
  • On Lookup record page search for your Web Resource that you have created.
  • and click on Add.
Screenshot from the DVMSKE tutorial
How to use a Web Resource in Microsoft Dynamics 365 CE/CRM ? — screenshot 17 View full size
  • After finding the web resource click on Add.
Screenshot from the DVMSKE tutorial
How to use a Web Resource in Microsoft Dynamics 365 CE/CRM ? — screenshot 18 View full size
  • After adding the web resource .
  • Add the Event according to your requirements .
  • Click on Add
Screenshot from the DVMSKE tutorial
How to use a Web Resource in Microsoft Dynamics 365 CE/CRM ? — screenshot 19 View full size
  • 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 .
Screenshot from the DVMSKE tutorial
How to use a Web Resource in Microsoft Dynamics 365 CE/CRM ? — screenshot 20 View full size
  • Click on Save.
  • After saving click on Publish to publish all the customizations.
Screenshot from the DVMSKE tutorial
How to use a Web Resource in Microsoft Dynamics 365 CE/CRM ? — screenshot 21 View full size
  • 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
Screenshot from the DVMSKE tutorial
How to use a Web Resource in Microsoft Dynamics 365 CE/CRM ? — screenshot 22 View full size

OUTPUT

Screenshot from the DVMSKE tutorial
OUTPUT — screenshot 23 View full size

Need help applying this to your business?

Talk to our team about your systems and next step.

Talk to our team
Open original image