<@U5TF1GQ20> My Field change searches a bin record...
# suitescript
s
@battk My Field change searches a bin record based on the value entered in the text field!
b
then you are likely receiving a permission related error
the employee role you are using probably does not have access to inventory
you can probably get more details if you log the error properly
s
I tried to stringfy the error and log it.. but I can't get any other information.
b
what does your try catch look like
s
try{
b
backtick ` used like quotes makes it pretty
s
try{ var searchResults = nlapiSearchRecord('bin', null, filters, columns); checks if the entered bin exists or not! }catch(e){ alert("Error in FieldChange: " + JSON.stringify(e.toString())); console.log(JSON.stringify(e.toString())); }
b
thats not how you want to log errors
s
it is a client script
b
e.toString is always "[object Object]"
s
ohh okay
console.log(JSON.stringify(e)); this is good right?
b
good enough
s
I will try and let you know.
code":"INSUFFICIENT_PERMISSION","details":"Permission Violation: You need the 'Lists -> Bins' permission to access this page.
b
as you can probably guess your role is missing that permission
s
Is there a way to give Employee Center roles access to bins?
b
does not look like it
you might need to use a server side script like a suitelet to get your data
s
So you're saying, I can get the bins data in suitelet and use it in clientscript??
b
use the client script to request data from a suitelet
s
So, What is the best way of doing it? getting the list of all bins at once in suitelet and requesting that data in client script?
b
potentially, depends on how many bins and how fast you need it
s
I have lot of bins.
b
just time how long it takes to run a search that gets all bins and one that gets 1. Pick the one that works for your use case
s
Thanks buddy... I will try it.
message has been deleted
I'm trying to scan a bin number, validate it on the Suitelet and getting the data back to client script. But I don't know how to do it, could you please help me out.
b
what part are you stuck on.
s
So every time I scan a bin number to "To bin" field, it submits the page.. is there a way I can do without submitting it?
b
i can't help you with your scanner
s
I tried this, jQuery('input[type=text]').keypress(function(event) { if (event.which == 13) { event.preventDefault(); return false; } }); and now it doesn't submit. if it doesn't submit how to access the data from suitelet to client script?
b
its the other way around, use the client script to make a https request to the suitelet
s
I don't know how to do it. is there any example I can refer to?
b
it would be very similar to the help Example: Client Script that Calls a RESTlet
you can probably use a restlet instead of a suitelet if you really wanted to
s
Ohh okay... it makes sense now.. Thank you buddy.
Thanks for the advice buddy. I got everything working now.