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 dictionary attributes via script.

mduluk
Giga Expert

Is there a way to set dictionary attributes by a script? What I want to do is set it so if the assigned to is blank, assignment group tree_picker is true. If there is a name in the assigned to I would like tree picker to be false.

Reason: I have a business rule that only shows the assignment groups that a user is part of if there is a name in assigned to. The problem is that if there is a nested group that someone is part of the sub group and not part of the parent, the sub group does not show up. The easy answer is ether un-nest the group, or make the members part of the parent, but I was curious if I could do the script instead.

3 REPLIES 3

CapaJC
ServiceNow Employee
ServiceNow Employee

I don't think that's possible, but that's only 'cuz I can't think of a way.

A possible hacky workaround that I've only half thought out:
1) have assignment_group use the tree picker
2) create a second reference to sys_user_group, make it not use the picker
3) UI Policy shows the field you want to use based on value of assigned_to
4) client script and business rule to keep the two fields in sync based on which one got changed

So basically the new field is just a shadow copy of the real assignment_group field that gets used by scripts, but lets you do what you want.


mduluk
Giga Expert

Definitly hacky, but could work. I'll play with it. I think 'un-nesting' some of the groups might end up being the idea, thanks for the idea.


tac11tac
Kilo Contributor

I'm at the same spot.



It would be nice to have a g_form.setAttribute(fieldName, 'Tree-picker', true);   i.e   in section 5 of the GlideForm page...



5 Change Field


void |   setAttribute(fieldName, attribute, boolean)



attribute would be a single attribute of an allowable list of attributes on the field.   I'm imagining that some of the attributes would be more problematic to change than others.   Hopefully, 'Tree_Picker' would be an easy one to implement.