hi everyone, so in the beforeSubmit of an UE, can ...
# suitescript
m
hi everyone, so in the beforeSubmit of an UE, can we not loop through the promotions sublist and grab values like we do the items sublist? I successfully grab the promotions line count. I then set a little
for loop
, like i've done many times for the items sublist, and want to grab the promo code, like this:
promoCode = newRecord.getSublistValue({
sublistId: "promotions",
fieldId: "couponcode_display",
line: i
});
I have be overlooking something obvious here. Any help is appreciated
e
couponcode_display
looks a strange ID to me. Based on the Record Browser for a Sales Order, I'd expect to retrieve the
couponcode
field or the
promocode
field.
And if you want the text instead of the ID, you can try
getSublistText()
instead of
getSublistValue()
m
I rely heavily, probably too heavily on the NS Field Explorer chrome extension to get field ids. Maybe couponcode_display isn't going to return in a script. It wouldn't be the first time i've encountered that. That said, I changed the field id just to
promocode
and left it as value because I could use about anything here as long is it sets the promocodes apart. Thanks for responding. Let me try
promocode
again and with the get text and get val calls . . .
ran it again like this:
promoCode = newRecord.getSublistValue({
sublistId: "promotions",
fieldId: "promocode",
line: i
});
It doesn't return anything. And from the records browser, this is what I should be able to get, yes?
and this line works:
var promoLineCount = newRecord.getLineCount({ sublistId: 'promotions' });
it returns the number of promo lines. but I cant get any promo sublist value to return
a
Brute force it... Use
getSublistFields()
It will show you all the available fields... then go from there.
m
@alien4u oh hey, thanks, I will keep that in mind! that said, I am chalking this one up to tired eyes and a long week. My code above seemed to just start working. No idea... I didn't really change anything, but clearly something changed. Maybe I had a little typo somewhere. Long week. Thanks everyone for the help!