Making service portal form variable bold

Wendy20
Tera Expert

Hi all,

 

I need some advice on how to make a variable (question) in a service portal form to be "bold".  Thank you in advance for your suggestions. 

 

Kind regards,

Wendy

1 REPLY 1

AnveshKumar M
Tera Sage
Tera Sage

Hi @Wendy20 

The possible way is using an onLoad catalog client script. Follow the steps below.

 

1. Create an onLoad catalog Client script in your catalog item like the one below.

AnveshKumarM_0-1701222847021.png

 

2. Use the script provided below and save the form.

Note: Make the necessary changes in script for your variable name and variable question text as mentioned in the script comments.

 

function onLoad() {

    setTimeout(function() {

        if (window != null) {
            // native view
            // Change it to your variable name instead of test_variable
            g_form.getControl('test_variable').setAttribute('style', 'font-weight: bold;font-size: 18px;');
        } else {
            // portal view
            // Change it to your variable name instead of sp_formfield_test_variable, modify it to sp_formfield_<YOUR_VARIABLE_NAME>
            var aTags = this.document.getElementById("sp_formfield_test_variable");
            aTags.style.fontWeight = 'bold';
			aTags.style.fontSize = 'large';
			
			var aTagsLab = this.document.getElementsByClassName("field-label");
			var searchText = "Test variable"; //Change this to your variable question text
			var found;

			for (var i = 0; i < aTagsLab.length; i++) {
				if (aTagsLab[i].textContent.toString() == searchText) {
					aTagsLab[i].style.fontWeight = 'bold';
					break;
				}
			}
        }

    }, 3000);

}

 

 

If the above one didn't worked, do the following changes

 

Right Click on Catalog Client Script Form Header then Configure -> Form Layout and bring the Isolate Script field to the selected list and save.

AnveshKumarM_1-1701223052885.png

 

Then in the Catalog Client Script, make sure that the Isolate script  checbox is cleared.

AnveshKumarM_2-1701223224657.png

 

If you want only the label should be Bold, use the following script.

 

function onLoad() {

    setTimeout(function() {

        if (window != null) {
            // native view
            // Change it to your variable name instead of test_variable
            g_form.getControl('test_variable').setAttribute('style', 'font-weight: bold;font-size: 18px;');
        } else {
            // portal view
			
			var aTagsLab = this.document.getElementsByClassName("field-label");
			var searchText = "Test variable"; //Change this to your variable question text
			var found;

			for (var i = 0; i < aTagsLab.length; i++) {
				if (aTagsLab[i].textContent.toString() == searchText) {
					aTagsLab[i].style.fontWeight = 'bold';
					break;
				}
			}
        }

    }, 3000);

}

 

 

Be informed that, the bold face will be enabled after 3 seconds on form loading.

Please mark my answer helpful and accept as a solution if it helped 👍✔️

 

Thanks,
Anvesh