pnv_mat
12/04/2024, 9:04 AMCeligo AI
12/04/2024, 9:04 AMAI generated answer (using internal Slack threads):Based on the conversations, it seems that you can control the options in a multiselect field based on a Saved Search or SuiteQL in a script. However, this would require hiding the actual field in the BeforeLoad event and adding a custom multiselect field where you add your options. In the BeforeSubmit event, you would then copy the selection to the actual field. Here is a general idea of how you can do it: 1. In the UserEvent BeforeLoad script, hide the actual field and add a custom multiselect field with the options you want to show. You can use SuiteQL to get the options you want to show.
javascript
function beforeLoad(context) {
if (context.type !== context.UserEventType.CREATE && context.type !== context.UserEventType.EDIT) {
return;
}
var form = context.form;
var field = form.getField({id: 'your_field_id'});
field.updateDisplayType({displayType: 'hidden'});
var customField = form.addField({
id: 'custpage_custom_field',
type: 'MULTISELECT',
label: 'Custom Field'
});
// Add options to the custom field based on SuiteQL or Saved Search
var options = getOptions(); // Implement this function to return the options you want to show
options.forEach(function(option) {
customField.addSelectOption({
value: option.id,
text: option.text
});
});
}
2. In the UserEvent BeforeSubmit script, copy the selection from the custom field to the actual field.
javascript
function beforeSubmit(context) {
var record = context.newRecord;
var customFieldValue = record.getValue({fieldId: 'custpage_custom_field'});
record.setValue({fieldId: 'your_field_id', value: customFieldValue});
}
Please replace 'your_field_id' and 'custpage_custom_field' with your actual field ID and custom field ID respectively.
******
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
12/04/2024, 9:04 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.82233727
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.819432139
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.815506697
Celigo AI
12/04/2024, 9:04 AMCeligo AI
12/04/2024, 9:06 AM