mesper
11/04/2024, 11:32 AMCeligo AI
11/04/2024, 11:32 AMAI generated answer (using internal Slack threads):Sure, you can add two conditions to check if the record is created from a purchase order and if the subsidiary on the record is 1. Here's how you can modify your script:
javascript
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/record', 'N/log'], function(record, log) {
function beforeLoad(context) {
try {
// check if the record is being created for the first time
if (context.type === context.UserEventType.CREATE) {
// get the current record
var currentRecord = context.newRecord;
// check if the record is created from a purchase order and if the subsidiary on the record is 1
if (currentRecord.type === record.Type.PURCHASE_ORDER && currentRecord.getValue('subsidiary') === 1) {
// check the "landedcostperline" field
currentRecord.setValue({
fieldId: 'landedcostperline',
value: true
});
}
}
} catch (e) {
log.error({
title: 'Error setting landed cost per line to true',
details: e
});
}
}
return {
beforeLoad: beforeLoad
};
});
This script will only set the 'landedcostperline' field to true if the record is a purchase order and the subsidiary is 1.
******
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/04/2024, 11:32 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.891151309
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.860609412
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.858237326
Celigo AI
11/04/2024, 11:32 AM