How to get the value from search.lookupFields when...
# ask-stanley-ai
s
How to get the value from search.lookupFields when using a join in the columns
c
AI generated answer (using internal Slack threads):
To get the value from
search.lookupFields
when using a join in the columns, you need to use the full string including the dot as the key. For example, if you have a joined column like 'shippingAddress.internalid', you should use it as the key in the
fieldLookUp
object. Here is an example:
Copy code
javascript
var fieldLookUp = search.lookupFields({
    type: search.Type.SALES_ORDER,
    id: transactionID,
    columns: ['location', 'shippingAddress.internalid']
});

// This works for location
console.log(fieldLookUp.location[0].value);

// This works for shippingAddress.internalid
const shippingId = fieldLookUp['shippingAddress.internalid'][0].value;
console.log(shippingId);
In this case,
fieldLookUp['shippingAddress.internalid'][0].value
is used instead of
fieldLookUp.shippingAddress.internalid[0].value
. The key is the full string 'shippingAddress.internalid', not 'internalid' inside an object called 'shippingAddress'. When you have strings that include a period, you should reference them with square brackets instead of dot notation. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.858764648
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.843383908
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.835144043
Please provide your feedback on this answer.