Populate selected user name once attestation checkbox is checked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2024 08:34 AM
Hi All,
I am having a requirement in one catalog item with 1 checkbox variable - Attestation. Once this is checked, next to this variable , I need to display the name of the person which is available in Requested for.
Label should not appear, only name should be visible . Is this possible?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2024 08:43 AM
@Renu9 I doubt if you would be able to capture the Requested for name on a variable before the catalog item is submitted using a client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2024 09:13 AM
Hi @Renu9 ,
You can try with onChange catalog client script on checkbox variable.
Create a single line text field and set name of requested for person name and try below code to hide the label
g_form.setLabelOf('<field_name>',''); // replace the field name
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2024 06:21 AM
According to https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/client/c_GlideFormAPI#r_GlideFo... setLabelOf(String fieldName, String label) is not supported by Service Catalog.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2024 09:22 AM
Hi @Renu9
Just Now I have tried in my PDI by creating two variables
1: as mentioned by you creation of check box called " Attestation"
2: creation of HTML field and made it Read Only. and also as mentioned by you label will not appear and I made setLabelof to NULL;
Below is the code and the images:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
g_form.setLabelOf('Requestforpopulate', ' '); // name of HTML field
return;
}
// Asynchronously get the value of the 'user_name' field and process it with the callback function
g_form.getReference('user_name', callback);
function callback(data) {
if (data) {
var userFullName = data.name;
// Display the name next to the checkbox with rich text formatting
if (newValue === 'true') {
g_form.setValue('Requestforpopulate', '\t' + userFullName); //// name of HTML field
} else {
g_form.setValue('Requestforpopulate', ''); // name of HTML field
}
}
}
}
when selected:
when not selected:
Thanks and Regards
Sai Venkatesh