I just can't get the syntax correct on this and could do with some help. I've looked through all the posts and dcumentation I can find, however a lot of it is contradictory.
I am wanting to essentially duplicate this Analytics agregate formula in a CRM function:
- count_if(("Opportunities"."Stage" = 'Committed, not Signed') OR ("Opportunities"."Stage" = 'In Quotation (Awaiting Proposal)') OR ("Opportunities"."Stage" = 'In Quotation (Awaiting Response)') OR ("Opportunities"."Stage" = 'In Quotation (Clarify Requirements)'))
I have set up a connection in the CRM for OAuth in Developer Space > Connections
This function works as I would expect :
- payload = {"select_query":"SELECT Total_Amount FROM Deals WHERE ((Stage = 'Committed, not Signed') or (Stage = 'In Quotation (Awaiting Proposal)')) or ((Stage = 'In Quotation (Awaiting Response)') or (Stage = 'In Quotation (Clarify Requirements)'))"};
- response = invokeurl
- [
- url :"https://www.zohoapis.eu/crm/v2/coql"
- type :POST
- parameters:payload.toString()
- connection:"zohocrmcoql"
- ];
- info response;
- return response;
However I can't seem to count the records no matter how I format. I'm also looking to sum a field called Total_Amount as well...
Even trying a simpler query doesn't seem to work :
- payload = {"select_query":"select SUM(Total_Amount), Stage from Deals where Stage = 'Committed, not Signed' group by Stage"};
- response = invokeurl
- [
- url :"https://www.zohoapis.eu/crm/v2/coql"
- type :POST
- parameters:payload.toString()
- connection:"zohocrmcoql"
- ];
- info response;
- return response;