This topic contains 4 replies, has 0 voices, and was last updated by j.j 6 years, 11 months ago.
-
AuthorPosts
-
October 5, 2017 at 11:09 am #18239
NateSI created a client script that prompts the user with an alert when a custom field that I created within the sales order is checked/true. Everything is fine if the logic of the script isn’t triggered based on the custom field. But when the custom field is checked the alert displays as expected, but then after editing the sales order and unchecking the box I can’t save the record. I can’t save it even if I reload the page and try again, or even if I deactivate the script and reload the page and try to save it. The only way for me to actually be able to save the sales order after this has happened is for me to go into my browser and clear the cache, then I can save the record again. What I mean by I can’t save the record is that when I click on save nothing happens, it just sits on that page. Below is my script.
Code:
/**
*@NApiVersion 2.0
*@NScriptType ClientScript
*/define([‘N/ui/dialog’],
function(dialog) {
function verifyPrice(context) {
var currentRecord = context.currentRecord;
// var fieldName = ‘custbody_verify_price’;if(currentRecord.getValue(‘custbody_verify_price’) == true){
var options = {
title: ‘VERIFICATION NEEDED’,
message: ‘Prices don’t match’
};try {
dialog.alert(options);
log.debug ({
title: ‘Success’,
details: currentRecord.getValue(‘transid’)
});} catch (e) {
log.error ({
title: e.name,
details: e.message
});
}}
}
return {
saveRecord: verifyPrice
};
});
This is a cached copy. Click here to see the original post. -
October 5, 2017 at 11:39 am #18240
Vesku1980Save function needs return True to be executed.
NateS replied on 10/05/2017, 11:44 AM: So I can just add an else {return true}?
-
October 5, 2017 at 12:05 pm #18241
pcutlerExactly:
if(currentRecord.getValue(‘custbody_verify_price’) == true){ …} else { return true; }
-
October 5, 2017 at 12:06 pm #18242
pcutlerAlso, you should return false in the case that you do want to prevent the save operation.
-
November 28, 2017 at 12:16 am #18243
j.jon this same topic i am using dialog.confirm(options) – if ok then save the record, issue is dialog.confirm returns a promise object, if i use callback then return true does not work. here is the code :
function success(result) {
if (result)
{alert(“Oked ” + result);
return true;}
else
{alert(“Cancelled ” + result);
return false;}
}
function failure(reason) {
alert(“Failure: ” + reason);
return false;
}
dialog.confirm(options).then(success).catch(failur e);
-
AuthorPosts
You must be logged in to reply to this topic.