Created
March 29, 2019 04:25
-
-
Save stimms/1d1d0691f9d1174ef98df11eea083628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// option 1 - async | |
async function draw() { | |
var contactId = parent.Xrm.Page.data.entity.getId(); | |
connections = await getConnectionsByContactId(contactId); | |
} | |
async function getConnectionsByContactId(contactId) { | |
const result = await Xrm.WebApi.retrieveRecord("contact", contactId, | |
`?$expand=contact_connections1($select=_record2id_value,connectionid,name,record2objecttypecode,entityimage_url) | |
&$select=contactid,fullname,entityimage_url`); | |
return result; | |
} | |
// option 2 - promises | |
function draw() { | |
const contactId = parent.Xrm.Page.data.entity.getId(); | |
connections = getConnectionsByContactId(contactId).then(connections=> { | |
//do your drawing here | |
}); | |
} | |
function getConnectionsByContactId(contactId) { | |
return Xrm.WebApi.retrieveRecord("contact", contactId, | |
`?$expand=contact_connections1($select=_record2id_value,connectionid,name,record2objecttypecode,entityimage_url) | |
&$select=contactid,fullname,entityimage_url`) | |
.then(resultToken => { | |
return resultToken; | |
}) | |
.catch(error => { | |
throw error; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment