Client-scripting - DynamicsPal
Client-scripting

Client scripting

Client-side scripting object model, we apply client-side programming to runs on browser. With the help of scripting we can interact with entity forms and their controls. JavaScript is one of the ways to apply custom business process logic for displaying data on a form in Customer Engagement.

Web resources

Web resources are virtual files that are stored in the Microsoft Dynamics 365 database and that you can retrieve by using a unique URL address. They can be referenced in multiple places such as in sitemaps, in entity forms, in dashboards, and command buttons. We can create the following different types of web resources like Webpage(HTML), Script(JScript), etc.

Limitations of Web resources

• There is no supported way of using the server-side code in HTML Web Resources.
• A web resource can contain code that is processed in the browser to execute web service calls to interact with Dynamics 365 data.
• Web resources are only available by using the Dynamics 365 web application security context. Only licensed Dynamics 365 users who have the necessary privileges can access them.

Size Limitation
We can upload the maximum size of files by Organization.MaxUploadFileSize property. Go to the System Settings in the Dynamics 365 application you can set this property in the Email tab and Set Maximum file size (in kilobytes). This setting limits the size of files that can be attached to email messages, notes, and web resources. The maximum default of the file that can be uploaded as a Web resource is 5 MB.

Creating Web Resources

Before creating your Web resource which is need to be important. It is always recommended to create you web resource in a custom solution so that it can be easily exported and deployed to other environments.

Create and Edit Web Resources

• Go to you demo solution- Setting/Solution.
• Under Components, choose Web Resources.
• To create a web resource- Choose New.
To edit a web resource- Double click the web resource you want to edit.
• The web resource form has the following fields and capabilities.

Name: Demo.js
Display Name: Demo.js
Type: Web Page (HTML)
Language: English

Note: Prefix will be added to Name automatically based on the publisher being selected while creating the solution.
• Click on the Text Editor button to open the editor.
• Design your first HTML web page contents in the Rich Text editor.
• Use the Rich Text editor toolbar to modify the content style.
• Click on OK to close the Text Editor.
• Click on the Save and Publish buttons.
• Click on the PREVIEW button on the top to preview our HTML web resource.

Accessing forms and controls using client-side code

Use the data and ui objects under the formContext object to programmatically manipulate data and user interface elements in Customer Engagement.

Understanding client-side events
To call custom JavaScript method we have event handlers. We can configure our client-side code to execute on specific events for dynamically associate our method to a corresponding event.
Form events
We have two events where we can write our client-side code:
• OnLoad
• OnSave

Was this article helpful?

No 0

×