result.getText({ name: ‘subsidiary’ }).split(‘:’).pop().trim() || “”
result.getText({ name: 'subsidiary' })
- Retrieves the text representation of the
subsidiaryfield from the search result. - In NetSuite,
getTextis used to fetch the displayed text instead of the internal ID.
.split(':')
- Splits the retrieved text by the colon (
:) separator. - Some NetSuite fields (like subsidiary) can return values in the format:
"Parent Subsidiary : Child Subsidiary"
- So, after splitting, this creates an array like:
["Parent Subsidiary", "Child Subsidiary"]
.pop()
- Retrieves the last element from the split array.
- This ensures that if the subsidiary name has a parent-child hierarchy, it only extracts the last part (child subsidiary name in this case).
.trim()
- Removes any leading or trailing spaces from the extracted text.
|| ""
- If the result is
null,undefined, or an empty string, it defaults to an empty string (""), ensuring there’s no error when handling missing values.