Totals function

Totals function

Hey,

 

I am trying to write a custom function to calculate Quote totals to include at the Deal level. Here is the function:

 

https://www.zoho.com/crm/resources/tips/functions-grand-total.html

 

RelatedQuotes = zoho.crm.getRelatedRecords("Quotes", "Deals", potId.toLong(),1,200); //info RelatedQuotes;

total = 0.0;

for each ele in RelatedQuotes

{

grand =ifnull(ele.get("Grand_Total"),"0.0").toDecimal();

total = (total + grand);

}

mp = map();

mp.put("Amount", total);

update = zoho.crm.update("Deals", potId.toLong(), mp);

info mp;

info update;

 

I select related module as “Deal”

 

I enter above script and edit argument as specified, dealId = Deal Id

 

I execute and prompted:

 

"Please enter the input values to the arguments

int potId = _______________________"

 

If I enter “Deal Id” I return error: Failed to execute function - Error at line number: 1
Value given for the variable 'potId' does not match its type

 

I am assuming that is because potId should be dealId? I enter script as:

 

RelatedQuotes = zoho.crm.getRelatedRecords("Quotes", "Deals", dealId.toLong(),1,200); //info RelatedQuotes;

total = 0.0;

for each ele in RelatedQuotes

{

grand =ifnull(ele.get("Grand_Total"),"0.0").toDecimal();

total = (total + grand);

}

mp = map();

mp.put("Amount", total);

update = zoho.crm.update("Deals", dealId.toLong(), mp);

info mp;

info update;

 

I edit arguments, dealId = Deal Id

 

I execute script and prompt:

 

"Please enter the input values to the arguments

int dealId = _______________________"

 

If I ender “Deal Id” I return error: Failed to execute function - Error at line number: 1
Value given for the variable 'dealId' does not match its type

 

 

 

 

 

Any Ideas??