Recently, I had to fetch some URLs and file names stored in a custom record related to another record. The challenge was to handle the commas inserted using the NSCONCAT function.
My solution was to use the string.replace() function to replace commas in the file names with ‘%2C’ and URLs before concatenating the search result and then replacing it after splitting the result with a comma on traversal.
I am attaching the saved search used:
installation_jobSearchObj = search.create({
type: "customrecord_installation_job",
filters:
[
["isinactive","is","F"],
"AND",
["internalid","anyof","21356"]
],
columns:
[
search.createColumn({
name: "internalid",
summary: "GROUP",
label: "Internal ID"
}),
search.createColumn({
name: "altname",
summary: "MAX",
label: "Name"
}),
search.createColumn({
name: "formulatext",
summary: "MAX",
formula: "NS_CONCAT(REPLACE({CUSTRECORD_INST_ATTACHMENT_PARENT_JOB.custrecord_inst_attachmnt_path},',','%2C'))",
label: "Formula (Text)"
}),
search.createColumn({
name: "formulatext",
summary: "MAX",
formula: "NS_CONCAT(REPLACE({CUSTRECORD_INST_ATTACHMENT_PARENT_JOB.name},',','%2C'))",
label: "Formula (Text)"
})
]
});
To avoid splitting the filenames or URLs if they have commas, I first used string.split() function with commas while traversing the result and only replaced the ‘%2C’ back to commas for each item after the split function