How to change variable background color

ESL
ServiceNow Employee
ServiceNow Employee

I am using service portal to request adding business application record. After I request, it will send the record to approver and the record include variables in service catalog.

I would like to change the background of these variables if the value in variables match some condition.

I tried to use catalog client script such us [g_form.getControl('submitted').style.backgroundColor = 'blue';] script, but it does not work as expected.

 

How can I achieve these requirement?

Please advice, Thanks

 

スクリーンショット 2022-10-05 17.23.31.png

8 REPLIES 8

ESL
ServiceNow Employee
ServiceNow Employee

Hi Dan 

Thanks for comment.

I have tried your code. It is not able to use g_form.getfield function.

スクリーンショット 2022-10-05 21.52.10.png

 

And I also tried this code, it shows the 'backgroundColor is not defined' error.

スクリーンショット 2022-10-05 21.53.30.pngスクリーンショット 2022-10-05 21.53.18.png

Dan O Connor
ServiceNow Employee
ServiceNow Employee

Give me a few minutes until I try it on my instance, wrote that of the top of my head but might actually need a getElement

Dan O Connor
ServiceNow Employee
ServiceNow Employee

Sorry should also ask, where are you wanting the color change to appear?

 

In the catalog item request, or on the approval record? There is like a variable formatter that forms part of the approval record showing the variables passed from a request, and I'm not sure if you can apply styles to that formatter

ESL
ServiceNow Employee
ServiceNow Employee

I would like to see the color in the approval record.

Actually there are some hidden variables in the catalog item request, I will compare 2 variable value, if the value is not same, I would like to change the variable background color to let the approver know the value is different.