web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Answered

Auto populate account for Selected contact

(0) ShareShare
ReportReport
Posted on by 40

Hi All

In the Opportunity form I want to auto populate account field when user select a contact. I have tried with JavaScript approach with below steps.

01.Get contact ID

02.Get AccountID for Contact ID

03.Get Account name

I feel there should be an easy way do this. Could you please help me?

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    The general logic for the script is following:

    1. Get the contact id from the form.

    2. Use Xrm.WebApi to get the information from the "contact" record.

    3. Populate the "company" lookup based on the data from the previous step.

    The most challenging part is step 2 and the following post gives you almost the fully functional script for that - www.inogic.com/.../

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Saman,

    you can create a workflow to achieve it, which is a no code way and easier than js.

    You can refer following steps.

    1.Go Settings > Process to create a Real Time workflow on opportunity entity

     pastedimage1614133359017v5.png

    2.Trigger it on Create and contact field change.

    If you want to fill account from contact automatically for existing opportunities, you can check 'As an on-demand process'

     pastedimage1614131654797v2.png

    3.Update the value of account from contact.

     pastedimage1614131514808v1.png

    4.Save and Active it.

     pastedimage1614131846936v3.png

    5.Test.

    Fill contact field and save it, the account field will be filled automatically.

    pastedimage1614132343845v4.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Saman Premathilaka Profile Picture
    40 on at

    Thanks Leah

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Travis South Profile Picture

Travis South 54

#2
11manish Profile Picture

11manish 33 Super User 2026 Season 2

#3
Syed Aqib Raza Profile Picture

Syed Aqib Raza 31

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans