- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 10:47 PM
I have a requirement to create a UI Action (button) on incident that should assign the current login user to assigned_to field.
Note: assigned to should be a member of assignment group then only it will accept the value. otherwise to create a popup to say you are not a member of this group
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2020 02:14 AM
glad it helped,
kindly mark my answer as correct and close this thread. so it will appear into solved queue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 11:01 PM
you can write here group member validation in your client callable script include and then use glide ajax in your ui action client side function to validate if user belong to group member or not.
eg:
Script Include :
var getMe = Class.create();
getMe.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDet: function(){
var id = this.getParameter('sysparm_user_name');
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', gs.getUserID());
gr.addQuery('group', id);
gr.query();
if(gr.getRowCount()>0){
return true;
}
else{
return false;
}
},
type: 'getMe'
});
UI Action script:
function runClientCode(){
var ga = new GlideAjax('getMe');
ga.addParam('sysparm_name', 'getDet');
ga.addParam('sysparm_user_name', g_form.getValue('assignment_group'));
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if(answer == 'false'){
alert('you are not part of group');
return false; //Abort submission
}
else{
g_form.setValue('assigned_to',g_user.userID);
gsftSubmit(null, g_form.getFormElement(), 'assgin_me');
}
}
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if(typeof window == 'undefined')
runBusRuleCode();
//Server-side function
function runBusRuleCode(){
current.update();
action.setRedirectURL(current);
}
Note: this is sample code, make changes based on your need.
If my answer helped you, kindly mark it as correct and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 11:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 11:55 PM
i tried your code,when i clicked the button then it assigned me but it cleared the assignment group field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2020 12:00 AM
can you please validate the code which i have mentioned because i had made some changes .
paste some screenshot, because i tested this on my personal instance and working fine.