Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

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

(0) ShareShare
ReportReport
Posted on by 5
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 5 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"

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! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans