function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jimmijamzjimmijamz 

Approvals - How to REASSIGN the approvers via code? HELP!


I've been trying for the past few days trying to get my head around all the javascript coding as i'm not a developer.

I've managed to APPROVE & REJECT and also submit approvals however, i can't seem to Reassign Approvals to other people via coding! HELP!


Below is my code for Approving a request. What is it for Reassignment?

is action = "Reassign";
on the API documentation, and also the WDSL,    nextApproverIds is actually a string() array



Code:
var request = new sforce.ProcessWorkitemRequest();
request.action = "Approve";
request.workitemId = workItemIds[i].Id; <-- this is ProcessInstanceWorkItemID
request.comments = "This approval request has been automatically 'APPROVED' via SQL Account Transfer Process";
debug(request.workitemId);
var proResults = sforce.connection.process([request]);

 


jimmijamzjimmijamz
Found another thread and it gave me an idea.

For further clarification for the newbies like me who are not programmers.

To have this 'Reassignment' the next approver must be set to 'Let approver manually select who the next approver is'

Code:
var request = new sforce.ProcessWorkitemRequest();
request.action = "Approve";
request.workitemId = workItemIds[i].Id; // ie. processinstacneworkitem ID
request.nextApproverIds = "00520000000riinAAA";
request.comments = "This approval request has been automatically 'REASSIGNED'";

var requests = new Array(1);
requests[0] = request;
var proResults = sforce.connection.process(requests);