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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Copy contents from Subgrid and paste records to another subgrid

(0) ShareShare
ReportReport
Posted on by 110

Hi

   I want to copy records from a subgrid and paste them into another subgrid. I have 2 conditions where the subgrids are related to same entity and different entity. Can I do this using Scripts/ Webapi/fetch or using plugin. If so please provide me with a sample code.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    I would probably use actions to do this.

    On the main form add a button (Copy Subgrids) using Ribbon Workbench.

    Create an Action under Processes for the entity that contains the form (not the entity of the subgrid). The Action doesn't need to have any input or output parameters.

    In the JavaScript function of your form, call the Action, and pass the Target type with an Entity Reference value of your form entity and entity id. Add code to refresh the form after the action has been completed

    Create a Plugin/Action for the Action that you just created.

    In your action add code to retrieve the data from grid 1, and create it in grid 2

    Add any additional logic that you want over there...

    Comprehensive, but I think probably ideal solution.

  • VermaNitin Profile Picture
    455 on at

    Hi Satish,

    Plugins can't be used to play with front-end components like subgrids.

    For same entity:

    You can probably use script to get the view selected in the first subgrid and then programmatically select the same view in the second subgrid.

    Note: The view selector should be enabled to achieve this.

    For different entity:

    How did you manage to show some other entity's data in a subgrid which is already bound to another entity?

    I don't have any idea on this. But I would be happy if you get a response on this.

    Hope it helps!

    Many thanks,

    Nitin Verma

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Actions are similar to plugins, but can be called from client side (i.e. JavaScript), but executed on Server side.

    The idea is that each grid displays data for an Entity, so by querying the entity and passing the parent Entity Id as an attribute, you can get all the records that you see in the subgrid as an EntityCollection in the Action code.

    You would take each value in the Entity Collection, and "Copy" into the new entity, since you know the parent Id of the entity, it would place the results in the right place.

    After the action execution has been completed, and the results come back to the client side, refresh the page or subgrids and you will see the copied results.

    Actions can be the combination of Action Process + Workflow or Action Process + Plugin. Logic is up to you.

    If you go with the Plugin route, you would have to register the action using the Plugin registration tool.

    The actions are not modifying the subgrids directly, but modify the data in the subgrids.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans