Making service portal form variable bold
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 04:35 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 06:03 PM - edited 11-28-2023 06:05 PM
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.
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.
Then in the Catalog Client Script, make sure that the Isolate script checbox is cleared.
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 👍✔️
Anvesh