Hi all, I'm building my first script to show a mes...
# suitescript
s
Hi all, I'm building my first script to show a message on a SO when a line item is added where a field value = X and I can't seem to get it to work. I got some ideas from Oracle docs but this doesn't seem to work https://pastebin.com/jXFqF5HH General guidance much appreciated!
m
You can only use
nlapiGetCurrentLineItemValue
to retrieve field values on the current record. If you want to look up item fields, you will need a lookup (e.g. nlapiLookupField)
Copy code
var itemId = nlapiGetCurrentLineItemValue('item', 'item');
var lifeCycle = nlapiLookupField('item', itemId, 'custitem_product_lifecycle');
if(lifeCycle === 'EOL (End of Life)') { ... }
s
Legend, will look into that this afternoon
m
Side note - strongly recommend you learn SuiteScript 2.x instead. SuiteScript 1 is pretty much deprecated
👍 1
s
Thanks. I've only recently started learning Js with no prior scripting experience so everything is a challenge right now 😕
e
may as well though learn 2.0, it’s not like you’re going to gain more or do it more easily by learning an antiquated version…