I want to change the background and text color of a field in a catalog task item depending on the ac

M_Tomy
Tera Expert

Dear Experts.

 

Please tell me.

 

For catalog task items, I would like to change the background and text color of certain field items once the checkbox is turned on.
Please refer to the attached image together.

By the way, the attached image is read-only, but the item I want to implement above is actually an input-enabled field.

1.png

Best regards.

2 ACCEPTED SOLUTIONS

Musab Rasheed
Tera Sage
Tera Sage

Hello,

If it is for SCTASK fields You can do this by going to Configure Style of field and under 'Value' you can specify condition.

https://www.servicenow.com/community/now-platform-forum/how-to-change-the-color-of-a-field-under-cer...

If it is for for SCTASK variables then use below solution.

https://www.servicenow.com/community/it-service-management-forum/catalog-item-variable-s-background-...

Please note : Fields and Variables are different, if you are referring to something from catalog item then refer them as variable and if you are referring to backend form like RITM or SCTASK form then refer them as fields.

Please hit like and mark my response as correct if that helps
Regards,
Musab

View solution in original post

Murthy Ch
Giga Sage

Hi @M_Tomy 

As you want to run this for the RITM variables you need to use below logic:
Write UI Policy on RITM and CTask level so that it will run only on RITM records and Catalog task records.

Give appropriate conditions and write the code in Run script section:

 

function onCondition() {
    var form = typeof g_sc_form != "undefined" ? g_sc_form : g_form;
    var myControl = form.getControl("alphanumeric");
    myControl.style.backgroundColor = 'Red';
    myControl.style.color = 'Blue';

}

 

MurthyCh_0-1666252121758.png

Refer below KB article for more info:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0547171 

 

Hope it helps

Let me know if any doubts

 

 

Thanks,
Murthy

View solution in original post

6 REPLIES 6

Hi @M_Tomy 

Thanks:)

Let me know if any doubts if you are stuck while implementing.

 

Thanks,
Murthy

@Murthy Ch 

 

I have tried the above script, it works into RITM and task but this script not changing text color (red) into SP (after submission of service request form).