- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I created a Catalog Client Script to auto-populate a field in a form based on "Assignment Group" field. The info of that field is used in a Flow action to populate assignment group on a new SCTASK. It works fine if I use the sys_id in the script, however I'm now required to do it using system properties to pass quality gates. Could you please advice on the easiest way to implement this?
Client Script Code:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
To successfully pass quality gates and avoid hardcoded sys_id in your Catalog Client Script, you should transition to using GlideAjax paired with a Script Include.
- Create the Script Include
- Name: GetCatalogItemProperty
- Client callable: Check the box true
var GetCatalogItemProperty = Class.create();
GetCatalogItemProperty.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSysProperty: function() {
var propertyName = this.getParameter('sysparm_property_name');
return gs.getProperty(propertyName);
},
type: 'GetCatalogItemProperty'
});
- Update your Catalog Client Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 'your_condition_here') //Update your condition
{
var ga = new GlideAjax('GetCatalogItemProperty');
ga.addParam('sysparm_name', 'getSysProperty');
ga.addParam('sysparm_property_name', 'your.system.property.name'); // Define your system property key here
ga.getXMLAnswer(function(answer) {
if (answer) {
g_form.setValue(' field_it_1_1', answer);
}
});
}
}
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
You should use GlideAjax to call a Script Include which will simply use gs.getProperty to return the value of that property to the client, which you can then use to set the variable value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
To successfully pass quality gates and avoid hardcoded sys_id in your Catalog Client Script, you should transition to using GlideAjax paired with a Script Include.
- Create the Script Include
- Name: GetCatalogItemProperty
- Client callable: Check the box true
var GetCatalogItemProperty = Class.create();
GetCatalogItemProperty.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSysProperty: function() {
var propertyName = this.getParameter('sysparm_property_name');
return gs.getProperty(propertyName);
},
type: 'GetCatalogItemProperty'
});
- Update your Catalog Client Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 'your_condition_here') //Update your condition
{
var ga = new GlideAjax('GetCatalogItemProperty');
ga.addParam('sysparm_name', 'getSysProperty');
ga.addParam('sysparm_property_name', 'your.system.property.name'); // Define your system property key here
ga.getXMLAnswer(function(answer) {
if (answer) {
g_form.setValue(' field_it_1_1', answer);
}
});
}
}
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
This is great! I'll try this. Thank you very much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @Esteban_Neri ,
Since this is a Catalog Client Script, you can't access system properties directly from client-side code using gs.getProperty(). A common approach is:
- Store the required Assignment Group sys_ids in System Properties.
- Create a Script Include (client callable) or GlideAjax that reads the system properties on the server.
- Call the Script Include from your Catalog Client Script to retrieve the sys_id values, then compare and set the field accordingly.
This keeps the sys_ids out of the client script, satisfies quality gate requirements, and still allows your Flow to receive the correct sys_id for creating the SCTASK.
If the values are only needed by the Flow, an even better approach is to read the system properties directly within the Flow Action or a server-side script, avoiding the need to expose the sys_ids to the client altogether.