Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to hide the string field label alone in the form?

Gowri S
Tera Expert

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.

1 ACCEPTED SOLUTION

Karthiga S
Kilo Sage

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

View solution in original post

5 REPLIES 5

SwarnadeepNandy
Mega Sage

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

Hi  Swarnadeep Nandy, 

Thanks for replying, as I want this behavior in incident form the solution didn't help.

Karthiga S
Kilo Sage

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

Thanks a lot Karthiga, your reply really helped 😊