Try the following modification of your code. You need to have a text selection for it to work. It does not check anything on what text you have selected, it just appends that text to the base URL you have and creates a hyperlink. I tested it with a part no 11886-02500320 and it worked.
var obj = app.selection[0];
var part = obj.contents;
var ItemText = obj.texts[0];
var url = "https://www.nextind.com/itemdetail/" + part;
addHyperURL(app.documents[0], ItemText, url, url, url, url);
function addHyperURL(myDoc, pageItemSource, url, hyperName, destiName, sourceName) {
var source = myDoc.hyperlinkTextSources.add(pageItemSource);
if (sourceName == undefined) { var sourceName = "sourceName"; }
if (destiName == undefined) { var destiName = "destiName"; }
var destination = myDoc.hyperlinkURLDestinations.add();
with (destination) {
try { name = destiName; } catch (e) { destiName = destiName + "_" + objID; name = destiName; }
destinationURL = url;
}
if (hyperName == undefined) { var hyperName = "HyperLink" + sourceName + "_" + destiName; }
try { var hyperLink = myDoc.hyperlinks.add(source, destination, { visible: false }); } catch (e) { return; }
try {
hyperLink.name = hyperName;
} catch (e) {
hyperLink.name = hyperName + "_" + hyperLink;
}
//{highlight: hyperArr[2],width: hyperArr[3], borderStyle: hyperArr[4], borderColor: hyperArr[5]});
return hyperLink;
}
-Manan