Jordan Patterson
04/15/2025, 10:51 PMCeligo AI
04/15/2025, 10:52 PMAI generated answer (using internal Slack threads):To disable the Units sublist field on sales orders for users who are not admin, you can use a User Event Script (UES) with a beforeLoad event. Here is a step-by-step guide: 1. Create a User Event Script and set the event type to beforeLoad. This event type allows you to manipulate the form before it is presented to the user. 2. In your script, you will need to get the current user's role. You can use the
runtime
module's getCurrentUser()
function to get the current user's details, and then use the role
property to get the user's role.
3. If the user's role is not admin, you can then get the sales order form and the Units sublist field. You can use the Form.getSublist()
method to get the sublist, and then the Sublist.getField()
method to get the field.
4. Once you have the field, you can use the Field.updateDisplayType()
method to set the display type to disabled. This will make the field uneditable for the user.
Here is a sample code snippet:
javascript
var runtime = require('N/runtime');
function beforeLoad(context) {
var user = runtime.getCurrentUser();
if (user.role !== runtime.Role.ADMIN) {
var form = context.form;
var sublist = form.getSublist('item');
var field = sublist.getField('units');
field.updateDisplayType({displayType: 'disabled'});
}
}
exports.beforeLoad = beforeLoad;
Please replace 'item' and 'units' with the actual IDs of your sublist and field.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
04/15/2025, 10:52 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.828667283
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.822632134
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.820831895
Celigo AI
04/15/2025, 10:52 PM