The CreatorCon Call for Content is officially open! Get started here.

Assign to me button issue on incident form???

madhu517
Kilo Contributor

Hi All,

I have an UI action created on my incident form , here the issue is whenever the user clicks on assigned to me button on incident form it is

clearing the assignment group field value whatever is there and setting the assigned to value to me itself.

But, here   i need that the assignment group field value should not be removed.

Below is the code for UI action:

var currentUserID = gs.getUserID();

var userDefaultGroup = '';

var userSysID = '';

var queryUserRecord = new GlideRecord('sys_user');

queryUserRecord.addQuery('sys_id',currentUserID);

queryUserRecord.query();

while (queryUserRecord.next()) {

userDefaultGroup = queryUserRecord.u_default_group;

userSysID = queryUserRecord.sys_id;

  }

current.state = 2;

current.assignment_group = userDefaultGroup;

current.assigned_to = userSysID;

action.setRedirectURL(current);

current.update();

Here they are setting the assignment group value based on the users default group, which was set in their user account. But In our instance no user record is set with the default group. How can i fix this issue to set the assignment group and assigned to value if the user clicks on "Assigned to me" button to set the default values...

Please help me on this

Thanks

Madhuri.K

17 REPLIES 17

Hi Gaurav,



In my code, mentioned below I havent gliderecord, so we should not have security issue..


You can try this,



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


var userID = g_user.userID;


g_form.setValue('opened_by',userID);


}


Sharique Azim
Mega Sage

Hi,



Use:



var currentUserID = gs.getUserID();



var userDefaultGroup = '';


var userSysID = '';


var queryUserRecord = new GlideRecord('sys_user');


queryUserRecord.addQuery('sys_id',currentUserID);


queryUserRecord.query();


while (queryUserRecord.next()) {


userDefaultGroup = queryUserRecord.u_default_group;


userSysID = queryUserRecord.sys_id;


  }




current.state = 2;


//current.assignment_group = userDefaultGroup;


current.assigned_to = userSysID;


action.setRedirectURL(current);


current.update();




thats it