Solution to: Display message to user that the item...
# suitescript
c
Solution to: Display message to user that the item record they are viewing is INACTIVE. Previous Post: https://netsuiteprofessionals.slack.com/archives/C29HQS63G/p1629212384177100 I figured I would post my code here to help others that wish to do the same. This will display a message telling the user that the part is INACTIVE anytime the record is loaded. I've commented out the part telling them when it is active. Just deploy this to the item type (possibly other record types too) of your choosing and specify the audience you want to have it display for. (I specified All Roles)
Copy code
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/record','N/ui/serverWidget', 'N/ui/message'], function( record, serverWidget, message) {
	function myBeforeLoad(context) {
		if(context.type !== context.UserEventType.CREATE){
            var form = context.form;
			var inactiveStatus = context.newRecord.getValue('isinactive');
          	var myItem = context.newRecord.getValue('itemid');
			if (inactiveStatus === true){
              var messageObj = message.create({
                title: '**INACTIVE ITEM**',
                type: message.Type.ERROR,
                message: 'The item ' + myItem + ' is INACTIVE!',
                //duration: 10000
              });
              form.addPageInitMessage({message: messageObj});
              }//else{
                //var messageObj = message.create({
                  //title: '**ACTIVE ITEM**',
                  //type: message.Type.CONFIRMATION,
                  //message: 'The item ' + myItem + ' is ACTIVE!',
                  //duration: 10000
                //});
                //form.addPageInitMessage({message: messageObj});
              //}
          }
		}
		return {
			beforeLoad: myBeforeLoad
		}
	});