I’m using an Execute Script action in a loop and the loop is working fine, but it appears that its only executing the script on the first iteration. I’ve tested the script with the second group of data on the scripts page and it works fine.
I put a dlg.ShowMessage(url) in the script and it shows on the first run and doesn’t on the second. Additionally none of the values update on the second pass. Any reason for this? Is there a setting I should change like run in the background?
This is showing:
- Show Dialogue from the Script
- Test message with correct first loop and Data.Get data
- Test message with correct loop value and old Data.Get data.
function Check(s) {
// Get Message ID and Tasc ID
var task = s.split("^");
var smsid = task[0];
var tscid = task[1];
// Configure API Call
var lib = host.lib("System");
var client = new lib.System.Net.WebClient();
var url = "https://rest.clicksend.com/v3/sms/receipts/" + smsid;
client.Headers.Add("Authorization", "Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
dlg.ShowMessage(url);
//Run Data Check
var data;
var hostException;
var valid = host.tryCatch
(
function() {
data = client.DownloadString(url);
},
function(exception) {
hostException = exception;
return true;
}
);
//Form Response
if (valid) {
// API Call was successful
Data.Set('WLS_ID',tscid);
Data.Set('WLS_Status','SMS Delivered');
Data.Set('WLS_Indicator','');
return "success";
} else {
// API Call returned an error
Data.Set('WLS_ID',tscid);
Data.Set('WLS_Status','SMS Error');
Data.Set('WLS_Indicator','');
return "error";
}
}
1st dialogue
2nd
3rd - The characters after ^ should match the second to last string.
I also imagine there should have been a second dialogue box with the url if it ran a second time.
I’m not sure if matters but I disabled all the other calls and did a simple execute script command in the loop just pass the value and showing it in a dialog along with returning the passed value.
On the second value in the dialogue I see:
Although the returned value does not have the <!rn>.
<!rn> was the issue. I was missing a colon in the report call. All good now.
1 Like