Using group sys id in client script. Want to Convert group sys id into System Properties
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 09:42 PM
I have catalog client script that uses group id and display variable based on group member on RITM and Task. I want to convert sys id into System Properties.
I used below Business rule and Client script. But not able to achieve this. Is below script is correct ? What table name do i need to use in business rule?
Business rule:
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.my_property = gs.getProperty('sysid.assignment_group');
})(current, previous);
function onLoad() {
var u_user_id = g_user.userID;
var u_grp_id = g_scratchpad.my_property
getgroupUsrMembership(u_user_id, u_grp_id);
}
function getgroupUsrMembership(u_userID, u_grpID) {
var gaX2 = new GlideAjax('Tools');
gaX2.addParam('sysparm_name', 'checkUserMemberOfGroup');
gaX2.addParam('sysparm_usr', u_userID);
gaX2.addParam('sysparm_grp', u_grpID);
gaX2.getXMLAnswer(processLoad);
}
function processLoad(answer) {
var u_ismember;
if (answer == "false") {
u_ismember = false;
g_form.setMandatory('variables.approval', false);
g_form.setDisplay('variables.approval', false);
} else {
u_ismember = true;
if (g_form.ui_policy && g_form.ui_policy.approvals)
g_form.setDisplay('variables.approval', true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 10:16 PM
Hi Krishna
you can only define scratchpad in a display business rule
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response helped in any way
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 10:20 PM
Hi @Krishna Priya,
The g_scratchpad variables only wok in display business rule.
You need to use the script include and onload/ on change client scripts.
Take a look at one of my article. It will help you.
System Properties & it's Usage
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar