Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Suggested answer

Opening a form which has every contact of a account (relationship)

(0) ShareShare
ReportReport
Posted on by 3
Hello there,
I am currently trying to open a little window which includes the contacts of a account. I found the navigateTo function, but I do not understand the relationship parameter.
I thought you can open the window using that, but I cant get it running.

Here is a rough picture of my goal, made in Photoshop. I only want the /Zugeordnete Ansicht: Kontakte/ part of the little window.



(Zugeordnete Ansicht: Kontakte -> Assigned View: Contacts, when translated word by word)

That below is my current attempt to open it like in the picture. I tried different entityNames like account, contact and relationship. Both account and contact just sent me to the record or the entitylist, depending on which pageType I specified.
For the attributeName I tried account and contact. 

Now for entityName relationship, when using that, there was an error message saying /The record you are trying to access does not have a form to display. Please contact your administrator for assistance./ 
 
var relationShip = {};
relationShip[/relationshipType/] = 1;
relationShip[/name/] = /contact_customer_accounts/;
relationShip[/attributeName/] = /account/;
relationShip[/roleType/] = 1;
var entityFormOptions = {};
entityFormOptions[/entityName/] = /relationship/;
entityFormOptions[/entityId/] = /295caa62-0000-eb11-80c6-005056900000/;
entityFormOptions[/relationship/] = relationShip;
entityFormOptions[/pageType/] = /entityrecord/;
var navigationOptions = {
    target: 2,
    height: {value: 80, unit:/%/},
    width: {value: 70, unit:/%/},
    position: 1
};
// Open the form.
Xrm.Navigation.navigateTo(entityFormOptions, navigationOptions).then(
    function (success) {
        console.log(success);
    },
    function (error) {
        console.log(error);
    });
Now openForm also has a relationship parameter, but well I didnt understand I either.

If it isnt possible to open a Window/Form like in the picture using openForm or navigateTo, how would you do it? And also, what would the relationship parameter stand for otherwise/what would you use it for?

Thanks for reading, hopefully someone has an answer.
 
  • Opening a form which has every contact of a account (relationship)
    oh, Thanks for sharing, I also had the same problem and it was quite difficult!
  • Suggested answer
    MaxB Profile Picture
    MaxB 3 on at
    Opening a form which has every contact of a account (relationship)
    I now created a new WebResource where I got all Entitys using the Xrm.WebApi.online.retrieveMultipleRecords function.


    My function to retrieve the Data looks like this:
     
    function getDataFromCRM(fields, entityName, filter) {
        var id = getCompanyId();
        var generatedSelection = "";
        for (let i = 0; i < fields.length; i++) {
            generatedSelection += fields[i] + ",";
        }
        parent.Xrm.WebApi.online
            .retrieveMultipleRecords(
                entityName,
                "?$select=" +
                generatedSelection +
                "&$filter=" + filter + " eq " +
                id
            )
            .then(
                function success(results) {
                    console.log(results);
                },
                function (error) {
                    return console.log(error);
                }
            );
    }

    The Array fields is something like: 
            var felder = [
                "contactid",
                "fullname"
            ]

    Filter for contacts would be: "_parentcustomerid_value"

Helpful resources

Quick Links

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 284,876 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,425 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans