onAfter Transform Script not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 10:25 AM
I have an onAfter transform script in which I added line of code hoping that it would help populate the Requested for name on the RITM.
So to provide a little more information - there is a Business Rule that has the following script:
The business rule script as it currently is will make sure that the correct requested_for name is right on both the ritm and the req. That is working fine; however, with this script and the transform onAfter script the job that runs that creates an Onboard ritm - the requested for name is empty. That is my dilemma. I need the requested for name to be the same on both the REQ and RITM across the board.
If I change the Business Rule script to the below then the requested for name is correct on the Onboarding ritm and req, but then the name is incorrect on the REQ on all the other forms.
// if(true){
// var user = current.variables.on_behalf_ref.getDisplayValue();
// current.request.requested_for.setDisplayValue(user);
// }
if(current.variables.on_behalf == "Yes")
{
current.u_requested_for = current.variables.on_behalf_ref; // set the custom requested for field from the on behalf variable from the variables sections.
}
else if (current.variables.requester)
{
current.u_requested_for = current.variables.requester; // set the custom requested for field from the requestor variable from the variables sections
}
else
{
current.u_requested_for = current.request.requested_for;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 11:14 AM
Hi,
So why don't you supply Requested for information at the beginning only. You can write a Field script and use field maps instead of doing this in OnAfter script.
Thanks,
Ashutosh Munot

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 11:33 AM
So what I did is I created a second business rule using the script that works for onboard creation including that script for only that item and the 1st business rule with the script that works for all the other forms saying to only do this if the form is NOT the onboard. That seemed to have done the trick, I just have to do more testing.
For your solution - I will test this out as well.
Thank you for your help. If your solution works I will mark as correct. It may take me about a week or so because I am on multiple projects. But I will not forget to come back and mark correct if so.
Thanks again.