Skip to content Skip to sidebar Skip to footer

Updating Field In Crm 2011 Through Javascript From Ribbon Button On Homegrid View

I am trying to create a button on the initial list or homegrid view of leads that will set the value of a specific field to the same value every time for the lead that is selected.

Solution 1:

To build on James's answer, you can use the CrmParameterSelectedControlSelectedItemIds to get a list of all the leads selected in a homepage grid. There is an answer on the MSDN forums that explains how to do this, copied below. You can do this in the Xml source or in the two CRM ribbon editors I know of.

After that, you would then need to use the Update method of one of the CRM webservices to loop through the Guid array and update each entity/database row accordingly. I've mentioned Avanade's excellent web resource before, and MSDN has some additional documention on this as well.

<CommandDefinitionId="Account.Form.CustomGroup.Button.A.Command"><Actions><JavaScriptFunctionLibrary="$webresource:AccountFormLibrar"FunctionName="CreateNewAccount"><CrmParameterValue="SelectedControlSelectedItemIds"/></JavaScriptFunction></Actions></CommandDefinition>
functionCreateNewAccount (prmRecordGUID) {
    //prmRecordGUID will recieve all GUIDS in comma seperated i.e. GUID1,GUID2,GUID3
}

Solution 2:

Yeah this should be pretty straightforward - I dont think what you have said in your comment will work - that function you are trying to use only works if the form of the record is open, e.g. it wont work from a grid view.

You will have to use a webservice call as described in the MSDN here: http://msdn.microsoft.com/en-us/library/hh771584#BKMK_DataAccessUsingJavaScript

Also if you are customising the ribbon (adding buttons) you would find it a lot easier with this tool: http://www.develop1.net/public/page/Ribbon-Workbench-for-Dynamics-CRM-2011.aspx

Post a Comment for "Updating Field In Crm 2011 Through Javascript From Ribbon Button On Homegrid View"