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);
No comments:
Post a Comment