Search code examples
dynamics-crm-2011dynamics-crmodatacrmjscript

Dialogs OData Set name?


Ok in crm 2011 using Odata Query - if a workflows Odata Set name is AsyncOperationSet What is the equivalent for a dialog?

I have tried to figure this out with no luck

Please help

Thank you

P.s I need to get the dialogs id from its name


Solution

  • When searching for a dialog to launch via javascript:

    Category = 1 (Dialog) Type = 1 (Definition) - This is important if trying to call a dialog from javascript!

    Solution:

    triggerDialog = function (name, entityName, recordId) {
    
    var dialogId = "";
    
        var request = Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc/WorkflowSet?$select=Name,WorkflowId&$filter=Type/Value eq 1 and Category/Value eq 1 and Name eq '"+name+"'";
        $.ajax({
            type: "GET",
            contentType: "application/json; charset=utf-8",
            datatype: "json",
            url: request,
            async: false,
            beforeSend: function (XMLHttpRequest) {
                XMLHttpRequest.setRequestHeader("Accept", "application/json");
            },
            success: function (data, textStatus, XmlHttpRequest) {
                if (data.d.results.length > 0) {
                    dialogId = data.d.results[0].WorkflowId;  
               }
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                /*Error Occurred*/
            }
        });
    
    var serverUrl = Xrm.Page.context.getServerUrl();
    
    window.showModalDialog(
    serverUrl + "/cs/dialog/rundialog.aspx?DialogId=" + encodeURIComponent(dialogId) + "&EntityName=" + encodeURIComponent(entityName) + "&ObjectId=" + encodeURIComponent(recordId), null, "dialogHeight:600px;dialogWidth:800px;center:yes; resizable:1;maximize:1;minimize:1;status:no;scroll:no");
    

    Hope this helps