Answered by:
How to call the save method with a custom ribbon button in CRM 2011

Question
-
Hello there
I'm adding a custom button in the ribbon of my CRM 2011, How can I call the save method or another like save and close with this custom button. I read in some pages that it is possible using JScript libraries and functions, but no the webresourses, for example: I can do that this button shows an alert message with the text "Hello world", but I don't know how call the save method in a similar way to: "Xrm.Page.data.entity.save()".
Anyone know how to do this?
Thanks.
Mario MI
Friday, August 10, 2012 6:21 PM
Answers
-
Hi,
You need to create the custom action like below:
<Actions> <JavaScriptFunction Library="$webresource:WEBRESOURCE_NAME" FunctionName="CUSTOM_FUNCTION_NAME"> <CrmParameter Value="FirstPrimaryItemId" /> </JavaScriptFunction> </Actions>
And also you need to create the method in the custom web resource(WEBRESOURCE_NAME):
function CUSTOM_FUNCTION_NAME(){ Xrm.Page.data.entity.save(); // Save // or Xrm.Page.data.entity.save('saveandclose'); // Save and Close }
Good luck
- Proposed as answer by Parthiban.T Monday, August 13, 2012 7:54 AM
- Marked as answer by Mario Muñoz Ibarra Sunday, September 9, 2012 11:49 PM
Monday, August 13, 2012 7:46 AM
All replies
-
Hi,
You can use Visual Ribbon Editor to create a new button by connecting it to your CRM Server.
Try Downloading the Tool using this link:http://crmvisualribbonedit.codeplex.com/
Create a new Button in the Entity where You need. Under the Actions Tab, Call the JavaScript Function you have written for performing Save / Save&Close Action. Also You can add the CRM Parameter(Primary Item Ids) under your JScript Function.
Naren
- Proposed as answer by Parthiban.T Monday, August 13, 2012 8:56 AM
Monday, August 13, 2012 7:15 AM -
Hi,
You need to create the custom action like below:
<Actions> <JavaScriptFunction Library="$webresource:WEBRESOURCE_NAME" FunctionName="CUSTOM_FUNCTION_NAME"> <CrmParameter Value="FirstPrimaryItemId" /> </JavaScriptFunction> </Actions>
And also you need to create the method in the custom web resource(WEBRESOURCE_NAME):
function CUSTOM_FUNCTION_NAME(){ Xrm.Page.data.entity.save(); // Save // or Xrm.Page.data.entity.save('saveandclose'); // Save and Close }
Good luck
- Proposed as answer by Parthiban.T Monday, August 13, 2012 7:54 AM
- Marked as answer by Mario Muñoz Ibarra Sunday, September 9, 2012 11:49 PM
Monday, August 13, 2012 7:46 AM -
Thanks, it works
Mario MI
Sunday, September 9, 2012 11:50 PM