【发布时间】:2021-08-30 11:31:02
【问题描述】:
检查paymenttype是否等于credit account[实体形式:auto_paymenttype]
然后,如果支付金额 阻止保存(弹窗无效:支付金额应低于重新支付金额)[实体形式:auto_resittype]
大家好,如果有人可以重新编码并帮助我,那就太好了。我是 D365 和 JS 的新手。基本上,我有 auto_paymenttype 和 auto_resittype 实体,它们的父级是 Payment。如何使用JS查询父调整记录。我已经提供了我当前的代码,请帮助我查看它。我已经尝试了一切,但到目前为止还没有运气。对不起我不专业的照片。但我希望你能理解它并且可以帮助我为这种情况编写代码。谢谢。
function resitApproveAmount(executionContext) {
try {
const object = {};
object.fctx = executionContext.getFormContext();
object.saveEvent = object.fctx.getEventArgs();
object.paymentamount = object.fctx.getAttribute("auto_paymentamount").getValue();
object.resitamount = object.fctx.getAttribute("auto_resitamount").getValue();
object.paymenttype = Xrm.Page.getAttribute("auto_paymenttype").getValue();
if (object.paymenttype != null) {
object.autoGUID = object.paymenttype[0].id.substring(1, 37);
}
Xrm.WebApi.retrieveMultipleRecords("auto_paymenttype", "$select=auto_name").then(
function success(result) {
for (var i = 0; i < result.entities.length; i++) {
object.auto_name = result.entities[i]["auto_name"];}
if(object.auto_name == "Credit Account"){
if (object.paymenttamount >= object.resitamount) {
alert("Payment Amount cannot be more than Resit Amount.");
object.saveEvent.preventDefault();
}
else
{object.fctx.data.save();}
}
},
function (error) {
console.log(error.message);
}
);
}
catch (error) {
console.log(error);
}
}
【问题讨论】:
标签: javascript dynamics-crm office365api