Get the location prefix using search

let locationSearchObj = search.create({
type: “location”,
filters:[[“internalId”, “is”, location],
columns:[
search.createColumn({name: “formulatext”,
formula: “CASE WHEN {tranprefix} IS NOT NULL THEN {tranprefix} ELSE {namenohierarchy} END”,
label: “Location”})
]});
let searchResultCount = locationSearchObj.runPaged().count;
if (searchResultCount <= 0) return false;
let locationDetails = [];
locationSearchObj.run().each(function (result) {
let locationObj = {};
locationObj.prefix = result.getValue({name: “formulatext”,
formula:”CASE WHEN {tranprefix} IS NOT NULL THEN {tranprefix} ELSE {namenohierarchy} END”,
label: “Location”,});
locationDetails.push(locationObj);
return true;
});

Leave a comment

Your email address will not be published. Required fields are marked *