Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Set Dependent for Custom Fields

Jaeik Lee
Mega Sage

I made 2 different custom fields in sc_task table.

 

field1 : 

u_zassignmentid

Reference(sys_user_group)

 

field2 :

u_zassigneeid

Reference(sys_user)

 

I set field2 dependent that lookup field1 value like Assignment Group and Assigned to.

But it did not work.

Why it does not work? How can i do?

 

Thank you for answer.

 

1 ACCEPTED SOLUTION

Hi @Jaeik Lee 

I see. Thanks for capturing the details.

The above behavior does not work if the dependent reference field (field 1 above in your case) does NOT include "group" in its name.

So just include the "group" word in your field1, which is referencing to the sys_user_group table. Then replace the dependent value with the new field name. And it should do the trick.

 

Ref: KB0998861 - Dependent field does not work as expected on task "Assigned to" field.

 

Cheers,

Tai Vu

View solution in original post

7 REPLIES 7

Anand Kumar P
Giga Patron

Hi @Jaeik Lee ,

In assigned to field dependent value use assignment_group 
or
You can write reference qualifier on assignment group and use below script

var UserGroup = Class.create();
UserGroup.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

	
	getMembers : function(groupId){
		gs.log("group",groupId);
		var id = [];
	var gr = new GlideRecord('sys_user_grmember');
		gr.addQuery("group",groupId);
		gr.query;
		while(gr.next()){
			id.push(gr.getValue("user"));
		}
		
		gs.log('sys_idIN+id.join();' +"sys_idIN"+id.join());
		return "sys_idIN"+id.toString();
	},
    type: 'UserGroup'
});
javascript:new UserGroup().GetMembers(current.assignment_group);

or 
https://www.servicenow.com/community/developer-articles/catalog-items-make-assigned-to-dependent-on-... 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Stefan Reichelt
Tera Guru

I tried that in my PDI, and I got it working at first attempt for the field2 -> field1 relation.

I just put "u_zassignmentid" into the "Dependent Field" of field2, and then I could always get the right users that were in the previously selected group. I would just beautify it with a UI Policy and clear the user field when the group field is emptied.

 

Is your setup anyhow different? If it still doesn't work, can you maybe share a few screenshots of the field dictionary entries?

Hi. there is screen shot of my works.

 

 

Tai Vu
Kilo Patron
Kilo Patron

Hi @Jaeik Lee 

Can you share what you have done so far and highlight any aspects that didn't function as expected?

 

Cheers,

Tai Vu