首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在自定义函数中使用Zoho Deluge脚本解决问题

在自定义函数中使用Zoho Deluge脚本解决问题
EN

Stack Overflow用户
提问于 2021-07-26 14:00:40
回答 1查看 75关注 0票数 0

对于1200+帐户,我需要如下输出:

代码语言:javascript
复制
accounts_count = {
    "a": 120,
    "b": 45,
    "z": 220
}

因此,它将获取帐户名的第一个字母,并将所有帐户的首字母计算在内。

如何在自定义函数中使用Zoho Deluge脚本来解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2021-08-12 02:56:01

最困难的部分是获取所有的联系人,因为zoho中的200个记录限制

我不打算在这里提供完整的解决方案,只提供较难的部分。

代码语言:javascript
复制
// 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;
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68525123

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档