Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

How to add new row to a subgrid using plugin

(0) ShareShare
ReportReport
Posted on by 645

My mission is to copy rows from one subgrid to an other using plugin, relationship is N:1  but it used in a grid on the form. How can I do that?

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: How to add new row to a subgrid using plugin

    Hi,

    You could write plugin on Associate message which will trigger every time when new records added to the subgrid.

    If found helpful, Please mark my answer verified.

  • Suggested answer
    RE: How to add new row to a subgrid using plugin

    Hi sahara,

    You just need to retrieve (https://docs.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.iorganizationservice.retrieve?view=dynamics-general-ce-9)  the records from the old grid, create a new record(s) and refresh the grid.

    Please check https://docs.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.iorganizationservice.create?view=dynamics-general-ce-9 on how to create a new record using C#.

    As its not possible to refresh the grid from a plugin you will need to use formcontext.data.refresh (https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/formcontext-data/refresh) to refresh it. An option will be to use it within a setTimeout function.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans