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

Deepak Ingale1
Mega Sage

Hi Lydia,


Could you please provide more info from which field or variable you are trying to set an approver.



It seems in   answer.push() method, you have used the record producer name. It is not going to work.



If you have variable, then it would be something like answer.push(current.variables.variablename.toString())


Hi Deepak,



I have the approver's name stored in two fields, initially the record producer variable: [FromSupervisor] and then on the HR_Case table it is stored as [Record_Producer_3] after the Record Producer creates the case.




The Workflow at present, is skipping the Approver Approval script I created and just marking as approved.   I have tried both fields without any success and the suggestion above.   I also added a timer as I saw in another article to delay it a few seconds just in case it did not have enough time to process the script without success.




I have found the coding for the HR Case table is a little different than on the incident side.



Thanks much for any guidance you can offer.


Could you please share the script


Also, you should refer variable name and not variable question field while scripting.


A custom field is created with u_ prefix, if you are referencing the custom field on hr_case table, its dictionary name should be referred while scripting and not the label.


LOADWEB.PNG