Aaron R
08/28/2024, 6:54 PMCeligo AI
08/28/2024, 6:55 PMAI generated answer (using internal Slack threads):To prevent the current user from being included in a custom field that is a list/record type and Employee list/record on a transaction, you can use a SuiteScript User Event script. This script would run on the record in question and pull the context of the current user. Here's a general idea of how you could approach this: 1. Create a User Event script that triggers before the record is loaded. 2. In the script, get the context of the current user using
runtime.getCurrentUser()
.
3. Then, get the field that you want to filter using context.newRecord.getField({fieldId: 'your_field_id'})
.
4. Use the field.removeSelectOption
method to remove the current user from the list.
Here's a sample code snippet:
javascript
define(['N/runtime'], function(runtime) {
function beforeLoad(context) {
if (context.type !== context.UserEventType.CREATE)
return;
var currentUser = runtime.getCurrentUser().id;
var employeeField = context.newRecord.getField({fieldId: 'custbody_employee'});
if (employeeField) {
employeeField.removeSelectOption({value: currentUser});
}
}
return {
beforeLoad: beforeLoad
};
});
This script will remove the current user from the 'Employee' field when creating a new record. Please replace 'custbody_employee'
with your actual field ID.
******
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
08/28/2024, 6:55 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851053238
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.839047194
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834946871
Celigo AI
08/28/2024, 6:55 PM