passing property to script include and getting back sys ids script help?

Kiddy1
Tera Contributor

Developer Community harshtimes ctomasi shloke04 explorenow

Aim:Need to remove hard coded sys_ids from client scripts

i have created a script include which take the properties and returns sysids

in the below script i have 3 sys ids i need to paas them by creating a property to script include and return back sys ids from script include,i need help on creating a script include

which takes multiple properties from client script and return sysids.

script include:

var Passing_Sys_Ids = Class.create();

Passing_Sys_Ids.prototype = Object.extendsObject(AbstractAjaxProcessor, {

Passing_Sys_Ids:function()

{

var answer;

var prop_name = this.getParameter('sysparm_name_in');

answer = gs.getProperty(prop_name);

return answer;

},

      type: 'Passing_Sys_Ids'

});

client script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

if (isLoading || newValue == '') {

return;

}

    //Type appropriate comment here, and begin script below

var getSysIds = new GlideAjax('Passing_Sys_Ids');

getSysIds.addParam('sysparm_name','Passing_Sys_Ids');

getSysIds.addParam('sysparm_name_in',"domain1"); //domain1 is sys property which was created to store sys_id

getSysIds.getXML(sysid);

function sysid(response)

{

  var answer = response.responseXML.documentElement.getAttribute("answer");

  alert(answer);

}

if(g_user.hasRole('itil') && g_user.hasRole('DE') && !g_user.hasRole("admin")){

var   user = new GlideRecord('sys_user');

user.addQuery('sys_id',g_user.userID);

user.query();

while(user.next())

{

domain = user.sys_domain;

}

if(domain == b4d705920f061e00e316f77ce1050e80) // can i replace answer here?

{

g_form.setValue('assignment_group',b4d705920f061e00e316f77ce1050e93) ;//i need to remove hard coded sys ids from scripts

}

else

{

g_form.setValue('assignment_group',b4d705920f061e00e316f77ce1050e67);//i need to remove hard coded sys ids from scripts

}

}

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI Kids,



Use getMessage in client script and store this sys_id's in that message.



This is how we replace gs.properties in client script.



Thank you,


Ashutosh



Please Hit ✅Correct, ��Helpful, or ��Like depending on the impact of the response


View solution in original post

16 REPLIES 16

for display br i have used in client scripts ,now i have issue with catalog client scripts how can we specify the table in catalog client script to create a display business rule?



secondly



can we use getMessage to store the sysid value in a variable and then pass



var sysid=getMessage('name'); in client scripts?


Yes We can Use getMessage



Thank you,
Ashutosh


getMessage can be used in server side also?


No. In Server side we use gs.properties.



Thank you,
Ashutosh


Mark Answer as correct accordingly if you get your answer.



Thank you,


Ashutosh