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