Vishal Chaudhari
04/30/2025, 11:12 AMCeligo AI
04/30/2025, 11:12 AMAI generated answer (using internal Slack threads):To run a client script on Custom Address Entry Forms when the form is opened, you can follow these steps: 1. Create a Client Script record, but don't create a deployment for it. 2. Navigate to: Customization > Forms > Address Forms 3. Click "Edit" (or "Customize") on the active address form. 4. On the Actions tab, add a button. - Label: Some Label - Function: Name of a function in the client script file. 5. On the Custom Code tab, select your client script file. Here is a sample of how your client script might look:
javascript
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/currentRecord', 'N/record'],
/**
* @param{currentRecord} currentRecord
* @param{record} record
*/
function(currentRecord, record) {
/**
* Function to be executed after page is initialized.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.currentRecord - Current form record
* @param {string} scriptContext.mode - The mode in which the record is being accessed (create, copy, or edit)
*
* @since 2015.2
*/
function pageInit(context) {
var addRec = context.currentRecord;
var addState = addRec.getField({
fieldId: 'state'
});
var addSatateDisplay = addState.isDisabled = true;
}
return {
pageInit: pageInit
};
});
In this script, the pageInit
function is executed when the page is initialized, which is when the form is opened. This function gets the current record and the 'state' field, and then disables the 'state' 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/30/2025, 11:12 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.84632355
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.824065089
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.820845068
Celigo AI
04/30/2025, 11:12 AM