Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Retrieve the currency field value from contact (ie) lookup field in account entity and must show the contact currency field value should update while saving in account entity currency field save using plugins

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

hi  can anyone tell me how to Retrieve the currency field value from contact (ie) lookup field in account entity and must show the contact currency field value should update while saving in account entity currency field  save using plugins . 

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve the currency field value from contact (ie) lookup field in account entity and must show the contact currency field value should update while saving in account entity currency field save using plugins

    I am stuck in it i retrieved the account and contact after that i need to retrieve attribute Money from contact and update in Account money Field .  here is my plugin code 

    namespace Moneyretrieveing
    {
    public class Class1 : IPlugin
    {
    private object entity;
    private object targetEntity;

    public object guidAccountId { get; private set; }

    public void Execute(IServiceProvider serviceProvider)
    {
    IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
    IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
    IOrganizationService service = factory.CreateOrganizationService(context.UserId);
    QueryExpression queryAccounts = new QueryExpression("account");
    queryAccounts.ColumnSet = new ColumnSet(true);
    EntityCollection Accounts = service.RetrieveMultiple(queryAccounts);
    QueryExpression queryAccounts1 = new QueryExpression("contact");
    queryAccounts1.ColumnSet = new ColumnSet(true);
    queryAccounts1.Criteria.AddCondition("parentcustomerid", ConditionOperator.Equal, new Guid("7C23E73A-2A4E-EA11-A812-000D3AF26E41"));
    EntityCollection contacts = service.RetrieveMultiple(queryAccounts);
    queryAccounts.ColumnSet = new ColumnSet("primarycontactid");
    EntityCollection retrieved = service.RetrieveMultiple(queryAccounts1);
    if (queryAccounts1.Attributes.Contains("new_money"))
    {
    Money money = (Money)((contacts.Attributes["new_money"]));
    }
    for (int i = 0; i < retrieved.; i++)
    {


    }


    }
    }
    }

  • Suggested answer
    Vipin J Profile Picture
    Vipin J 1,583 on at
    RE: Retrieve the currency field value from contact (ie) lookup field in account entity and must show the contact currency field value should update while saving in account entity currency field save using plugins

    You need to write a java-script code

    • on the change of contact lookup on account entity
    • on the form load of account entity

    Code will try to get associated currency value which is set on contact record and set the value in account entity form.

    Refer following

    https://vjcity.blogspot.com/2019/07/how-to-get-and-set-value-for-different.html

    https://vjcity.blogspot.com/2019/08/guidelines-to-write-good-javascript.html

    If you change the currency value on Account entity, then you can update the currency value on contact entity from java-script.

    You should go for Plugin if these operations are being done to CRM from external end.

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 Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans