I want to allow the user to select one or many contacts from the contact entity, and then launch a dialog that accepts the record IDs. The idea is to add some custom configuration to the contacts.
I've currently got a custom action on a ribbon button that launches a dialog, but it only accepts one record Id. I can get access to the list of selected record Ids, thatisn't the problem, it is passing a list to the dialog using JavaScript.
I can't seem to find anything in the SDK or code snippets. The nearest thing I found was this:
http://crmmongrel.blogspot.com/2011/06/launch-dialog-from-ribbon-button-in-crm.html
Anyone know if this is possible? I know the out of the box Send Direct E-Mail allows an email to be sent to the selected items, so I need somethin开发者_如何学JAVAg similar.
Should I be using dialogs or something else?
Here is a code snippet of the javascript that is called on the click of the ribbon button:
function LaunchModalDialog(SelectedControlSelectedItemReferences,dialogID, typeName)
{
// Get selected objects
var allItems = new Array
var allItems = SelectedControlSelectedItemReferences
// Just get first item for now as dialog only seems to accept one ID
var personId = allItems[0].Id;
personId = personId.replace(/\{/g, "");
personId = personId.replace(/\}/g, "");
// Load modal
var serverUri = Mscrm.CrmUri.create('/cs/dialog/rundialog.aspx');
var mypath = serverUri + '?DialogID={' + dialogID + '}&EntityName=' + typeName + '&ObjectId={' +personId + '}';
mypath = encodeURI(mypath);
// First item from selected contacts only
window.showModalDialog(mypath);
// Reload form.
window.location.reload(true);
}
You'll need to specify the SelectedControlAllItemIds parameter in your Ribbon for that button. Here is a link that describes it:
http://social.microsoft.com/Forums/en/crm/thread/79f959ac-0846-472f-bff1-4f5afe692a56
--Edit--
I'm sorry, I misunderstood - you meant launch an actual CRM Dialog, not just a normal HTML pop-up dialog window.
CRM Dialogs can't be used on multiple records by design, so you aren't going to be able to use them for this.
However, you should be able to create an HTML web resource file that you can launch from the Ribbon, passing in the SelectedControlAllItemIds parameter. That HTML web resource would then have some javascript that would update the selected contacts using the REST endpoints (see the SDK for more information).
Hope that helps!
精彩评论