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
});
Thanks Chris – sadly i find that the answer is often simple and I overthink it.. 🙂
No problem. Glad you’re sorted now!