Display template value fields without their backend values

Divya139
Tera Contributor

Hi,

I want to show the template value fields on the approval form not in their backend value but as front end fields. Attached a screenshot on how these values are coming now. I want them as proper fields and values.

Thanks

1 REPLY 1

Amit Gujarathi
Giga Sage
Giga Sage

Hi @Divya139 ,
I trust you are doing great.

Here's an example of how you can achieve this:

  1. Open the form designer for the approval form in ServiceNow.
  2. Identify the template value fields that you want to display as front-end fields.
  3. Create a new UI policy for each field you want to modify.
  4. In each UI policy, set the "Type" to "Visibility" and configure the conditions to determine when the field should be visible.
  5. In the "Advanced" section of the UI policy, set the "UI Type" to "Visible" to make the field appear on the form.
  6. Save the UI policy.

Next, we'll use a client script to populate the front-end fields with the appropriate values from the backend.

  1. Create a new client script for the approval form.
  2. In the client script, use the "g_form.getValue()" function to retrieve the values of the template value fields.
  3. Use the "g_form.setValue()" function to set the values of the corresponding front-end fields.
  4. 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