Look up Salesforce name using contact id

Originally asked by Dave Chandler on 06 September 2023 (original question)


Hiya - so when we grab the Case.ContactId it returns the Contact ID key (eg. 003Aq000007PctQIAS) - not the name. Are we able to use this key to lookup the contacts name in the salesforce object ContactCleanInfo.name using ContactCleanInfo.ContactId = “003Aq000007PctQIAS” and then send this back to Jira in the Salesforce Outgoing script?


Answer by Stéphane Thillay on 06 September 2023

Hi Dave,

In the outgoing Salesforce to Jira script, we’re using:

def queryUser = httpClient.get("/services/data/v54.0/query/?q=SELECT+Name+FROM+User+WHERE+Id=%27${entity.OwnerId}%27")

This instruction does a query through the Salesforce API to get detail of a record (User object) based on an Id (here the OwnerId of the Case being synchronized with Jira).

From that example you may adapt to get details of the Contact.

Regards,

Stéphane


Answer by Dave Chandler on 06 September 2023

Yep great - thats actually what we did:

String player_id = entity.ContactId
String playerName = "Player Not Found"

try {
playerName = httpClient.get("/services/data/v54.0/query/?q=SELECT+Name+from+Contact+where+id=%27${player_id}%27").records[0].Name
} catch(Exception e1) {
//fail silently
}

Appreciate the reply - glad we’ve gone about it the right way!

Cheers!


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.