I am reaching out to inquire about updating the `d...
# suitescript
m
I am reaching out to inquire about updating the
department
field on a currency revaluation record using SuiteScript 2.0. I am using the
record.submitFields
method in a scheduled script to update this field, but it does not seem to apply the change. Other fields, such as
smemo
, are updating successfully, so it appears there might be a restriction specific to
department
on this type of record.
```define(['N/search', 'N/record'], function (search, record) {
function myScript(context) {
try {
var useSearch = search.load({ id: 'customsearch_testing_cr' }); // Saved Search ID
var mResultsSet = useSearch.run();
var useSearchResult = mResultsSet.getRange({ start: 0, end: 1000 });
for (var abc = 0; abc < useSearchResult.length; abc++) {
try {
var results = useSearchResult[abc];
var useId = results.id;
var useRecType = results.recordType;
record.submitFields({
type: useRecType,
id: useId,
values: { department: 1 } // Updating 'department'
});
} catch (exp2) {
log.error({ title: 'Loop Error:', details: exp2 });
}
}
} catch (exp) {
log.error({ title: 'Script Error:', details: exp });
}
}
return { execute: myScript };
});```
v
Is the period locked? That's a GL impacting change. Also, not sure you should be updating those internal records yourself - do they not inherit segments from the transactions they are created from?
m
Normally yes, they are supposed to be inherited from the payment transaction department. However, the customer doesn't want to have analytics on the balance sheet accounts, only on the profit and loss p&l accounts.
the period is open