Trying to script an approval on a record producer that creates an HR Case.

lydia3
Kilo Contributor

I have a record producer pulling in the manager that I need to approve the request in the Workflow, but trying to get it to work in the approval process has been unsuccessful.  

The record producer is called FromSupervisor, I also have the field populating into the HR_Case in a newly added field Record_Producer_3.

I assumed that I needed to push that field over in the Approval Script on the Workflow, but it continues to skip over the approvals (not referencing anyone)

answer.push(FromSupervisor)

Any guidance would be most appreciated.

1 ACCEPTED SOLUTION

Getting closer!   Now that you have a field u_approver that is a reference, it is expecting a sys_id of a user record.   In your script above you are setting it to the Display Value of the FromSupervisor.   This should get your squared away:


current.u_approver = producer.FromSupervisor; - this is assuming FromSupervisor is a reference variable for the sys_user table.


View solution in original post

15 REPLIES 15

LOADWEB.PNG


OK thanks, wanted to double check that this field is also indeed on the hr_case table and not an extended table.   I see this field is of type string.   It should be set to reference and then you choose the User (sys_user) table as the referenced table.   Then save the dictionary record.



On your record producer, make sure the variable is also a reference to the User (sys_user) table.



Once that is done back in the workflow: Click the lock by Users, Click the Select Fields button (one just above the lock), and choose Record Producer 3 in that list.   Then that user will automatically get an approval.


I had to change some things on my end to make the adjustments above as I had an AJAX script automatically populating the field I need as the approver on the form.   As such I added a new field to the HR_Case table called u_Approver as the Record_Producer_3 field is used elsewhere and I could not set that as a Reference.  



I am trying to take the field populated by the AJAX and have it update the new field, but I have something wrong.   It does update the Record_Producer_3 with the name of the approver, but not the new Approver field.   Thanks again, I was able to select it as the Approver on the Workflow, just have to get the new field to populate and it should work.



See highlighted script below:


  LOADWEB.PNG


Getting closer!   Now that you have a field u_approver that is a reference, it is expecting a sys_id of a user record.   In your script above you are setting it to the Display Value of the FromSupervisor.   This should get your squared away:


current.u_approver = producer.FromSupervisor; - this is assuming FromSupervisor is a reference variable for the sys_user table.


You are awesome, that did it!   Thank you very much for all of the support!