Connecting HTML Web Resource and Forms in Dynamics 365 Model-Driven Apps with JavaScript (Implementing Dynamic Percentage Circles)
In the realm of Dynamics 365, customization often extends beyond the built-in features. Recently, I encountered a challenge: how to visually represent dynamic percentages for various skills on a Dynamics 365 form. This blog post delves into the HTML and JavaScript work that led to the creation of dynamic percentage circles, providing an engaging and informative solution.
1) Create Web Resources in PowerApps
a. Form_onload.js
Create a new JavaScript web resource named "Form_onload.js" in PowerApps. This script will handle the form onload event and set the client API context.
b. Diagram.html
Create a new HTML web resource named "Diagram.html" in PowerApps. This file will contain the HTML code, CSS styling, and JavaScript logic for dynamic percentage circles.
Overview of the HTML
Our HTML document is structured to accommodate dynamic percentage circles for different skills. We use counters, input fields, and canvases to create an interactive and visually appealing representation of skill levels. The design incorporates responsive elements for an optimal user experience.
CSS Styling
The CSS styling plays a crucial role in crafting the visual aesthetics of our dynamic percentage circles. The counters are designed with a circular shape, each representing a specific skill. Responsive design considerations ensure that the layout adapts to different screen sizes, offering a seamless experience.
JavaScript Logic
The heart of our solution lies in the JavaScript logic. The
circleProgress function initializes and animates circular progress based on
percentage values. Input fields dynamically update the circles, providing
real-time feedback. The logic also includes a smooth animation function for an
enhanced user experience.
Integration with Dynamics 365
To seamlessly integrate our solution with Dynamics 365, we utilize a web resource. The setClientApiContext function establishes a connection with the Dynamics 365 form, allowing us to retrieve and update skill values dynamically. This integration enhances the user interface and provides a streamlined experience.
2) Create OOB Form and Add HTML Web Resource
Create a new Out-of-the-Box (OOB) form in Dynamics 365 or use an existing one. Inside the form designer, add an HTML web resource component.
a. Select the Diagram.html file.
3) Identify HTML Web Resource Name & Update Form_onload.js
Inside the OOB form, the HTML web resource will be assigned a name. Copy the name.
Replace "WebResource_name" in the form_onload script with the actual name of the HTML web resource.
4) Upload JavaScript File to Form Events
Upload the "Form_onload.js" file to the form events:
OnLoad: Attach the "Form_onload.js" script to the form onload event.
OnChange: Attach the "Form_onload.js" script to the onchange event of required fields.
OnSave: Attach the "Form_onload.js" script to the form onsave event.
Usage and Customization
Users can effortlessly interact with the dynamic percentage circles on the Dynamics 365 form. Input fields allow for customization, enabling users to update skill percentages on the fly. The flexibility extends to customization options such as changing circle colors or adjusting dimensions to suit specific preferences.
Practical Example
Consider a scenario where a user needs to evaluate and
showcase their skills on a Dynamics 365 platform. The dynamic percentage
circles offer a visually engaging way to represent technical skills,
problem-solving abilities, communication skills, analytical thinking, coding
proficiency, and domain knowledge. This not only enhances the user experience
but also provides a clear and intuitive representation of skills.
Comments
Post a Comment