I am trying to display a warning message when the ...
# suitescript
c
I am trying to display a warning message when the user loads an item record where that item record is inactive but the script isn't working. Any thoughts?
Copy code
/**
 *@NApiVersion 2.0
 *@NScriptType UserEventScript
*/
define(['N/ui/serverWidget', 'N/ui/message','N/record'],
    function(serverWidget, message, record) {
        function beforeLoad(context) {
          if(context.type !== context.UserEventType.CREATE)
            return;
          var itemRecord = context.newRecord;
          var isInactive = itemRecord.getValue('isinactive');
          if (isInactive === 'T')
            {
              var myMsg = message.create({
                title: 'Inactive Part',
                message: 'This part is inactive',
                type: message.Type.WARNING
              });
              myMsg.show();
            }
        }
    return {
        beforeLoad: beforeLoad 
    };
});
1
c
Look at the documentation for
N/ui/message
. It only works in Client Scripts
m
In a userevent script, you can access
context.form
and then call
form.addPageInitMessage
which is the same as the N/ui/message module.
b
Checkboxes arent usually strings in ss2,
c
Thanks! I was able to get this working and I will repost the code to a new thread to help others out if needed.