Assigned to me UI ACTION

Ankit Kumar6
Tera Contributor

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

1 ACCEPTED SOLUTION

glad it helped,

 

kindly mark my answer as correct and close this thread. so it will appear into solved queue. 

View solution in original post

15 REPLIES 15

Harsh Vardhan
Giga Patron

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.

now i have tested the above code. which is working perfectly fine. let me know if you need any further help on it. 

 

screenshot for reference. 

 

find_real_file.png

 

UI Action

 

find_real_file.png

 

 

i tried your code,when i clicked the button then it assigned me but it cleared the assignment group field.

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.