if you need to get value from any field into the portal and set other field values you can use this script
$(document).ready(function(){
$('#student_couponcode').on('change',(studenteventdiscountamount) => {
debugger;
var eventcouponcode = studenteventdiscountamount.target.value;
var eventcouponcodefilteroption = "student_couponcode eq '"+eventcouponcode+"'";
var odataUrI = "https://yourportal.com/_odata/student_discounts?$filter="+encodeURIComponent(eventcouponcodefilteroption);
$.ajax({
type:'GET',
contentType: 'application/json; charset=utf-8',
datatype: 'json',
url: odataUrI,
beforeSend: function(XMLHttpRequest){
XMLHttpRequest.setRequestHeader('Accept', 'application/json');
},
async: true,
success: function(data, textStatus, xhr){
if(data.value[0])
{
if(data.value[0].student_eventid.Id==eventGuid){
var couponcodediscountamount = data.value[0].student_amount;
$('#student_eventcoupon').val(couponcodediscountamount);
}
else {
$('#student_eventcoupon').val(defaultAmountValue);
}
},
error: function (xhr, textStatus, errorThrown ){
alert(textStatus+ ''+errorThrown);
}
});
});
});
Comments
Post a Comment