Wednesday, March 7, 2012

Working with Visual Ribbon Editor - Adding Button and passing parameters

Hope you remember my previous post. As I explained to you visual ribbon editor is a great tool which we can use easily to create new ribbon button and actions. here I'm explaining how to create a Ribbon button using visual ribbon editor, and pass selected records guids as a parameter to update those records from the back end.

First will see how to add a Ribbon button.

1. Connecting to the CRM server from visual ribbon editor.

2. Click on "Open" button and select the Entity which you want to create a button.

3. Now you have 3 kind of Ribbon types (Form, Homepage and Sub-Grid) in this example I'm creating button against the Homepage.

4. Click on 'New Group' and add a Group to your button

5. Select the Group and Click on "New Button" Update Lable and Id and Select the icon as well.


Ok Now you ready to Go.

Click on Save button. it will save and publish your changes to the CRM.

Now we need to add action to that button click.

Create a web resource and Add a javascript function ex: updateRecordStatus

what this function does is it simply call WCF method to update the record status. Here I'm not going to focus on WCF method.

As you can see in the below image we can specify CRM parameters. Here I'm selecting "Selec

tedControlSelectedItemIds" parameter. This will pass whatever the selected records to the javascript method. Then we can use AJAX to send those IDs to the WCF web service and show the response to the user.

function UpdateRecordStatus(recordIds) {
if (recordIds!= null && recordIds!= "") {
var _serviceUrl = '/ISV/SERVICE/Service.svc/json/UpdateRecordStatus';
var _data = '{"Ids": "' + recordIds + '"}';
$.ajax({
type: "POST",
url: _serviceUrl,
data: _data,
contentType: "application/json",
dataType: "json",
cache: false,
async: false,
success: function (response) {
alert("Selected records are updated successfully ")
},
error: function (response) {
alert(response.responseText);
}
});
}
}

No comments:

Post a Comment

MS CRM 2011 KB Article customization Issue.

Recently I have encountered some issue while customizing Kb Article Entity. I was doing following configuration in Article form. 1. Add Ba...