- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2017 11:56 PM
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
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 12:04 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 08:20 AM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 08:26 AM
Yes We can Use getMessage
Thank you,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 08:32 AM
getMessage can be used in server side also?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 08:36 AM
No. In Server side we use gs.properties.
Thank you,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 08:47 AM
Mark Answer as correct accordingly if you get your answer.
Thank you,
Ashutosh