- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 06:40 AM
Hi,
I need a checkbox and string field, when checkbox is checked, only string field value should be displayed not the label. Is there a way to hide the label alone?
I need this field value to be populated in report as well. So I don't want to use UI Macros.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 06:56 AM
Hi @Gowri S
Try hiding the label with the below code.
Apply the necessary conditions as per your requirement.
g_form.setLabelOf('u_textfield',''); //u_textfield is your field name
Please mark it Correct and Hit Like if you find this helpful!
Regards,
Karthiga

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 06:53 AM
Hello @Gowri S,
One possible solution is to use a Catalog Client Script to hide the label of the string field using JavaScript. A Catalog Client Script is a script that runs on the client side when a user interacts with a catalog item or record producer.
Here are the steps to do this:
- Create a checkbox variable with the name hide_label in your catalog item.
- Create a string variable with the name string_field in your catalog item.
- Create a Catalog Client Script for your catalog item with the following properties:
- Type: OnChange
- Variable name: hide_label
- Name: Hide label script
- Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Get the label element of the string field
var labelElement = document.getElementById('label.' + g_form.getControl('string_field').id);
//Check if the checkbox is checked
if (newValue == true) {
//Hide the label element
labelElement.style.display = 'none';
} else {
//Show the label element
labelElement.style.display = 'block';
}
}
- Save the Catalog Client Script and test your catalog item in Service Portal. You should see that the label of the string field is hidden when the checkbox is checked.
- To populate the string field value in a report, you can create a report on sc_req_item table with Choose Columns showing number, item and .variables.string_field. You should see that the string field value is displayed in the report.
I hope this helps.
Kind Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 08:11 AM
Thanks for replying, as I want this behavior in incident form the solution didn't help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 06:56 AM
Hi @Gowri S
Try hiding the label with the below code.
Apply the necessary conditions as per your requirement.
g_form.setLabelOf('u_textfield',''); //u_textfield is your field name
Please mark it Correct and Hit Like if you find this helpful!
Regards,
Karthiga
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 08:12 AM
Thanks a lot Karthiga, your reply really helped 😊