Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Retrieve and display Address ID values on entity form

(0) ShareShare
ReportReport
Posted on by

Hello Community,

When we create a contact record in Dynamics 365, and populate its Address 1 and Address 2 fields, the system automatically creates the system "Address" entity records corresponding to Address 1 and Address 2. Also, the id of the Address records created is set in the address1_addressid and address2_addressid fields in the Contact record.

Does anyone know if and how I can expose the address1_addressid and address2_addressid fields of the Contact record on a related entity form, so that I can show the values of those address IDs on the related entity form?

Thanks!

  • LeoAlt Profile Picture
    16,331 Moderator on at
    RE: Retrieve and display Address ID values on entity form

    Hi Eric,

    Thanks for your details.

    May I know that what the kind of the field "Address1_AddressId"? Since you want to store the primary key(ID) in it, is it lookup field or only text field?

    And if the contact has 1:N relationship between the related entity, then you could get the ID value from contact by JS I provided before.

    If the contact has N:1 relationship between the related, you need to use Power Automate(Flow) to get the ID value from contact.

    Regards,

    Leo

  • Community Member Profile Picture
    on at
    RE: Retrieve and display Address ID values on entity form

    Hi Jim,

    Thanks for your information.

    Unfortunately, I am looking to map the "primary key" value, not the regular field values. I don't think the field mapping via the relationships supports mapping of the primary key field from the source entity to another field on the related entity since the data type would be different.

    Basically, what I am trying to achieve is copy the primary key field value from the field "Address1_AddressId" from the Contact entity, to another field on a related entity. Using Quick View would not meet the requirement as I need this field to be directly on the related entity so I can query and perform other tasks I need to directly on the related entity.

  • Suggested answer
    ACECORP Profile Picture
    1,589 on at
    RE: Retrieve and display Address ID values on entity form

    You can use the Field Mapping feature of D365 to do that.

    See the following knowledge article for details https://itsolutions.bdo.ca/insights/using-field-mapping-in-microsoft-dynamics-crm-to-copy-data-between-associated-records/

  • LeoAlt Profile Picture
    16,331 Moderator on at
    RE: Retrieve and display Address ID values on entity form

    Hi Partner,

    If you want to show data on related entity forms from contact, you could use the following ways.

    1.Using Quick View Form for contact, and add your address fields on it and then show it on related entity forms.

    pastedimage1594016848709v1.png

    pastedimage1594016864973v2.png

    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/customize/create-edit-quick-view-forms

    2.Create the field you want to show on related entity form, and use JS code to get the field value by webapi.

    Sample code:

    //get field value based on lookup field.
    function getValueByCustomer(executionContext){
        formContext=executionContext.getFormContext();
        var customer=formContext.getAttribute("customerid").getValue();
        if(customer != null){
            var customerId = customer[0].id.replace("{", "").replace("}", "");
            //get field value from related account 
            Xrm.WebApi.retrieveRecord("account", customerId, "?$select=fieldname").then(
                function success(result) {
                    //set value from account form to order form
                    formContext.getAttribute('new_fieldName').setValue(result.fieldname);
                },
                function (error) {
                    console.log(error.message);
                    // handle error conditions
                }
            );
        }
    
    }

    Best Regards,

    Leo

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 149 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 61 Most Valuable Professional

#3
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 53 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans