Need to add property value in script include

Ashwini8
Tera Contributor

Hi All,

Actually there is a script include definition where the assignment group value is  setting based on CI and category value.

for few category's we have defined some assignment group sys ID in the script include, but now i just replaced the sysID with the system property which i have created for each group. but that is not working. Please suggest.

Before adding the property the code was like this and it was working fine.

CIAssignmentgroup: function(cmdb_ci) {

cmdb_ci = JSUtil.nil(cmdb_ci) ? this.getParameter("sysparm_cmdb_ci") : cmdb_ci; // Passing cmdb as parameter
var category = this.getParameter("sysparm_category").toString(); //Passing category as parameter
var gr = new GlideRecord("cmdb_ci");
gr.addEncodedQuery('sys_id=' + cmdb_ci + '^support_groupISNOTEMPTY');
gr.query();
gs.log("TR:cat " + category);
if (gr.next()) {
var support = gr.getValue("support_group"); //Getting the value of CI's support group
return support.toString(); // return support group as answer
} else {
if (category == 'security') {
return '71272132db10e01057e2e2d2ca96193f';
} else if (category == 'Cloud') {
return 'f5272132db10e01057e2e2d2ca961933';
} else if (category != '' && support == '') {
return '';
}
}

return 'false';

After adding the property its not setting the assignment group, please find below script.

CIAssignmentgroup: function(cmdb_ci) {

var security = gs.getProperty('Security.SOC.Assignment.Group.SysID');
var cloud = gs.getProperty('Cloud.Assignment.Group.SysID');
var SD = gs.getProperty('Service.Desk.Assignment.Group.SysID');

cmdb_ci = JSUtil.nil(cmdb_ci) ? this.getParameter("sysparm_cmdb_ci") : cmdb_ci; // Passing cmdb as parameter
var category = this.getParameter("sysparm_category").toString(); //Passing category as parameter
var gr = new GlideRecord("cmdb_ci");
gr.addEncodedQuery('sys_id=' + cmdb_ci + '^support_groupISNOTEMPTY');
gr.query();
gs.log("TR:cat " + category);
if (gr.next()) {
var support = gr.getValue("support_group"); //Getting the value of CI's support group
return support.toString(); // return support group as answer
} else {
if (category == 'security') {
return security;
} else if (category == 'Cloud') {
return cloud;
} else if (category != '' && support == '') {
return SD;
}
}

return 'false';

},

 

 

3 REPLIES 3

Community Alums
Not applicable

If it's a scoped app use the name (its a bit different than global)

Also, you may use (especially if domain separated!) GlideProperties.get("CSM_debug_log",false); instead of gs.getProperty()

 

Cheers,

Joro

 

find_real_file.png

 

Hi Joro,

Its not a scoped application. Just I replaced the sys id with the property. How i need to use the property in script include?

Regards,

Tejaswini RG

Allen Andreas
Administrator
Administrator

Hi,

Please use the appropriate forum feature "Insert/Edit code sample" when pasting code. This helps keep things organized and easier to read: 

find_real_file.png

Other than that, please use log statements to help you troubleshoot, else you're just coding in the dark. Double-check your values and switch the one log statement I saw to gs.info() instead.

In your testing, what category did you see?

What does your other script show is being returned?

Considering changing these to this, just in case:

return security.toString();

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!