How to change the ownership of the document to an admin, irrespective of who sent the document?

How to change the ownership of the document to an admin, irrespective of who sent the document?

Scenario: I have set up a workflow/automation in CRM to send documents to Zoho Sign. When the document is sent, the user who triggers the workflow will eventually be the owner of the document. I want to change the owner of the document to an admin, irrespective of who sent the document. How can I achieve this?

When a document is sent for signing using a workflow/Automation, the owner of the document is one who triggered it. So this code will help you to change ownership of document once it is sent out.
  1. You can view the set up function by clicking here.
  2. For OAuth Connection Setup, navigate to Setup -> Developer Space -> Connections -> Add a new Connection. Select Zoho OAuth, then name the connection.

    In the available scopes, select the four Zoho Sign scopes (Zoho Sign.account.ALL, Zoho Sign.documents.ALL, Zoho Sign.setup.READ, Zoho Sign.templates.ALL) and create the connection.

  3. Paste the following code in the function:
  1. requestMap = invokeurl
  2.   [
  3. url: "https://sign.zoho.com/api/v1/requests/"+requestId
  4. type: GET
  5. connection: "<Use Connection Name Here>"
  6.   ];

  7. if(requestMap.containKey("requests"))
  8. {
  9.   requestStr = requestMap.get("requests");
  10.  
  11.   requestObj = requestStr.toMap();
  12.   adminemail = "admin@example.com";//use admin email here
  13.   data = Map();
  14.   data.put("email_id",adminemail);
  15.   // Change Ownership api call
  16.   resp = invokeurl
  17.       [
  18. url: "https://sign.zoho.com/api/v1/requests/"+requestId+"/changeownership"
  19. type: PUT
  20. parameters: data
  21. connection: "<Use Connection Name Here>"
  22.       ];
  23. }