最近、Outlook クライアント用の CRM 2011 を新しいマシンに追加しました。支払いエンティティ formLoad で実行されるスクリプトがあります。このスクリプトは、すべての支払い割り当てを考慮し、TotalAmount から差し引いた後の残りの金額を計算します。
ただし、Outlook を介してデータにアクセスすると、formLoad でスクリプトが起動していないようです。Web ポータルを介して同じデータにアクセスすると、スクリプトは問題なく起動します。 CRM用のOutlookでカスタムjavascriptを実行できるようにするために有効にする必要がある場所を設定しますか?
私のスクリプトは以下の paymentLoad() です:
function PaymentOnLoad() {
setTimeout(attachEventToGrid, 2500);
if (crmForm.ObjectId != null) {
var PaymentAmount = Xrm.Page.getAttribute("new_accountpaymentamount").getValue();
var OSAmount = CalcOutstandingPaymentAmount(crmForm.ObjectId);
Xrm.Page.getAttribute("new_remainingamount").setValue(parseFloat(eval(rounddec(OSAmount))));
if ((PaymentAmount != null) && (OSAmount - PaymentAmount != 0)) {
Xrm.Page.ui.controls.get("new_paymentamount").setDisabled(true);
}
}
}
function rounddec(value) {
return Math.round(value * 100) / 100;
}
function attachEventToGrid() {
// Attach a refresh event to the PaymentAllocations grid
var targetgrid = document.getElementById("PaymentAllocations");
if (targetgrid) {
if (targetgrid.control.add_onRefresh != undefined) {
targetgrid.control.add_onRefresh(ReLoad);
}
else {
targetgrid.attachEvent("onrefresh", ReLoad);
}
}
else {
setTimeout(attachEventToGrid, 2500);
}
}
function PaymentAllocationOnLoad() {
OnPaymentTypeSelection();
if (Xrm.Page.getAttribute("new_payment").getValue()[0] != null) {
var OSPaymentAmount = CalcOutstandingPaymentAmount(Xrm.Page.getAttribute("new_payment").getValue()[0].id);
Xrm.Page.getAttribute("new_paymentremainingamount").setValue(parseFloat(eval(OSPaymentAmount)));
if (Xrm.Page.getAttribute("new_invoice").getValue() != null) {
var OSInvoiceAmount = CalcOutstandingInvoiceAmount(Xrm.Page.getAttribute("new_invoice").getValue()[0].id);
Xrm.Page.getAttribute("new_invoiceremainingamount").setValue(parseFloat(eval(OSInvoiceAmount)));
Xrm.Page.ui.controls.get("new_paymentamount").setDisabled(true);
}
}
}
function CalcOutstandingPaymentAmount(paymentid) {
_oService = new FetchUtil(_sOrgName, _sServerUrl);
var sFetchPayment = "<fetch mapping='logical'>" +
"<entity name='new_payment'>" +
"<attribute name='new_paymentamount' />" +
"<attribute name='new_accountpaymentamount' />" +
"<filter type='and'>" +
"<condition attribute = 'new_paymentid' operator='eq' value='" + paymentid + "'/>" +
"</filter>" +
"</entity>" +
"</fetch>";
var fetchResultPayment = _oService.Fetch(sFetchPayment, null);
var sFetch = "<fetch mapping='logical'>" +
"<entity name='new_paymentinvoiceallocation'>" +
"<attribute name='new_allocatedamount' />" +
"<filter type='and'>" +
"<condition attribute = 'new_payment' operator='eq' value='" + paymentid + "'/>" +
"</filter>" +
"</entity>" +
"</fetch>";
var fetchApplication = _oService.Fetch(sFetch, null);
var TotalAmount = 0;
if (fetchResultPayment != null) {
TotalAmount = fetchResultPayment.results[0].attributes.new_accountpaymentamount.value;
}
if ((fetchResultPayment != null) && (fetchApplication != null)) {
for (var i = 0;
i < fetchApplication.results.length;
i++) {
TotalAmount -= fetchApplication.results[i].attributes.new_allocatedamount.value;
}
}
return TotalAmount;
}
任意の提案をいただければ幸いです。