Tuesday, 13 October 2015

Aggregations In FetchXML using Javascript


    var FORM_TYPE_CREATE = 2;
    var formType = Xrm.Page.ui.getFormType();
    if (formType == FORM_TYPE_CREATE) {
        var guId = Xrm.Page.data.entity.getId();

        var fetch = "<fetch version='1.0' output-format='xml-platform' mapping='logical' aggregate='true'>" +
       "<entity name='new_paymentmodeselection'>" +
       "<attribute name='new_fees' alias='ChequeSales_sum' aggregate='sum' />" +
       "<filter type='and'>" +
         "<condition attribute='new_paymentmodeid' operator='eq' uitype='new_importdata' value='" + guId + "' />" +
       "</filter>" +
       "</entity>" +
       "</fetch>";
        var Cheque = XrmServiceToolkit.Soap.Fetch(fetch);
        if (Cheque.length > 0) {
            var totalFee ;
            if (typeof Cheque[0].attributes.ChequeSales_sum != "undefined") {

                totalFee = Cheque[0].attributes.ChequeSales_sum.value;
            }
            //var totalAmount = parseFloat(totalFee);
            Xrm.Page.getAttribute("new_chequesalegrandtotal").setValue(totalFee);
        }

    }//////////////////////////////////////////////////////////////////////Groupby Examples in Fetchxm/////////////

 var fetch = "<fetch version='1.0' output-format='xml-platform' mapping='logical' aggregate='true' >" +
             "<entity name='new_payments'>" +
                "<attribute name='new_fees' alias='fee_sum' aggregate='sum' />" +
               "<attribute name='new_paymentmodes' alias='paymentmodes' groupby='true' />" +
                "</entity>" +
           "</fetch>";


var Bankspay = parseInt(typeof totalFee[0].attributes.new_bank != "undefined" ? totalFee[0].attributes.new_bank.value : 0);
    var totalCash = parseInt(typeof totalFee[0].attributes.new_cashpayments != "undefined" ? totalFee[0].attributes.new_cashpayments.value : 0);

Sunday, 4 October 2015

showModalDialog in MSCRM

function ADD() {

    var _fullName = typeof _ApplicationRecs[i].attributes.new_fullname != "undefined" ? _aApplicationRecs[i].attributes.new_fullname.value : "";
    return typeof _printerConfigs[0].attributes.new_printername ? _printerConfigs[0].attributes.new_printername.value : null;
    if (_tAC = "" && _COde)
        {
        alert(_tAC == "" ? "Vat not found." : (_COde == "" ? "UK of Operation not found for this servicecategory." : "values not found for this missions."));


       

        var _width = 500;
        var _height = 600;

        var _left = (screen.width / 2) - (_width / 2);
        var _top = (screen.height / 2) - (_height / 2);
        var _URL = XrmServiceToolkit.Soap.GetServerURL() + "/WebResources/hppscm_/Webpages/data.html";
        var _pageProperties = 'dialogWidth=' + _width + 'px; dialogHeight=' + _height + 'px; dialogLeft=' + _left + 'px; dialogTop=' + _top + 'px;';
        window.showModalDialog(_URL, objectArray, _pageProperties);
}

SubgridSelectedRecordsGUIDS using Ribbon Button

function processrecords(selectedIds) {

    if (selectedIds != null && selectedIds != "") {

    var strIds = selectedIds.toString();

    var arrIds = strIds.split(",");

    for (var indxIds = 0; indxIds < arrIds.length; indxIds++) {

        alert(arrIds[indxIds]);

    }}}




parameters values: crm selectedcontrolItemsIds, Name SelectItems
save and Pubplish..... will get Selected record IDs In Ribbon Click.