InDesign Script Error
Im trying to run a script which changes all of the hyperlinks in an Indesign file to include UTM tracking codes however Im getting an error on line 3 - wondering if anyone can help??
The code adds UTM tracking but also uses an if/then to check if there are more than one & in the code. If there is more than one it adds a slightly different bit of text to the hyperlink.
When I run this in InDesign I get an error I have shown attached as a screenshot.
Here is my code and error message - I believe the error is on the line shown in red?
var utm = "utm_source=publications&utm_medium=sale-finder&utm_campaign=12-days-of-xmas";
var hlds = app.activeDocument.hyperlinkURLDestinations;
var utmsearch = "&" + utm;
var utmdefault = "?" + utm;
for (var i = 0; i < hlds.length; i++) {
var result = hlds.item(i).destinationURL.includes("?");
if (result) {
hlds.item(i).destinationURL += utmsearch;
} else {
hlds.item(i).destinationURL += utmdefault;
}
}

