The CreatorCon Call for Content is officially open! Get started here.

How to call a System Property to the Catalog Client Script?

Alfiya
Tera Contributor

Hi All,

So we have a custom table, there are multiple records in this table and this table has a field called 'name', 

There another field on Catalog item called 'cat_name',Now this 'cat_name' field is a reference field to the above mentioned custom table

So below is the either of the ways we were getting the values of the custom table:

                        1) By using getReference() and then hard coding the value of the 'name' Field to identify the record in the                                catalog item Script in catalog item.

or

                        2) By Hard coding the sysid of that record in the catalog Client Script in the catalog item.

So as hard coding is not recommended, I want to do it with system properties. So for each of this record I want to create a system property and then call this system property to the Catalog Client script.

So as gs.getProperty() can't be used in the catalog client script. How can it be fetched?

I now understand that this can be achieved by using a  script Include, But I'm not sure how this can be done.

Also if there is any other way we can do this, please guide me.

Thanks in Advance..

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

only way is to use GlideAjax and then use gs.getProperty() and return the value

OR

1) create hidden string variable and hide it always

2) in the default value give this

javascript: gs.getProperty('property_name')

3) then you can access the property value using g_form.getValue('hiddenVariableName');

Regards
Ankur

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

only way is to use GlideAjax and then use gs.getProperty() and return the value

OR

1) create hidden string variable and hide it always

2) in the default value give this

javascript: gs.getProperty('property_name')

3) then you can access the property value using g_form.getValue('hiddenVariableName');

Regards
Ankur

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

Mark Roethof
Tera Patron
Tera Patron

Hi there,

GlideAjax with getXMLAnswer would be the best way to go. Unfortunately, it will be a bit of work 😞
See some info in this article which I wrote a while ago:
Client Side Scripting: Go for GlideAjax (with getXMLAnswer)!

The suggestion from Ankur about a hidden variable wouldn't be that hard to achieve and is a nice workaround. Be aware though: this also actually submits and creates a variable with that value. 

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn