Then create lead record if internal ID matches Lin...
# suitescript
m
Then create lead record if internal ID matches Line 1.
a
so you are getting the sublist value in the item sublist of the field 'line' ?
the record itself will have an internal id, the item records will have an internal id, the lines have a lineid in the field 'line'
lineids often start at 0
but 11075 does not look like a line id, so I'm thinking your trying to look at the item's internal id? getSublistValue({ sublistId: 'item', fieldId: 'item', line: x})
m
yes items internal id
is 11075
yes that is my script
to pull the line value
a
you want the item value
m
yes that is 11075
then i want to use that value
in an if statement
to create my lead record
i can do it in 1.0 no problem
2.0 is giving me fits
a
var itemInternalId = getSublistValue({ sublistId: 'item', fieldId: 'item', line: x})
if (itemInternalId == 11075) ...
more specifically, something long the lines of rec = context.newRecord (or record.load(something))
and then it's actually more like "rec.getSublistValue()"
m
right so my rec is Objrecord.getSublistValue
1 sec
var itemLineCount = Objrecord.getLineCount({sublistId:'item'}); log.debug('itemLineCount=='+itemLineCount); for(var i = 0; i < itemLineCount; i++) { var itemsub= Objrecord.getSublistValue({line:i, sublistId:'item',fieldId:'item'}); }
Now I want to use that internal ID to create my lead record
in an if statement
so i've tried if(itemsub==11075)
and if(itemsub)
and if(parseInt(itemsub))
nothing is working though
a
I would log itemsub just to make sure you're seeing 11075...
can you be 100% confident the code is actually running? can you modify a log statement and verify it is reflected correctly? Double check the script is not inactive and the deployment is deployed - you might have a config issue in your way...
client script? UE? what's your entry point?
m
aftersubmit of SO record
yes everything is running, if i do not add the if statement, the record creates just fine
a
and you're able to see the value of itemsub in your logs as 11075?
m
yes
a
wow, it seems like you're doing it right - I'm at a loss, never had an issue with that, can you paste the entire script?
m
if(parseInt(itemsub)==11075) {
Thats the only other part
var Objrecord = context.newRecord; var recordid=Objrecord.id; var salesOrder = context.newRecord; log.debug('recordid=='+recordid);
That's the beginning
a
use three backticks around your whole script and paste it all (```) at the beginning and at the end
m
ill try a few things
thank you for your help
I appreciate it