locked
getting guids of the selected records in the grid RRS feed

  • Question

  • Hi,
    I want to get the guids of selected records in the grid when an ISV grid button is clicked and i need to pass those ids to an new email form



    Thanks
    Divya
    Tuesday, December 29, 2009 5:01 AM

Answers

  • I placed this code on a button in the ISV Config.
    Because I wanted to do something with the selected rows when a button is clicked.

    It doesnt have any use to place is in the onload, because when the form is loading no rows can be selected.
    You could place it on:

    - onSave
    - ISV Config button
    Tuesday, December 29, 2009 11:35 AM

All replies

  • Hi Divya,

    This link might be useful for you !



    Regards,
    Nishant Rana

    http://nishantrana.wordpress.com
    Tuesday, December 29, 2009 5:09 AM
  • Place cod in ISV under the entity you want your button.

    It will place a button on on gridbar, on click it will open new email forms for each selected record.

    you can adjust it according to your business requirements.
    do tell me if you need any further healp.

    <Button Icon=

    "/_imgs/ico_16_138.gif" Url="" JavaScript="

    var

     

    a = document.all['crmGrid'].InnerGrid.SelectedRecords;

    if

     

    (a.length > 0)

    {

    for

     

    (i=0; i &lt; _Attributes.length; i++ )

    {

    var

     

    pId = a[i][0];

    var

     

    pType = a[i][1];

    var

     

    pName = a[i][3].all[4].innerText;

    var

     

    url = '/activities/email/edit.aspx?pId='+pId+'&amp;pType='+pType+'&amp;pName='+pName+'&amp;partyid='+pId+'&amp;partytype='+pType+'&amp;partyname='+pName+'&amp;partyaddressused=&amp;contactInfo=';

    window.open(url,

    null, 'width=1000, height=530, toolbar=0');

    }}

    " WinParams="letf=0,top=0,width=10,height=10,toolbar=0,scrollbars=0,status=1" WinMode="1">

    <Titles>

    <Title LCID=

    "1033" Text="" />

    </Titles>

    <ToolTips>

    <ToolTip LCID=

    "1033" Text="Create new Email for selected record" />

    </ToolTips>

    </Button>


    http://www.allaboutdynamics.com
    Tuesday, December 29, 2009 5:18 AM
  • If you can directly access a grid via javascript (in other words, delving into an IFrame to grab it), this site may be useful:

    http://blog.customereffective.com/blog/2009/02/javascript-snippets-for-working-with-grids-in-crm.html
    Dave Berry
    Tuesday, December 29, 2009 5:28 AM
    Moderator
  • Hi,
    I get error on page if i copy the above code can u please help me.
    Tuesday, December 29, 2009 6:24 AM
  • please check this line
     for (i=0; i &lt; _Attributes.length; i++ )

    it will be

     for (i=0; i &lt; a.length; i++ )


    http://www.allaboutdynamics.com
    Tuesday, December 29, 2009 6:42 AM
  • I need this functionality for multiple records selected i need to create only one email activity with partyid of multiple selected account.

    can it be possible.

    Thanks
    Divya
    Tuesday, December 29, 2009 8:03 AM
  • Yes you can!

    In your custom web page, create one email and for each retrieved guid, create a new activityparty object and link it to the mail...

    My blog : http://mscrmtools.blogspot.com
    You will find:
    Form Javascript Manager (export/import javascript from forms)
    ISV.Config Manager (graphical ISV.config edition - export/import)
    View Layout replicator (customize one view and replicate to others)
    And others (use tool tag on my blog)
    Tuesday, December 29, 2009 8:15 AM
    Moderator
  • Yes it can be done.
    The code:

    var _objRows = document.getElementById('gridBodyTable').rows;
    var data = new Array();
    var oId;       
    var oType;
    
    for(var i=0; i < _objRows.length; i++){           
    	if(_objRows[i].className == 'ms-crm-List-SelectedRow'){
    		oId = _objRows[i].oid;
    		oType = _objRows[i].otype;
    		data.push(oId);
    	}
    }
    
    document.cookie = 'SelectedRows=' + data + '; path=/;';
    Don't really have time to explain the code, but what it does is it gets the guids of a selected row after you clicked a button.
    It writes these GUIDS to a cookie (but you can do with it what you want).

    Hope you can figure it out by yourself.
    • Proposed as answer by Joey VDB Tuesday, December 29, 2009 11:35 AM
    Tuesday, December 29, 2009 8:18 AM
  • Hi,

    I need to pass all guids to crm's email form not to any custome defined web page.I need to capture all the selected guid's in the grid and pass it to the partyid of email entity of ms crm.

    Thanks
    Divya
    Tuesday, December 29, 2009 8:33 AM
  • The above code gathers all the selected guids and places these guids in the var data.
    So all you have to do is to pass the var data to the partyid. How its done, i do not know.

    Tuesday, December 29, 2009 11:00 AM
  • where to place the code in ISV or in email onload event?
    Tuesday, December 29, 2009 11:17 AM
  • I placed this code on a button in the ISV Config.
    Because I wanted to do something with the selected rows when a button is clicked.

    It doesnt have any use to place is in the onload, because when the form is loading no rows can be selected.
    You could place it on:

    - onSave
    - ISV Config button
    Tuesday, December 29, 2009 11:35 AM