Best answer

Code Steps Ran thousands of Times

  • 10 July 2020
  • 2 replies
  • 773 views

Hello,

I have 9 Code steps all with the same structure as below, but with different input data and variables being used. I am triggering this zap with a webhook from TallyFy. When I triggered this zap yesterday, it proceeded to run the entire zap 6,400 times. I am thinking it may be due to not having a Callback in the last Code step. The Code step presented below is the first of nine that are identical other than inputs and variables, in order to pull out only the human readable values I need in order to store them into a document for client digestion. Can anyone give me some idea as to why the zap ran 6,400 times and how to implement the Callback in the structure below, if that is indeed the problem? HUGE THANKS.

 

 

inputData:

addrSvcs:

id: 1 required: True selected: True text: Return Service Requested value: None id: 2 selected: True text: Address Service Requested value: None id: 3 selected: True text: NCOA value: None

 

JavaScript Code:

var addrSvc = inputData.addrSvcs.match(/text:\s(NCOA|Return Service Requested|Address Service Requested|None)/gi);
return addrSvc.map(function(svc) {
  if (addrSvc) {
    var originalTxt = addrSvc.join(',');
    var newText = originalTxt.replace(/text:\s/gi,'')
    return {addrServices: newText};
  }});

 

Output from Testing:

addrServices

Return Service Requested,Address Service Requested,NCOA

id: 8QscrpVth1aKNE9NKXqYC4r1nZktOUqO

runtime_meta

memory_used_mb: 72

duration_ms: 100

logs:

async: false

icon

Best answer by kpiercy 16 July 2020, 17:17

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

@steph.n 

Thank you for the reply, but I did end up finding the solution. Was a misunderstanding on my part as I am new to Javascript. I came up with this late last week, but didn’t think it would work because it was only removing the “text:” descriptor from the first iteration of the object, but I realized I could use RegEx /g to make it global. Solution below:

 

var addrSvc = inputData.addrSvcs.match(/text:\s(NCOA|Return Service Requested|Address Service Requested|None)/gi);
var originalText = addrSvc.join(', ');  
var newText = originalText.replace(/text:\s/g, '');
   return {addrServices: newText}; 

Userlevel 7
Badge +8

Hi there @kpiercy - I went ahead and submitted a ticket on your behalf to the Support team. Please let us know if you have any further questions and be sure to share the answer you received here.

Thanks so much!