locked
SubGrid Value in PlugIn RRS feed

  • Question

  • Simple question but not sure how to proceed.

    I am firing a plugin on update of an entity. That entity is displaying a 1:N related entity in a subgrid on its main form.

    How can my plugin determine which related entities are selected in the subgrid when the record is updated? I can see the checked values in javascript but I want to know them in a plugin.

     

    Ever Grateful

    Thursday, August 18, 2011 1:26 AM

Answers

  • It will be a bit tricky to implement.

    Selection of records is on client side and plugin is being fired on server side.

    So, using some JavaScript, you need to save the GUIDs of related records which were selected. You can save it in one text field with comma separated. Once it is saved in a field, it is accessible by the plugin. In the plugin, access that field and it will list you the related records which were selected.

    If you explain your business requirement, maybe we can have some simple solution for you.


    MS CRM MVP :: uMar Khan :: Microsoft CRM Consultant (Blog :: http://umarkhan.wordpress.com)
    • Marked as answer by Kevin30309 Thursday, August 18, 2011 1:55 PM
    Thursday, August 18, 2011 6:23 AM
    Moderator
  • Whatever logic you have put in the plugin can go into a JavaScript method which uses oData endpoint to perform any CRM operations. From your javascript code pass in checked values to that Javascript method. This way you can achieve the same results of processing checked items, in the most efficient way.

    If you need to do any server side processing of those items, initate a call to REST web service from the JS


    Manny Grewal || Australia
    • Proposed as answer by Manny Grewal Thursday, August 18, 2011 10:39 AM
    • Marked as answer by Kevin30309 Thursday, August 18, 2011 1:55 PM
    Thursday, August 18, 2011 10:39 AM
  • Note that if you update a record inside a subgrid, on the server side, it is the subgrid record that is updated, not the main record on the form. Therefore, if you have a plugin that triggers when the subgrid record is updated it should work and if your plugin wants to know which is the "parent" record in the form, it can always retrieve that information. In other words, you do not need to worry about the main record at all since it is not getting updated.

    Gonzalo | gonzaloruizcrm.blogspot.com

    Thursday, August 18, 2011 12:05 PM
    Moderator
  • Thanks to all. I am headed down the path of storing GUID in the record. That seemed to be the most direct approach.

     

    A little background. The "main" form has some data around a service request. The "subgrid" contains a list of possible openings that can satisfy my parameters. I am taking the selected opening and scheduling a service appointment.

     

    Thanks again...K

    • Marked as answer by Kevin30309 Thursday, August 18, 2011 1:55 PM
    Thursday, August 18, 2011 12:56 PM

All replies

  • It will be a bit tricky to implement.

    Selection of records is on client side and plugin is being fired on server side.

    So, using some JavaScript, you need to save the GUIDs of related records which were selected. You can save it in one text field with comma separated. Once it is saved in a field, it is accessible by the plugin. In the plugin, access that field and it will list you the related records which were selected.

    If you explain your business requirement, maybe we can have some simple solution for you.


    MS CRM MVP :: uMar Khan :: Microsoft CRM Consultant (Blog :: http://umarkhan.wordpress.com)
    • Marked as answer by Kevin30309 Thursday, August 18, 2011 1:55 PM
    Thursday, August 18, 2011 6:23 AM
    Moderator
  • Whatever logic you have put in the plugin can go into a JavaScript method which uses oData endpoint to perform any CRM operations. From your javascript code pass in checked values to that Javascript method. This way you can achieve the same results of processing checked items, in the most efficient way.

    If you need to do any server side processing of those items, initate a call to REST web service from the JS


    Manny Grewal || Australia
    • Proposed as answer by Manny Grewal Thursday, August 18, 2011 10:39 AM
    • Marked as answer by Kevin30309 Thursday, August 18, 2011 1:55 PM
    Thursday, August 18, 2011 10:39 AM
  • Note that if you update a record inside a subgrid, on the server side, it is the subgrid record that is updated, not the main record on the form. Therefore, if you have a plugin that triggers when the subgrid record is updated it should work and if your plugin wants to know which is the "parent" record in the form, it can always retrieve that information. In other words, you do not need to worry about the main record at all since it is not getting updated.

    Gonzalo | gonzaloruizcrm.blogspot.com

    Thursday, August 18, 2011 12:05 PM
    Moderator
  • Thanks to all. I am headed down the path of storing GUID in the record. That seemed to be the most direct approach.

     

    A little background. The "main" form has some data around a service request. The "subgrid" contains a list of possible openings that can satisfy my parameters. I am taking the selected opening and scheduling a service appointment.

     

    Thanks again...K

    • Marked as answer by Kevin30309 Thursday, August 18, 2011 1:55 PM
    Thursday, August 18, 2011 12:56 PM