Restrict roles from selecting values from a field by showing alert

function performTradePartnerOrderValidation(currentRec) {

     

      try{

        let newsalesOrderType = currentRec.getValue({

          fieldId: ‘custbody52’

        });

        if(salesOrderType == SALES_ORDER_TYE_OBJECT.TRADE_PARTNER_ORDER && salesOrderType != newsalesOrderType && mode == ‘edit’ && !Object.values(TRADE_PARTNER_ORDER_LOCK).includes(role)) {

          alert(“You cannot change the trade partner order. Please contact Administrator for details.”);

          currentRec.setValue({

            fieldId: ‘custbody52’,

            value: salesOrderType

          });

          return false;

        }

        return true

      }

      catch(err) {

        console.error(‘error@performTradePartnerOrderValidation’, err)

      }

    }

Leave a comment

Your email address will not be published. Required fields are marked *