Display template value fields without their backend values
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2023 04:42 AM
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2023 05:52 AM
Hi @Divya139 ,
I trust you are doing great.
Here's an example of how you can achieve this:
- Open the form designer for the approval form in ServiceNow.
- Identify the template value fields that you want to display as front-end fields.
- Create a new UI policy for each field you want to modify.
- In each UI policy, set the "Type" to "Visibility" and configure the conditions to determine when the field should be visible.
- In the "Advanced" section of the UI policy, set the "UI Type" to "Visible" to make the field appear on the form.
- Save the UI policy.
Next, we'll use a client script to populate the front-end fields with the appropriate values from the backend.
- Create a new client script for the approval form.
- In the client script, use the "g_form.getValue()" function to retrieve the values of the template value fields.
- Use the "g_form.setValue()" function to set the values of the corresponding front-end fields.
- Save the client script.
For example, if you have a template value field called "template_field" and a front-end field called "frontend_field", the client script would look like this:
function onLoad() {
var templateValue = g_form.getValue('template_field');
g_form.setValue('frontend_field', templateValue);
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi