Is it possible to pull the contacts associated wit...
# ask-stanley-ai
r
Is it possible to pull the contacts associated with a given transaction? If so, whats the SQL statement?
c
AI generated answer (using internal Slack threads):
Yes, it is possible to pull the contacts associated with a given transaction. You can achieve this by creating a Contact search and using the Transaction join. Here is a sample SuiteScript 1.0 code that demonstrates this:
Copy code
javascript
var contactSearch = nlapiSearchRecord("contact",null,
[
   ["transaction.internalidnumber","equalto","8337"]
],
[
   new nlobjSearchColumn("entityid").setSort(false),
   new nlobjSearchColumn("email"),
   new nlobjSearchColumn("phone"),
   new nlobjSearchColumn("altphone"),
   new nlobjSearchColumn("fax"),
   new nlobjSearchColumn("company"),
   new nlobjSearchColumn("altemail"),
   new nlobjSearchColumn("internalid","transaction",null),
   new nlobjSearchColumn("tranid","transaction",null),
   new nlobjSearchColumn("recordtype","transaction",null),
   new nlobjSearchColumn("type","transaction",null)
]
);
In this code, we are searching for contacts where the transaction internal id number is equal to 8337. The search returns various contact details such as entity id, email, phone, alt phone, fax, company, alt email, and transaction details like internal id, tran id, record type, and type. However, please note that you might not be able to get the actual role besides the primary one. Also, the "contactrole" field on a transaction search might return empty. ****** 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.828869641
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.8121171
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811839461
Please provide your feedback on this answer.