Adding two additional Roll-Up Potential Amounts to the example online.

Adding two additional Roll-Up Potential Amounts to the example online.

The example is located online here:

https://www.zoho.com/crm/help/automation/custom-functions-programming.html

And it works great!

However, I have been asked to see if I can also add the following functions for Potentials to Account fields.

We would also, like to see:

Monthly Revenue and Annual Revenue

Does any one know what the script might look like to make this happen?

The current script looks like this:

accountID1 = (input.AccountId).toString();
resp = zoho.crm.searchRecordsByPDC("Potentials", ("accountid"), accountID1);
info resp;
total = 0.0;
for each rec in resp
{
stage = (rec.get("Stage")).toLowerCase();
if (stage.contains("won"))
{
total = (total + (rec.get("Amount")).toDecimal());
}
}
updateResp = zoho.crm.updateRecord(("Accounts"), accountID1, { input.SumUpField : total });

Anyone know how you might have the function tally up the last 30 days of potentials for the Account and the a rolling Annual Revenue Total for the Account? 

Thanks, Thomas Pursifull