darrenhillconsulting
08/22/2024, 2:57 AMCeligo AI
08/22/2024, 2:57 AMAI generated answer (using internal Slack threads):To set default values on a transaction type record based on the subsidiary id using SuiteScript 2.1 in a User Event script, you can use the
beforeLoad
function. This function is triggered before the record is loaded into the UI.
Here is a sample code snippet that sets the subsidiary field value:
javascript
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(["N/record"], function (record) {
function beforeLoad(context) {
if (context.type !== context.UserEventType.CREATE) {
return;
}
var newRecord = context.newRecord;
var subsidiaryId = newRecord.getValue({ fieldId: "subsidiary" });
// Set default values based on subsidiary id
if (subsidiaryId === '1') {
newRecord.setValue({ fieldId: "taxschedule", value: "1" });
newRecord.setValue({ fieldId: "custitem_fa_amz_flag01", value: 1 });
}
}
return {
beforeLoad: beforeLoad,
};
});
In this script, we first check if the event type is CREATE
. If it is, we get the subsidiary id from the new record. Then, based on the subsidiary id, we set default values for the taxschedule
and custitem_fa_amz_flag01
fields.
Please note that you need to replace '1'
, "taxschedule"
, "1"
, "custitem_fa_amz_flag01"
, and 1
with your actual subsidiary id and the default values you want to set.
******
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/22/2024, 2:58 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.854610562
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.833664417
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830244958
Celigo AI
08/22/2024, 2:58 AM