I've got a custom record with the Hierarchy checkm...
# suitescript
m
I've got a custom record with the Hierarchy checkmark on. I'm using
search.lookupFields
to get the name of the record, only, I want it without the hierarchy.
name
gets me the name with all the parents. There doesn't seem to be a
namenohierarchy
. Am I missing something here? 🤔
a
idk if there's sane way to do that, cant remember but you can always just hack with some JS string methods
Copy code
const nameStr = searchlookupFields({
   type,
   id,
   etc...
});
const name1 = nameStr.split(': ')[1];
image.png
e
If you don't know how many segments there might be, then something like
Copy code
const lastSegment = (name) => {
  const names = name.split(':')
  return names[names.length - 1].trim()
}
👍 1
And no, I don't believe you're missing anything.
namenohierarchy
is never there when you need it 😄
m
Solution found: using the query module instead. By doing that, I can get the plain name of the record, making the script foolproof.