Hi everyone,
I am building a portal and have a form with a submit button that allows the user to input a price (in a field named NewPrice within a table named RequestLine). When the user hits Submit and the record is saved, I would like to capture the price inputted by the user and send it as part of an api request to an external system.
What I have done so far is as follows;
- In the Basic Form where the user can input the new price I have added the below javascript that calls a web page that does a fetchxml to retrieve the modified record from dataverse and returns the field NewPrice. (For now I'm just exposing the result of the fetchxml in an alert just to see the returned value.). The problem with this is that the record wouldn't have saved the new value yet and the previous value of the field NewPrice is retrieved, example;
if the value in the field is 5.00 and the user opens the form, changes the value to 8.00 and Submits the form, the value of 5.00 is still being retrieved.
$(document).ready(function() {
$("#UpdateButton").on("click", function() {
alert('yooo');
debugger;
var recodId = $("#EntityFormControl_EntityFormView_EntityID").val();
$.ajax({
method: 'GET',
dataType: 'json',
url: "/returnprice?recordid=" + encodeURIComponent(recodId)
}).done(function(data) {
console.log(JSON.stringify(data.results));
alert(data.results);
})
});
});
Is it possible to move such javascript to run On Success of the form i.e. when the form has been fully submitted and the record fully updated?
Thanks in advance!