Okay im having a really annoying thing im trying t...
# suitescript
c
Okay im having a really annoying thing im trying to debug: So i have a function which iterates through a lot of items, and im having trouble with some. This is an example of an item im having trouble with: I have created and if statement, check the values of the item and thoose are fine! Except for when i try to use bomItem.custitem12 in CHECK 6.. Im using a keyvalue object which holds the SAME value as bomItem.custitem12 shows in CHECK1, but apparently when i try to pass the bomItem.custitem12 value it does not work, but when i use the string it does work... I have tried to use TOSTRING on the bomItem.custitem12 in Check5 but without any luck, does ANYBODY? have an idea on what this could be?? I have tried to debug it, but i cant seem to find a fix
And then some items Works perfectly fine???? makes no sense in my head
s
maybe something wrong with your
recordSetPricesItemObj
? If that is some object you're building up from NS record data, I'd recommend using NFT to avoid bugs.
c
What is NFT?
See nothing is wrong with the key value?
When you give the string you will get the value
d
I am guessing that for some reason the variable and the string aren't the same. possibly a trailing whitespace? Would you place a character immediately before and after the variable in CHECK 7? If there is a trailing whitespace that would reveal it. Alternatively, you could do a direct comparison between the variable and the string.
c
The whole approach is really hard to follow. You should spend some time refactoring to use IDs of some kind. You must waste so much time debugging because the names are all so similar. Also,
custitemXX
all over the place is impossible to follow
e
i agree with all of the above. ALSO, most commonly the issue here is with whitespace. Doesn’t have to be trailing/leading, it could even be somewhere in the middle. When you write to the logs it is displaying in HTML and therefore you may lose an extra space and it looks like one. Go to the Item itself, in edit mode, and copy the Item ID / Name field. You will probably see an extra whitespace character in there.
c
No whitespace, placed an "a" before and after
But this returns false
removed all whitespaces with regex, thats not it
c
You’re wasting lots of time on this. Rewrite it to use integer internal IDs?
c
how would i get the ID of the stock categroyies?
categories*
message has been deleted
I can get the id of the field, but how would i get the ID from these?? i would have to compare them by strings anyways
@CD right?
c
I literally don't know, there isn't enough information. What I'd do if I were you: 1) Change the IDs of all of the
custXXX
records to have sensible names so that it's readable by someone else that doesn't know your system 2) Post your entire script here, along with the custom record type definitions 3) Post what you are actually trying to achieve
c
my script is like 1600 lines right now
yea i could change the custitem12 to stockcategoryfield
but that would not chance anything
i would still have the same problem after
c
it would make your code maintainable
c
Yes... but that is not the problem
c
Anyway, if the reference on one record is linked to a custom record/list and isn't just freeform text, then you can use IDs
c
message has been deleted
its like this
then on a record there is a field called stockcaterogy with a dropdown with the names
c
so 197 is the category
c
yes... but if you get the value from the stockcategory field you will get the name
not the id
if i could the id somehow that would be great tho, but i dont know how
c
we literally have no way of helping you without seeing your code
c
Can i dm you
c
i'll let you ponder what i've tried to say, i've got work to do
no
c
you asked to see my code, but fair enough
c
like i said, i've got work to do. if you share it in this thread others may have time to help
c
but again, just asking how i should get an id from the stock category, that has nothing to do with my code
c
it depends on what you have done. do you want to get the internal ID from a saved search, which could be a search on the record that references the stock category, or an actual stock category search itself? or you could have loaded a record that has a reference to it. etc etc. a million different things.so it has everything to do with your code
c
i want a stock category search
so which search type do i chose
stock category is not an option
i want to search the list