+ Start a Discussion
gsickalgsickal 

Bug in processSubmitRequest?

Is there a bug in processSubmitRequest?  I have a process that requires the  approver to be manually chosen but when I run the processSubmitRequest on this I get an error saying a required field is missing.  If I try to set the nextOwnerId it doesn't work either.  Is this a bug or if manual requests are not supported is there a graceful way to determine this and report it back to users instead of displaying a message implying a field is missing?  Here is the syntax:
 
Code:
var request = new sforce.ProcessSubmitRequest();
request.objectId = id;
//request.nextOwnerId = approverIds;
//request.comment = "Test Process Submit Request";

var requests = new Array(1);
requests[0] = request;

var results = sforce.connection.process(requests);

 
 
 
Best Answer chosen by Admin (Salesforce Developers) 
RajaramRajaram
You are using the following:
 
//request.nextOwnerId = approverIds;
//request.comment = "Test Process Submit Request";
 
There is nothing called nextOwnerId in processSubmitRequest. You should  use .nextApproverIds, it should work. Here is the piece from the WSDL
 
<complexType name="ProcessRequest">
<sequence>
<element name="comments" type="xsd:string" nillable="true"/>
<element name="nextApproverIds" type="tns:ID" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</sequence>
</complexType>
 
 
Hope this helps!

All Answers

RajaramRajaram
Here is a sample piece of code:
public ProcessResult[] doProcessSample(String comments, String id, String[] approverIds) throws ApiFault { 
ProcessResult[] processResults;
ProcessSubmitRequest request = new ProcessSubmitRequest();
request.setComments(comments);
request.setNextApproverIds(approverIds);
request.setObjectId(id);
try {
//calling process on the approval submission
processResults = binding.process(new ProcessSubmitRequest[]{request});
for (ProcessResult processResult : processResults) {
if(processResult.getSuccess()){
if(xconfig.isTraceMessage()){
log.debug("Approval submitted for: " + id + ", approverIds: " +
approverIds.toString() + " successful.");
log.debug("Process Instance Status: " +
processResult.getInstanceStatus());
}
} else{
log.error("Approval submitted for: " + id + ", approverIds: " +
approverIds.toString() + " FAILED.");
log.error("ERRORS: " + processResult.getErrors().toString());
}
}
} catch (Exception e) {
e.printStackTrace();
}
return processResults;


}

You should set the next approvers using the "setNextApproverIds" method.

Hope this helps..
Raja

gsickalgsickal

Thanks, I saw that example for Java.  My example though is for an Ajax Scontrol and comes straight from the Ajax api docs.  My question still remains, how do you set the approver id for a manual process?  it didn't work for me.

RajaramRajaram
You are using the following:
 
//request.nextOwnerId = approverIds;
//request.comment = "Test Process Submit Request";
 
There is nothing called nextOwnerId in processSubmitRequest. You should  use .nextApproverIds, it should work. Here is the piece from the WSDL
 
<complexType name="ProcessRequest">
<sequence>
<element name="comments" type="xsd:string" nillable="true"/>
<element name="nextApproverIds" type="tns:ID" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</sequence>
</complexType>
 
 
Hope this helps!
This was selected as the best answer
gsickalgsickal
Thanks, this did the trick.  There is a bug in the API documentation online for the process call that references "nextOwnerId" but should be changed to say "nextApproverIds"
jimmijamzjimmijamz
Hi gsickal, how did you manually reassign the nextApprover via code?

is 'processSubmitRequest' not only for Initially Approval Request?

and processWorkItemRequest only has for 'approve' 'reject' and 'remove'. There's nothing for 'Reassign'

The below code doesn't quite work...

Code:
var request = new sforce.ProcessSubmitRequest();
request.objectId = "50020000001OzsgAAC";
request.nextApproverIds = "00520000000riinAAA";
          
var proResults = sforce.connection.process([request]);

 

jimmijamzjimmijamz
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);

 

kstites1kstites1
Is there a way to make a list button on leads to mass submit leads for approval?