We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Short Description must change Dynamically

SaiMounikaY
Tera Contributor

Hi All,

I need help in changing the record producer short description dynamically when particular state users opens the record producer. I created a label type variable as short description and written onload client script can anyone help with working code.

3 REPLIES 3

Ankur Bawiskar
Tera Patron

@SaiMounikaY 

record producer short description cannot be dynamic

As a workaround do this

-> keep short description of record producer as empty

-> create multiple HTML type variables and store the content in it particular to each state

-> then use onLoad catalog client script and check state of logged in user and then hide the other HTML variables 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@SaiMounikaY 

Just a quick follow-up—were you able to review the suggested approach?
Please let me know if you need any assistance.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Tanushree Maiti
Tera Patron

Hi @SaiMounikaY 

 

Try with this

 

  1. Create onload Catalog Client script

 

function onLoad() {

    g_form.getReference('sys_user', function(user) {

        if (user.state == '<YOUR_TARGET_STATE>') { // Replace with actual state field name and value

            g_form.setValue('short_description', 'Your Custom Short Description');

        } else {

            g_form.setValue('short_description', 'Default Short Description');

        }

    });

}

 

  1. Record Producer Script (Server-Side)

Because Client Scripts only affect the UI, ensure the mapped value applies to the final generated record (like an Incident) by using the Record Producer's script field. 

 

var userGR = new GlideRecord('sys_user');

if (userGR.get(gs.getUserID())) {

    if (userGR.state == '<YOUR_TARGET_STATE>') {

        producer.short_description = 'Your Custom Short Description';

    } else {

        producer.short_description = 'Default Short Description';

    }

}

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti