Download Statement from Zoho Books and upload to Zoho CRM
Hi everybody! I don't know who needs to know this, but if you do, then here it is.
This code:
- Searches for Contact in Books based on the Account ID in CRM
- Download the statement of account of the Contact in Books
- Upload as an attachment in Account record in CRM
By default, if you do not specify "start_date" and "end_date", it will download the current year's statement. Also, "accId" is mapped to "Account ID" in Zoho CRM. This function is for the Accounts module in CRM.
- //search for account in books
- orgId = {enter your Zoho Books Organization ID here as a string. e.g: "78634343"};
- booksCust = invokeurl
- [
- url :"https://www.zohoapis.com/books/v3/contacts?organization_id=" + orgId + "&zcrm_account_id=" + accId.toString()
- type :GET
- connection:"{your zoho books connection name, I'd choose full scope}"
- ];
- // check if there's a contact in Zoho Books with the Zoho CRM account ID
- if ( booksCust.get("code") == 0 && booksCust.get("contacts").size() > 0 )
- {
- contactId = booksCust.get("contacts").get(0).get("contact_id");
- //get statement
- getStatement = invokeurl
- [
- url:"https://www.zohoapis.com/books/v3/contacts/" + contactId + "/statements?organization_id=" + orgId
- type: GET
- connection: {your zoho books connection name, I'd choose full scope}"
- ];
- info getStatement;
- if ( getStatement != null )
- {
- getStatement.setParamName("file");
- //upload to crm
- uploadStatement = invokeurl
- [
- url: "https://www.zohoapis.com/crm/v6/Accounts/" + accId.toString() + "/Attachments"
- type: POST
- files: getStatement
- connection: "{your zoho crm connection name}"
- ];
- info uploadStatement;
- }
- }
Good luck!
Nik, aplikasi.us
Zoho Premium Partner