To check if paymenttype equal credit account [entity form: auto_paymenttype
Then , if payment amount <= resit amount, it will save else > prevent save (popup message invalid: payment amount should lower than resit amount)[entity form: auto_resittype
Hi guys, It could be great if someone could re-code and help me on this.I am new in D365 and JS. Basically, I have entities which is auto_paymenttype and auto_resittype and their parent is Payment. How can I query the parent adjustment record using JS. I have provide my current code, please help me to review it. I have try everything but so far no luck. Sorry for my unprofessional picture. But I hope you understand it and could help me to code for this situation. Thank you.
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); } }
Hi Fahran, this was originally posted to Dynamics 365 Guides, which is a mixed reality product for holographic training. I will move your posting to the CRM forum where it should get better visibility.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156