الأحد، 26 أبريل 2015

Open CRM Lookup window in a custom page

function OpenLookup() {
    var serverURL = "http://Server:5555/OrganizationName/_controls/lookup/lookupinfo.aspx?AllowFilterOff=1&DefaultType=2&DefaultViewId=%7b00000000-0000-0000-00AA-000010001004%7d&DisableQuickFind=0&DisableViewPicker=0&LookupStyle=single&ShowNewButton=1&ShowPropButton=1&browse=0&objecttypes=123";


    var lookUp = window.showModalDialog(serverURL, 'entity', "dialogwidth: 750px; dialogheight: 600px; resizable: yes");

    ///For get return values

    //var name = lookUp.items[0].name; var id = lookUp.items[0].id;
    if (lookUp != null) {
        var data = eval('(' + lookUp + ')');
        alert(data.items[0].name + ":" + data.items[0].id);
    }
}

الاثنين، 20 أبريل 2015

Dynamics CRM 2013:Get/Set Business Process stage field value.

Xrm.Page.getControl("header_process_fieldname").getAttribute().setValue(value);  //Set Value

Xrm.Page.getControl("header_process_fieldname").getAttribute().getValue();  //Get Value

 //****** get the Id of business process Satge*******************************
    var StageId = Xrm.Page.getAttribute("stageid").getValue();
    
    if (StageId == "7f5247fe-cfc3-42bc-aa77-b1d836d9b7c0") {
        var Control = Xrm.Page.getControl("header_process_fieldname").getAttribute();
//fire onChange event.
        Control.addOnChange(FunctionName);
    }

الخميس، 16 أبريل 2015

How to assign Equipment/Facility to existed resource group.


//********* Create New Equipment/Facility *******************************
        Entity Equipment = new Entity("equipment");
        Equipment["name"]="Test Equipment 1";
        Equipment["timezonecode"]=1;
        Equipment["businessunitid"] = new EntityReference("businessunit", new Guid("BusinessUnitId"));

        Guid EquipmentId = _Service.Create(Equipment);
        //************************** Retrieve the Resource group***************
        Entity ResourceGroup = _Service.Retrieve("constraintbasedgroup", new Guid("ResourceGroupId"), new ColumnSet(true));
        //********************* Get the constrains of Resource group***************
        System.Text.StringBuilder builder = new System.Text.StringBuilder(ResourceGroup["constraints"].ToString());
        //******* Assing the equipment to resouce group ***************
        builder.Replace("</Body>", " || resource[\"Id\"] ==" + EquipmentId.ToString("B") + " </Body>");

        ResourceGroup["constraints"] = builder.ToString();
        //**************************** Update Resource Group***************
        _Service.Update(ResourceGroup);