Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Retrieving Related contacts information and save them on variables

(0) ShareShare
ReportReport
Posted on by 1,255

Hi knowledgeable people,

i have the following scenario:

1. Custom Contacts Related Grid(Entity) on opportunities which is N to N.
2. Related entity (mentioned above) have relationship to opportunities, contacts and another custom entity called roles, to select using a look up the opportunity contact role.
3. i need to retrieve contacts information from Contacts entity based on which role he has, for example if Opportunity Contact Role is Primary, i need from related contact his email, phone, etc... can be one role or multiple roles
4. I need to set those results on variables for example when it finds on related opportunity contacts the roles, primary, technical etc, save that information (email, name, phone) on a variable.

i'm trying something like this, but no success for me with that... so any suggestion/helpful hand will be pretty awesome for me :)


function RetrieveContacts (){ var getguid =Xrm.Page.data.entity.getId(); var idOppString = getguid.slice(1, -1); var stringResult = null; var ContactsArray = My.oData.GetEntityRecords("new_contactopportunity", null, "new_contactopportunityId,new_contactopportunityId/Name,new_opportunity/Name,new_contactrole/Name", "new_opportunity/Id eq guid'"+idOppString+"'", false, null, null, null); alert("Array: "+ContactsArray[0].new_contactopportunityId.Id); if (ContactsArray[0].new_contactopportunityId.Id > 0){ alert("into if"); stringResult = ""; for (var i = 0; i < ContactsArray[0]; i++){ alert(stringResult + ContactsArray[i].new_contactrole.Name); } } }

*This post is locked for comments

  • RE: Retrieving Related contacts information and save them on variables

    Hi,

    1. Opportunity, Contacts and Roles entities has Opportunity Contacts Lookup (if am not wrong)

    2. am assuming you are trying to get contact values by executing this script in Opportunity entity.

    please do the following in your javascript

    1. In opportunity Get the opportunity Contacts lookup record id.

    2. Get all contacts which has this opportunity contact id.

    3. get its values and save in variable.

    Note: In case my answer helped you. Kindly mark it as verified.

    Warm Regards,

    Pavan Kumar Garlapati

    Follow my Blog: https://pavankumargarlapati.wordpress.com

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans