When your REST call returns the value you want to fill in a field you use this function to set it:
setFieldValue("The_field_internal_name_of_your_field", the_value_from_your_rest_call);
Sending data to another list on save can be done by adding the HTML in a HTML section in your form, and then add this code to your Custom JS:
// Keep track of the custom function being completed
var hasSubmittedCustomHTML = false;
// Used to ensure the custom HTML is not saved multiple times if save is not hit multiple times
var isSavingCustomHTML = false;
function doSaveCustomHTML(){
// Add your custom REST call here and add the two below rows in the success/done callback from your REST call
hasSubmittedCustomHTML = true;
spjs.dffs.triggerSave();
}
function dffs_PreSaveAction() {
if(!hasSubmittedCustomHTML){
if(!isSavingCustomHTML){
isSavingCustomHTML = true;
// run your custom REST function to update another list
doSaveCustomHTML();
}
return false; // Return false to wait for the custom function to finish
}else{
// Custom HTML submitted - save item
return true; // Continue saving item
}
}
Please note that the actual HTML and the custom REST API call to save the custom HTML is not included here.
Alexander