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 08:51 AM
Something like this would work. Replace the u_business_partner with whatever your custom field is named (since I don't see Business Partner field on my hr_profile table).
(function (){
var profileGR = new GlideRecord('hr_profile');
profileGR.addQuery('user', current.opened_by);
profileGR.query();
if (profileGR.next()) {
current.assigned_to = profileGR.u_business_partner;
}
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 09:16 AM
Hi Taylor,
I have not worked on HR tables yet. Below one is the code of Erik and is edited.
Create a before BR on your current table. Check Insert and Update as required.
var profileGR = new GlideRecord('hr_profile'); profileGR.addQuery('user', current.opened_by); profileGR.query();
if (profileGR.next()) {
current.assigned_to = profileGR.u_business_partner; }
Hope this helps!
Thanks,
Archana

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 09:24 AM
Ah forgot the "query" line... I've edited my code. Thanks for catching!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 09:30 AM