RE: Can you use a variable name for fieldId in Suitescript

Hi –  i want to use a variable for fieldid in my script (i.e. name change based upon values that are established.   Can this be done??

Here is sample.. I have tried writing the variable several ways.

function execute(scriptContext) {
var texty = ‘\’custitem’;
var testtext = ‘doe_jane’;
var texty3 = ‘\”;
var fieldname = texty.concat(testtext);
var fieldname = fieldname.concat(texty3);

log.debug(‘fieldname’, fieldname);

var itemfix = record.load({
type: record.Type.INVENTORY_ITEM,
id: 488,
isDynamic: false
});

var values = itemfix.getText({fieldId: fieldname});
var values2 = itemfix.getValue({fieldId: fieldname});
log.debug(‘values’, values);
log.debug(‘values’, values2);

var values3 = itemfix.getText({fieldId: fieldname.concat(texty3)});
var values4 = itemfix.getValue({fieldId: fieldname.concat(texty3)});
log.debug(‘values’, values3);
log.debug(‘values’, values4);

//itemfix.setText(fieldname, ‘thisisatest’);

itemfix.save({
enableSourcing: true
});

happy2be Rookie Asked on May 25, 2023 in SuiteCloud.
Add Comment
2 Answers

Thanks Chris –  sadly i find that the answer is often simple and I overthink it.. 🙂

Rookie Answered on June 1, 2023.

No problem. Glad you’re sorted now!

on June 2, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.