Zoho Deluge-如何比较洪水中的列表条目

发布于 2025-02-04 13:47:18 字数 1396 浏览 3 评论 0 原文

我目前有两个列表,一个来自外部API(SPLYNX),该列表返回所有客户列表,另一个列表返回Zoho CRM中的Contacts Module的所有帐户名称的列表,目前,我只想编写一个代码,该代码确认两个列表是否包含匹配条目(例如,Splynx列表中的一个条目与CRM列表中的另一个条目匹配)。 我实际上要实现的目标是每个匹配条目,我想通过SPLYNX的客户ID字段更新CRM记录,并在CRM中的帐户模块中使用一个自定义字段称为Splynx ID(因为此ID是自动生成的,以维护以维护两个应用程序之间的一致性)。我想知道这是否可以实现。

是我到目前为止写的代码

headersmap = Map();
headersmap.put("Authorization","Basic xxxxxxx);
response = invokeurl
[
    url :"https://selfcare.dotmac.ng/api/2.0/admin/customers/customer?"
    type :GET
    headers:headersmap
];
AccountlistSplynx = List();
li1 = List();
li2 = List();
li3 = List();
rows = response.toJSONList();
rows1 = response.toJSONList();
rows2 = response.toJSONList();
for each  row in rows
{
    Name = row.getjson("name");
    AccountlistSplynx.add(Name);
}
for each  row in rows1
{
    Address = row.getjson("street_1");
    li1.add(Address);
}
for each  row in rows2
{
    CustomerID = row.getjson("id");
    li2.add(CustomerID);
}

Accountlistzoho = List();
mp = Map();
contacts = zoho.crm.getRecords("Contacts");
for each  contact in contacts
{
    account = ifnull(contact.getJSON("Account_Name"),Map());
    if(account.size() > 0)
    {
        accountname = account.getJSON("name");
        Accountlistzoho.add(accountname);
    }
}

if ( Accountlistzoho == AccountlistSplynx ) 
{
    info "Matching records!";

}
else 
{
    info "No matching records!";
}

这 帐户

I currently have two lists, one is from an external api (splynx), which returns a list of all customers, and another list which returns a list of all Account names from the contacts module in Zoho crm, at the moment, I just want write a code that confirms if the two lists contain matching entries (like one entry in the splynx list matches another entry in the crm list).
What I actually want to achieve is for each matching entry, I want to update crm records with the Customer ID field from Splynx, with a custom field called Splynx ID in the accounts module in CRM (because this ID is auto generated so as to maintain consistency across both apps). I want to know if this even achievable.

This is the code I have written so far

headersmap = Map();
headersmap.put("Authorization","Basic xxxxxxx);
response = invokeurl
[
    url :"https://selfcare.dotmac.ng/api/2.0/admin/customers/customer?"
    type :GET
    headers:headersmap
];
AccountlistSplynx = List();
li1 = List();
li2 = List();
li3 = List();
rows = response.toJSONList();
rows1 = response.toJSONList();
rows2 = response.toJSONList();
for each  row in rows
{
    Name = row.getjson("name");
    AccountlistSplynx.add(Name);
}
for each  row in rows1
{
    Address = row.getjson("street_1");
    li1.add(Address);
}
for each  row in rows2
{
    CustomerID = row.getjson("id");
    li2.add(CustomerID);
}

Accountlistzoho = List();
mp = Map();
contacts = zoho.crm.getRecords("Contacts");
for each  contact in contacts
{
    account = ifnull(contact.getJSON("Account_Name"),Map());
    if(account.size() > 0)
    {
        accountname = account.getJSON("name");
        Accountlistzoho.add(accountname);
    }
}

if ( Accountlistzoho == AccountlistSplynx ) 
{
    info "Matching records!";

}
else 
{
    info "No matching records!";
}

I also want to know if this is the best route to follow in trying to achieve this because I had already imported these contacts from Splynx to CRM before I realized that I did not create the custom field for Accounts

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼泪也成诗 2025-02-11 13:47:18

查看Intersect列表功能:

<variable> = <listVariableOne>.intersect( <listVariableTwo> );

Note!

<listVariableOne>.intersect( <listVariableTwo> );

应该

<listVariableTwo>.intersect( <listVariableOne> );

返回相同的相交集,但有时其中一个呼叫返回较小的集合。要围绕此操作,请调用Intersect()两种方式,如果它们不同,请使用提供预期集的一种。


对于此任务,将使用类似的东西

headersmap = Map();
headersmap.put("Authorization","Basic xxxxxxx);
response = invokeurl
[
    url:"https://selfcare.dotmac.ng/api/2.0/admin/customers/customer?"
    type :GET
    headers:headersmap
];

// Note: Using a Map to associate Splynx names and ids.
SplynxMap = Map();
rows = response.toJSONList();
for each row in rows
{
  SplynxMap.put(row.getjson("name"), row.getjson("id");
}

// Here make a list of Splynx names based on the map keys.
AccountlistSplynx = List();
AccountlistSplynx = SplynxMap.keys();

// Intersect() function
ItemsToProcess = Accountlistzoho.intersect(AccountlistSplynx);


// Get Zoho record and update with Splynx Customer ID
// Here is one way to do this, but probably not the best or 
// most efficient.  There is should be a way in CRM to request
// a specific record based on the "name" field and avoid
// looping through contacts for each item to process.
for each item in itemsToProcess
{
  for each contact in contacts
  {
    account = ifnull(contact.getJSON("Account_Name"),Map());
    if(account.size() > 0)
    {
        if ( item ==  account.getJSON("name"))
        {
          account.Splynx_ID = SplynxMap.get(item);
        }
    }
  }
}

Take a look at the intersect list function:

<variable> = <listVariableOne>.intersect( <listVariableTwo> );

Note!:

<listVariableOne>.intersect( <listVariableTwo> );

and

<listVariableTwo>.intersect( <listVariableOne> );

should return the same intersection set but sometimes one of these calls returns a smaller set. To work around this, call intersect() both ways and if they differ use the one that gives the expected set.


For this task intersect() would be used something like this:

headersmap = Map();
headersmap.put("Authorization","Basic xxxxxxx);
response = invokeurl
[
    url:"https://selfcare.dotmac.ng/api/2.0/admin/customers/customer?"
    type :GET
    headers:headersmap
];

// Note: Using a Map to associate Splynx names and ids.
SplynxMap = Map();
rows = response.toJSONList();
for each row in rows
{
  SplynxMap.put(row.getjson("name"), row.getjson("id");
}

// Here make a list of Splynx names based on the map keys.
AccountlistSplynx = List();
AccountlistSplynx = SplynxMap.keys();

// Intersect() function
ItemsToProcess = Accountlistzoho.intersect(AccountlistSplynx);


// Get Zoho record and update with Splynx Customer ID
// Here is one way to do this, but probably not the best or 
// most efficient.  There is should be a way in CRM to request
// a specific record based on the "name" field and avoid
// looping through contacts for each item to process.
for each item in itemsToProcess
{
  for each contact in contacts
  {
    account = ifnull(contact.getJSON("Account_Name"),Map());
    if(account.size() > 0)
    {
        if ( item ==  account.getJSON("name"))
        {
          account.Splynx_ID = SplynxMap.get(item);
        }
    }
  }
}
愿得七秒忆 2025-02-11 13:47:18

关于您的需求,如果在Splynx记录中匹配Zoho CRM记录,是否要更新Zoho CRM记录?

步骤1:
将所有SPLYNX记录存储到销量中的列表数据类型变量中。
将所有ZOHO记录存储到列表数据类型变量中。

步骤2:
假设这两个列表的API字段名称都不均等匹配。

步骤3:
如果我们假设该帐户名称是匹配的标准,那么这就是确定Zoho记录中匹配的记录的方法。请注意,API_FIELD_NAME或键与您的实际数据不同。

SplynxData = {{"s_account_name":"Account A","ID":"s_ID_1"},{"s_account_name":"Account B","ID":"s_ID_2"},{"s_account_name":"Account C","ID":"s_ID_3"},{"s_account_name":"Account D","ID":"s_ID_4"}};
ZohoData = {{"z_account_name":"Account A","ID":"z_ID_1"},{"z_account_name":"Account B"},{"z_account_name":"Account C"}};

ZohoData_group_Name = Map();
for each ZohoData_item in ZohoData{
    item_map = Map();
    ZohoData_group_Name.put(ZohoData_item.get('z_account_name'),ZohoData_item);
}
for each SplynxData_item in SplynxData{
    matched_zoho_item =  ZohoData_group_Name.get(SplynxData_item.get('s_account_name')) ;
    if (matched_zoho_item != null){
        info matched_zoho_item;
        //Do zoho.crm.updateRecords methods
        
    }
}

您可以在 https://deluge.zoho.com/tryout 中尝试此洪水脚本。
请参阅此链接有关如何更新Zoho Records

Regarding your needs, do you want to update Zoho CRM records if they are matched in Splynx records?

Step 1:
Store all Splynx records into the List data type variable in the deluge.
Store all Zoho records into the List data type variable in the deluge.

Step 2:
Assume that API field Names of both Lists are not equally matched.

Step 3:
This is how to determine matched records in Zoho records if we assume that Account Name is the criteria to be said it is matched. Please note that api_field_name or keys will be different from your actual data.

SplynxData = {{"s_account_name":"Account A","ID":"s_ID_1"},{"s_account_name":"Account B","ID":"s_ID_2"},{"s_account_name":"Account C","ID":"s_ID_3"},{"s_account_name":"Account D","ID":"s_ID_4"}};
ZohoData = {{"z_account_name":"Account A","ID":"z_ID_1"},{"z_account_name":"Account B"},{"z_account_name":"Account C"}};

ZohoData_group_Name = Map();
for each ZohoData_item in ZohoData{
    item_map = Map();
    ZohoData_group_Name.put(ZohoData_item.get('z_account_name'),ZohoData_item);
}
for each SplynxData_item in SplynxData{
    matched_zoho_item =  ZohoData_group_Name.get(SplynxData_item.get('s_account_name')) ;
    if (matched_zoho_item != null){
        info matched_zoho_item;
        //Do zoho.crm.updateRecords methods
        
    }
}

You can try this deluge script in https://deluge.zoho.com/tryout.
Please refer to this link on how to update Zoho Records https://www.zoho.com/deluge/help/crm/update-record.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文