技巧14:如何迭代一组Deluge代码特定次数。

技巧14:如何迭代一组Deluge代码特定次数。

原文链接:https://help.zoho.com/portal/en/community/topic/tip-14-how-to-iterate-a-set-of-deluge-code-a-specific-number-of-times



大家好,


您可能已经知道,递归函数用于  执行特定操作特定次数。我们已经在技巧2中对此进行了详细说明同样,还有另一种方法可以迭代一组Deluge代码“ n”次。您需要做的就是创建一个列表,并使用“对于每个索引”任务对其进行特定次数的迭代。 

 

以下是一些对您有用的用例: 

  • 为每个新创建的记录创建“ n”个重复记录。

  • 要执行发送邮件任务“ n”次。

  • 批量更新旧记录。

在下面提供的示例脚本中,我们正在自定义函数上实现逻辑,并且Zoho Creator应用程序中的任何工作流程都可以触发此函数。


让我们考虑为上述函数提供的输入“数字”(整数)为10。结果,该函数将返回以下列表。

[1、2、3、4、5、6、7、8、9、10] 

 

  1. list listintgenerator(int number)
  2. {
  3. //We'll need to create a reference List for indexing purpose
  4. indx = number - 1;
  5. str1 = " ";
  6. val = leftpad(str1,indx);
  7. lst_val = val.replaceAll(" ","0,").toList();
  8. lst_temp = List:Int();
  9. counter = 1;
  10. //Iterate each index of the above generated List and perform counter operation
  11. for each index x in lst_val
  12. {
  13. lst_temp.add(counter);
  14. counter = counter + 1;
  15. }
  16. return lst_temp;
  17. }
  18.  

现在,可以使用For每个任务来迭代生成的List,并且在该循环内,您可以添加必须执行10次的Deluge代码集。

 

希望本文对您中的许多人有用。请继续关注此空间,以获取更多此类提示。