Business Rule for Assignment_Group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2011 01:37 PM
I am making a business rule to auto assign the assignment_group field based on the user in the assigned_to field. This rule is going to be used when inserting project or project task records. I need this rule because when importing projects from MS Project the assignment_group field does not import.
The rule will looking something simple like this...
gr.setParameter('assignment_group', getUserGroup(current.assigned_to));
I am very new to glide records and all scripting in SN (going to training this week actually) and am wondering how to pull the users group from the name in a business rule. Anything would help, thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2011 02:48 PM
Have you created a function defined as "getUserGroup"? Assuming that everything about this function is working correctly, create a before insert (and update if needed) with:
current.assignment_group =getUserGroup(current.assigned_to);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2011 11:32 AM
The first problem I think of when dealing with setting the assignment group based off of the user is whether the user is in more than one group (in my instance I have one user that belongs to 26 groups) how do you determine the group that you would like to set.
I've heard of people getting around this by setting up a default group (u_default_group) in the users record in the sys_user table that is a reference field that points back to the sys_user_group. In that case you could query it straight from the user record. (current.assignment_group = current.assigned_to.u_default_group).
If you are super lucky and each person you are importing projects for is only a member of one group then you could use something like this in a before insert business rule to set the assignment group.
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user',current.assigned_to);
gr.query()
while(gr.next()){
current.assignment_group = gr.group;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2012 08:27 AM
I am looking for something like this to assign a user group how would you create the function you talked about to do this?