none
CRM 2011,How to retrieve selected records from CRM Grid

    Question

  • Hi

     

    i am struggling to write code(javascript in custom html web resource) to retrieve the GuId's of all selected contacts from main application grid. Actually i have a button on Main CRM application Grid which upon click displays all the interests(custom entity) in my html Page and upon selection of perticular interest by the user it should create m-m relationship between that Interest and all selected contacts(from CRM App Grid). The only part i am struggling to write is how to retrieve the Guid's of selected contacts from Main CRM Appliation Grid in my html page.

     

    Any urgent help will be highly appreciated.

    Umer

    Friday, June 17, 2011 3:43 PM

Answers

  • Hi Umer,

    You need to add CrmParameter=SelectedControlSelectedItemIds xml node into ribbon Actions JavaScriptFunction xml node. Then on button click CRM will pass the selected records GUID into the function first paramter as commana seperated values.

    <CommandDefinition Id="Account.Form.CustomGroup.Button.A.Command">
    <Actions>
      <JavaScriptFunction Library="$webresource:AccountFormLibrar" FunctionName="CreateNewAccount">
      <CrmParameter Value="SelectedControlSelectedItemIds"/></JavaScriptFunction>
    </Actions>
    </CommandDefinition>

    Make sure that function is recieving paramter i.e.

    function CreateNewAccount (prmRecordGUID) {

     //prmRecordGUID will recieve all GUIDS in comma seperated i.e. GUID1,GUID2,GUID3

    }

     


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    Friday, June 17, 2011 7:25 PM
  • Hi

     

    Since you can retrieve the Id of the selected item from Grid(using SelectedControlSelectedItemIds), you can make another Ajax call to Odata endpoint to retrieve other attributes such as product quantity.

     

    Umer

    • Marked as answer by Umer_Javed Wednesday, July 20, 2011 2:31 PM
    Wednesday, July 20, 2011 2:31 PM

All replies

  • Hi Umer,

    You need to add CrmParameter=SelectedControlSelectedItemIds xml node into ribbon Actions JavaScriptFunction xml node. Then on button click CRM will pass the selected records GUID into the function first paramter as commana seperated values.

    <CommandDefinition Id="Account.Form.CustomGroup.Button.A.Command">
    <Actions>
      <JavaScriptFunction Library="$webresource:AccountFormLibrar" FunctionName="CreateNewAccount">
      <CrmParameter Value="SelectedControlSelectedItemIds"/></JavaScriptFunction>
    </Actions>
    </CommandDefinition>

    Make sure that function is recieving paramter i.e.

    function CreateNewAccount (prmRecordGUID) {

     //prmRecordGUID will recieve all GUIDS in comma seperated i.e. GUID1,GUID2,GUID3

    }

     


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    Friday, June 17, 2011 7:25 PM
  • Thanks Jehanzeb. Can i just confirm "AccountFormLibrar" web resource in your example, it is an html web resource.correct?
    Monday, June 20, 2011 5:52 PM
  • Hi Umer,

    It is Script (JScript) type web resource.


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Monday, June 20, 2011 7:35 PM
  • Hello again,

    I want to get a column value from grid in CRM Dynamics 2011. I have a grid with three columns, one with product code, product description and last one with product quantity I want to pick quantity on form load event.

    Regards,

     


    Raza Usmani Software Engineer
    • Proposed as answer by Umer Javed Wednesday, July 20, 2011 2:25 PM
    • Unproposed as answer by Umer Javed Wednesday, July 20, 2011 2:26 PM
    Tuesday, July 12, 2011 9:07 AM
  • Hi

     

    Since you can retrieve the Id of the selected item from Grid(using SelectedControlSelectedItemIds), you can make another Ajax call to Odata endpoint to retrieve other attributes such as product quantity.

     

    Umer

    • Marked as answer by Umer_Javed Wednesday, July 20, 2011 2:31 PM
    Wednesday, July 20, 2011 2:31 PM