Need to mass update thousands of Lead records in Zoho CRM and can't be bothered manually clicking through tens of pages and doing mass update? Here's an example of using a custom function to achieve this. In this case, I needed to merge several notes fields into one text area field as the multiple note fields were becoming unwieldy.
NB: this blog post is no longer relevant as API v2 lets you use searchRecords with multiple criteria :) I discovered something really cool tucked away in the Zoho CRM forums today. For the history, check out this thread . In summary, the searchRecords API task in Zoho CRM is impossible to use if you have multiple criteria and in general it's pretty annoying to get the single criterion right. In the forum thread, Zoho Support advised that you can actually use getRecords with a view name. This feature is not documented on the getRecords page at all but I can confirm it works:D This is really, really cool. It's going to make my life as a Zoho dev much easier! Instead of having to do something really inefficient and ugly like: leadRecords = zoho.crm.searchRecords("Leads","(Created Time|<|" + yesterday_date +")",fromIndex,toIndex); for each ele in leadRecords { lead_source = ele.get("Lead Source"); createTime=(ele.g
Hey Jeremy
ReplyDeleteI use a recursion function for getting a lot of records. I don't have to use an iterator, the function itself will determine if it has to take another round. Maybe it helps you or someone else.
list space.getRecords(string customViewName, int start)
{
blocksize = 200;
end = (input.start + blocksize - 1);
allRecords = List();
foundRecords = zoho.crm.getRecords(input.customViewName, input.start, end);
if (foundRecords.size() > 0)
{
allRecords.addall(foundRecords);
if (foundRecords.size() == blocksize)
{
followingRecords = thisapp.space.getRecords(input.customViewName, (end + 1));
allRecords.addall(followingRecords);
}
}
return allRecords;
}
Although this example uses a custom view one could also use searchRecords() with a search criteria.
You call it with completeList = thisapp.space.getRecords(, 1).
Best,
Sascha
Nice one Sascha. Recursion is another interesting way to solve this.
ReplyDelete