Thursday, September 20, 2018

Prevent a record from being submitted/saved in the database

Customer wants to prevent the Sales Order from being approved by users depending on some criteria. Currently there is no way to disable the Approve button in the Sales Order.


The workaround is to create a User-Defined Error and throw this on the Before Submit function of the Sales Order.

function cancelSubmit(type)
{
if(type=='approve')
{
   var err = nlapiCreateError('E1001', 'You are not allowed to approve this Sales Order');
   throw err;
}
}
 

 

No comments:

Post a Comment