Need help dot walking in assignment script for Assigned to.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 08:24 AM
Hi all,
I am attempting to create an assignment rule that sets the "Assigned to" field to the "Opened for's" Business Partner which is a value populated in their HR Profile. The Opened for field is a reference to the user table. I'm a beginner with scripting so I am looking for some assistance on how to populate the current record's "Assigned to" field with the Opened for's Business Partner using an Assignment rule or a Matching rule. Any assistance is greatly appreciated.
Taylor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 10:09 AM
Hi guys, thank you for helping me with this! I have tried this as a Matching Rule as well as a Business Rule with no result... I edited the code as follows, any tips?
function getHRPartner() { //I added a function name here as it was erroring without one
var profileGR = new GlideRecord('sn_hr_core_profile'); //this is our HR Profile table.. is this right to change from hr_profile?
profileGR.addQuery('user', current.opened_by);
profileGR.query();
if (profileGR.next()) {
current.assigned_to = profileGR.u_hr_business_partner; //this is the name of our Business Partner field
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 10:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 10:14 AM
I'll interject a few considerations:
Archana, I would actually discourage the use of a Business Rule in this scenario. BRs should be used with there isn't a configuration alternative. The HR Product often has configuration alternatives to typical scripting (Client Scripts, BRs, UI Policies, etc). In this case, the configuration alternative is the Platform-wide Assignment & Matching Rule systems.
So, Taylor, I feel you are right to consider Assignment Rule or Matching Rule.
My rule of thumb here:
Assignment Rule ==> Determine the Group
Matching Rule ==> Determine the Individual.
So, I would suggest you use the code that they suggest in a Matching rule script.
Also, you may not need to script this:
Take your matching rule, on the Resources tab, select Matching: Advanced (rather than scripted) and see if you can directly dot walk to the correct field.
Note: You do need to make sure you have an appropriate group selected (i.e. the individual should be in the selected group) for this to work. Address that with an Assignment rule.
Does that help?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 10:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 10:24 AM
Taylor,
If you are scripting in the matching rule, use this function:
(function getPotentialAssignees(current) {
// PUT ALL YOUR CODE HERE
})(current);
__________
Also:
Are you sure your u_hr_business_partner field is a reference to sys_user, not hr profile? That is important. You can't put a reference to the HR Profile in the Assigned to. It has to be the associated User for that HR Business Partner.