Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Javascript lookup related entity

$
0
0

Hi all, 

To start off, I have two custom entities and I've configured an HTML button calling a little bit of Javascript below

<html>
<body>

<button onclick="ManualPayment()";>Create Manual Payment</button>

<script>
//when button is clicked, show the fields to make manual payment.
function ManualPayment() {
window.parent.Xrm.Page.data.entity.save();
window.parent.Xrm.Page.getAttribute("new_reservationpaymentmethod").setValue();
window.parent.Xrm.Page.getAttribute("jucy_paymentspecifyamount").setValue();
window.parent.Xrm.Page.data.entity.save();
}
var PaymentAmount = window.parent.Xrm.Page.getAttribute("jucy_paymentspecifyamount");
//if the field contains data still, clear field again and save
if (PaymentAmount !=null)
window.parent.Xrm.Page.getAttribute("jucy_paymentspecifyamount").setValue();
window.parent.Xrm.Page.getAttribute("new_reservationpaymentmethod").setValue();
window.parent.Xrm.Page.data.entity.save();
</script>

</body>
</html>

This particular piece of HTML sits on one of the entities which we call Reservations. The second custom entity, is call Payments.

What I'd like to be able to perform is when the event handler is triggered with this button, perform a check with this button, whereby it gets all related Payments and subtracts the balance taken against the Reservation. 

I'm hoping one of you have some Javascript that might help accomplish this. 

Cheers


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>