How to avoid using sysid in client scripts

Eric Hartojo
Tera Contributor

Hi there,

 

I have an issue retrieving sys_id that is stored in system properties. As you can see on the pictures, I'm trying to set a value for hidden assignment group that I call in record producer. For some reason using g_scratchpad didn't work at all. If I replace g_scratchpad with sys id like 'das89asd89ad', it picked up the correct group. It's not best practice to hardcode sys_id but I can't make the scratchpad work. Any alternatives or solutions?

 

Attached are display business rules and client script images.

2 ACCEPTED SOLUTIONS

@Eric Hartojo since this is a record producer (catalog item) and not a table so display BR may not work, you will have to use GlideAjax.

If it would have been a client script on some table and not catalog client script, your BR would have worked perfectly.


Raghav
MVP 2023
LinkedIn

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@Eric Hartojo

members have already suggested to use onLoad/onChange + GlideAjax

what did you start and where are you stuck?

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

View solution in original post

4 REPLIES 4

Sagar Pagar
Tera Patron

Hi @Eric Hartojo,

 

You can retrieve the sys_id from System property in record producer scripts and assign  values.

 

 

If you need it to change client scripts then you have to use the Client callable Script include and GlideAjax call to retrieve it and use it to change client scripts.

 

Take a look at once of my article - System Properties & it's Usage

It will help you to serve your purpose.

 

Thanks,
Sagar Pagar

 

 

The world works with ServiceNow

Hi @Sagar Pagar ,

 

I used Display Business rule with g_scratchpad variable method but it didn't work as I mentioned on the question. Didn't know if I miss something. Do I have to use GlideAjax?

@Eric Hartojo since this is a record producer (catalog item) and not a table so display BR may not work, you will have to use GlideAjax.

If it would have been a client script on some table and not catalog client script, your BR would have worked perfectly.


Raghav
MVP 2023
LinkedIn

Ankur Bawiskar
Tera Patron
Tera Patron

@Eric Hartojo

members have already suggested to use onLoad/onChange + GlideAjax

what did you start and where are you stuck?

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