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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to update a sub grid field based on field ?

(0) ShareShare
ReportReport
Posted on by 40

 I 5430.download.pnghave est.close date in opportunity and sub grid of product  i want to assign the value of est.close date to valid_ to in product sub grid when you choose the opportunity and save these assign the value of close date to the valid to field in product sub grid  and when you open  the opportunity again you can not choose the product that used in another product 

when it used in other opportunity

I have the same question (0)
  • Ahmed Mehany Profile Picture
    40 on at

    screenshot_2D00_10_2D00_4_2D00_2_2D00_228_2D00_INMA_2D00_main_2D00_aspx_2D00_1608121620675.png

    i have est.close date in opportunity and sub grid of product  i want to assign the value of est.close date to valid_ to in product sub grid when you choose the opportunity and save these assign the value of close date to the valid to field in product sub grid  and when you open  the opportunity again you can not choose the product that used in another product 

    when it used in other opportunity

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

    Hello,

    If you want to use this approach I would recommend to use Plugin or Flow to loop through the child records and update the field on the change of the field on the parent record.

  • Ahmed Mehany Profile Picture
    40 on at

    can you guide me in example of how to use plugin to update subgrid record

  • Ahmed Mehany Profile Picture
    40 on at

    i have done these plugin and it's not working

     public void Execute(IServiceProvider serviceProvider)

           {

               // extract the service provider

               ITracingService tracingservice = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

               IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

               IOrganizationServiceFactory srevicefactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

               IOrganizationService service = srevicefactory.CreateOrganizationService(context.UserId);

               if(context.InputParameters.Contains("Target")&&context.InputParameters["Target"] is Entity)

               {

                   Entity entity = (Entity)context.InputParameters["Target"];

                   if (entity.Contains("name"))

                    {

                        var fetch = @"<fetch no-lock='true' >

                                <entity name='opportunity' >

                                  <attribute name='contactid'/>

                                  <filter>

                                    <condition attribute='opportunityid' operator='eq' value='{0}' />

                                  </filter>

                                </entity>

                              </fetch>";

                        var fetchXML = string.Format(fetch, entity.Id);

                        var allContacts = service.RetrieveMultiple(new FetchExpression(fetchXML)).Entities;

                        foreach (var contactEnt in allContacts)

                        {

                            Entity contactToUpdate = new Entity("opportunityproduct", contactEnt.Id);

                            contactToUpdate["new_valid_to"] = entity["estimatedclosedate"];

                            service.Update(contactToUpdate);

                        }

                    }

               }

           }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 213 Super User 2026 Season 1

#2
CU11031447-0 Profile Picture

CU11031447-0 100

#3
NeerajPawar Profile Picture

NeerajPawar 71

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans