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

ProcessSubmit Request and ProcessWorkItemRequest

Hi guys i am using javascript to reassign an approval to someone else but i am having problems getting the workitemitds i am confused on what methods i can call on these two objects in javascript

var rDate = new Date();
                rDate.setDate(rDate.getDate() + 2);       
                CreateTask("00520000000tKm3", "IS IN SALES - SENIOR MANAGER", "SUP SUP", rDate, "High");
                UpdateCaseStage("Senior Manager");
                var request = new sforce.ProcessSubmitRequest();
                request.objectId = "{!Case.Id}";
                request.comments = "Test Process Submit Request";
                var processRequest = sforce.connection.process([request]);
                var record = new Array();
                record[0] = processRequest[0];
                /*var workItem = new sforce.ProcessWorkitemRequest();
                workItem.action = "Approve";
                workItem.workitemId = "04aT00000008POi";
                workItem.nextApproverIds = "00520000000sbtx";
                workItem.comments = "Assigned to Senior Manager";
                var processWorkItem = sforce.connection.process([workItem]);

What i am trying to do is get the workItemId from processRequest object but having no go help pls?
Each ProcessResult item will contain an array of workitem IDs:

So in your code below you can probably iterate through the items in processRequest[0].newWorkItemIds.
Hi were you able to resolve the problem.

I am also getting the following error :

{entityId:null, errors:{fields:null, message:'invalid cross reference id', statusCode:'INVALID_CROSS_REFERENCE_KEY', }, instanceId:null, instanceStatus:null, newWorkitemIds:null, success:'false', }

Thanks in advance.