I have a search on a script that works fine for me...
# suitescript
p
I have a search on a script that works fine for me (as an admin) but for other users I am getting the following error:
SSS_INVALID_SRCH_OPERATOR An nlobjSearchFilter contains an invalid operator, or is not in proper syntax: internalid.
Code is as follows:
Copy code
function pageInit(context) {
      var rec = currentRecord.get();
      var myID = rec.getValue({fieldId: 'id'});
      var bkStatus = rec.getValue({fieldId: 'status'});

      var mySearch = search.create({
        type: "salesorder",
        filters:
        [
           ["type","anyof","SalesOrd"], 
           "AND", 
           ["unit","anyof","2"], 
           "AND", 
           ["internalid","anyof",myID]
        ],
        columns:
        [
           search.createColumn({name: "quantity", label: "Quantity"}),
        ]
      })
I used the Chrome Export Script extension to get the code so assume it was correct but apparently it is not. Note: At the beginning I did have the
var myID = fieldID: 'internalid'
but I have since corrected that. Is it possible cached on the other users browser?
w
It could be possible, yes.
as someone else said. You don't need to do rec.getValue({fieldId: 'id'}), rec.id is enough, but that doesn't matter here.
s
@Watz when would you use currentRecord.get() and use the currentRecord module? isn't the currentRecord always available and accessible in the context in the CS? like in context.currentRecord?
w
🤷‍♂️
😂 1
Sounds reasonable 🙂
😄 1
🙌 1
s
I mean this script is alright, but on create I'm pretty sure it's gonna break because rec.id won't be accessible
👍 2
p
@Sciuridae54696d I think that is the reason I am seeing that error pop up.
s
@pen one try adding a condition which limits the script only to run when it's not on create (at least this part. this will prevent the error, but you gotta also think about when it should execute, CS will only execute when not on view mode. (as opposed to UE)) in your case where the argument in your pageInIt is context, i.e pageInit(context)
Copy code
if(context.mode!=create){
//the body of the code
}
something like that will stop the error (crossed fingers)
p
Thanks. Exactly what I did.
🎉 1
s
great! 🙂