Marvin
10/25/2024, 9:10 AMAnthony OConnor
10/25/2024, 2:15 PM<isordered>T</isordered>
, which I do for all my lists so that works for me 🙂Anthony OConnor
10/25/2024, 2:16 PMAnthony OConnor
10/25/2024, 2:20 PMif(varName === lib.ORDER_TYPE.NEW){...}
instead of
if(varName === 1){...}
which is way more readable and doesn't require someone to double check what 1 refers to all the time.Marvin
10/25/2024, 5:11 PM<isordered>
that is helpful to know about.
How I am doing the mapping is by just searching the list like this.
const results = _cache_getListMapping.get({
key: cache_key
, loader: () => {
const results = [];
search.create({
type: list_id
, columns: ["internalid", "scriptid", "name"]
, filters: [{name: "isinactive", operator: <http://search.Operator.IS|search.Operator.IS>, values: "F"}]
}).run().each((result) => {
results.push({
id: result.getValue("internalid")
, scriptid: result.getValue("scriptid")
, name: result.getValue("name")
});
return true;
});
return JSON.stringify(results);
}
, ttl: 30 * 60 // 30 mins
});
// cached values will be returned as a JSON string so we stringify all results and parse them before returning
return JSON.parse(results);
And then I can convert back and forth from scriptid to internalid.
If I want to get the scriptid from internalid.
_.find(listmapping, (s) => s.id == variable_w_internalid)?.scriptid;
If I want to get the internalid from the scriptid.
_.find(listmapping, (s) => s.scriptid === "VAL_*")?.id;
Anthony OConnor
10/25/2024, 5:12 PMMarvin
10/25/2024, 5:17 PM