对于1200+帐户,我需要如下输出:
accounts_count = {
"a": 120,
"b": 45,
"z": 220
}因此,它将获取帐户名的第一个字母,并将所有帐户的首字母计算在内。
如何在自定义函数中使用Zoho Deluge脚本来解决这个问题?
发布于 2021-08-12 02:56:01
最困难的部分是获取所有的联系人,因为zoho中的200个记录限制
我不打算在这里提供完整的解决方案,只提供较难的部分。
// this is the maximum number of records that you can query at once
max = 200;
// set to a value slightly higher than you need
max_contacts = 1500;
// round up one
n = max_contacts / max + 1;
// This is how many times you will loop (convert to int)
iterations = n.toNumber();
// this is a zoho hack to create a range of the length we want
counter = leftpad("1",iterations).replaceAll(" ","1,").toList();
// set paging
page = 1;
// TODO: initialize an alphabet map
//result = Map( {a: 0, b:0....});
// set to true when done so you're not wasting API Calls
done = false;
for each i in counter
{
// prevent extra crm calls
if(!done)
{
response = zoho.crm.getRecords("Contacts",page,max);
if(!isEmpty(response))
{
if(isNull(response.get(0)) && !isNull(response.get("code")))
{
info "Error:";
info response;
}
else
{
for each user in response
{
// this is the easy part: get the first letter (lowercase)
// get the current value and add one
// set the value again
// set in result map
}
}
}
else
{
done = true;
}
}
// increment the page
page = page + 1;
}https://stackoverflow.com/questions/68525123
复制相似问题