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

So if I understand you want Assignment Group to stay as is if the current user is part of Assignment Group & clicks on Assigned To.


If so, add the below condition to the UI Action



(gs.getUser().isMemberOf(current.assignment_group))



This will make Assigned To Me button visible only when the logged in User is part of Current Assignment Group.


Hi Jaspel singh,



After adding the condition as (gs.getUser().isMemberOf(current.assignment_group))


the assignment group is getting removed.



Pls Sugest me.



Thanks


Madhuri.K


I tested the same & it worked well for me. After adding the condition the Assigned to Me button appeared only for the User who is part of current assignment group correct?



Also, could you help me with the code written for UI Action along with condition for it. Also, could you check if there is any dependency added to the Assignment Group field by checking its dictionary.


Hi Jaspal,


The assigned to field is dependent on assignment group


and pls check the below code in screen shot.



code for assign to me.PNG


Thanks


Madhuri.K


Hi Madhuri,


In the condition, please add a "(" first bracket for the condition to be executed..