darrenhillconsulting
11/05/2024, 7:10 PMCeligo AI
11/05/2024, 7:10 PMAI generated answer (using internal Slack threads):Based on the conversations, you can create a client script using TypeScript and SuiteScript 2.1 to show or hide a field in VIEW mode. However, it's important to note that client scripts do not run in view mode. Therefore, you would need to hide the fields in a beforeLoad UserEvent. Here is a sample code snippet that you can use as a reference:
typescript
import { EntryPoints } from 'N/types';
import * as record from 'N/record';
import * as serverWidget from 'N/ui/serverWidget';
export function beforeLoad(context: EntryPoints.UserEvent.beforeLoadContext) {
if (context.type !== context.UserEventType.VIEW) return;
const form = context.form;
const myField = form.getField({ id: 'custbody_myfield' });
const value = context.newRecord.getValue({ fieldId: 'custbody_myfield' });
if (value === 'hideme') {
myField.updateDisplayType({ displayType: serverWidget.FieldDisplayType.HIDDEN });
} else if (value === 'showme') {
myField.updateDisplayType({ displayType: serverWidget.FieldDisplayType.NORMAL });
}
}
In this script, we are using the beforeLoad
user event to check the value of the field 'custbody_myfield'. If the value is 'hideme', we hide the field. If the value is 'showme', we display the field.
Remember to replace 'custbody_myfield' with the actual id of your 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
11/05/2024, 7:10 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.858540773
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.852573633
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.845475495
Celigo AI
11/05/2024, 7:10 PM