+ Start a Discussion

Approve Custom Object in SControl

I have a custom object and I wanted to be able to approve it via a SControl.
I was looking at the api "ProcessWorkitemRequest" but do not see any sample on it
I was trying the following code but am getting an error

var request = new sforce.ProcessWorkitemRequest();

request.action = "Approve";

request.workitemId = "{!MyObject__c.Id}";

request.comment = "Automated approval.";

var processRes = sforce.connection.process([request]);

This is giving an error -

"invalid cross reference id"

Any help?