Is it possible to load a sales order via the trani...
# suitescript
c
Is it possible to load a sales order via the tranid rather than internal id?
l
Why you need this?
c
I need to find the sales order associated with a customer desposit
the cust deposit record has the sales order transaction ID in a field but not the internal ID
l
Is a custom field?
c
so when the deposit is saved, I can load the sales order via tranid and update some fields there
Standard field
l
I don’t have my laptop with me now. But I think you can get us
Id*
c
I can do it via a saved search - was hoping to not do that though
l
Can you show me how you get that field value in script?
c
var salesOrderTransID = record.getValue({ name: ‘salesorder’ });
l
If your using user event, I think is something like context.newRecord.getValue(“createfrom”)
c
how will that give me the internal ID of the salesorder?
if I’m on the customer deposit
l
It should give you the internal if
Id*
c
of the sales order?
even though I’m not creating a sales order
and I’m not in the sales order?
l
Can you help me print that value using log.debugger?
c
yeah, was just loading the debugger domain 🙂
I’ll have to edit the script to work in the debugger
l
Yes, that what I believe. That is a list/record field type, if you using getValue you will get internal id; if you using getText you will get Tran Id
c
as I’ve not run it in NS yet
so why will it return the sales order ID?
and not the customer deposit ID?
l
It’s a list/record field type
c
I’m creating the record from the sales order
if that makes a difference?
So i’m told that means it’s not a list/record
pressing the button ‘create deposit’ on the sales order
l
Doesn’t make any difference I think, but you can try first
c
illegal character (adhoc$-1$debugger.user#14)
line 14: var test = context.newRecord.getValue(“createfrom”);
works if I remove .getValue(“createfrom”);
r
you should use salesorder id if you are creating customer deposit from sales order
c
message has been deleted
That’s all I can see on the record
r
var test = context.newRecord.getValue(“salesorder ”);
try this one
c
ahh that seems to work
the debugger runs but it steps straight into the code
shouldn’t it wait for a new record to be created?
r
can you share your code again
c
I haven’t deployed the script - just running it from the debugger
r
sorry i do not use debugger. I just deploy the script in testing mode and then test
c
You should look into the debugger - you’re missing out!
r
i used to use it with Suitescript 1.0 but with 2.0 it is little tedious to use the debugger
c
yeah it can be
r
you can use NetSuite Show Field IDs chrome extension to find the NetSuite field ids.
c
looks like deleting a deposit also triggers the script?
yeah I use that extension already
r
can you share your code
c
it’s in the main window
in slack
test = undefined
Looks like it didn’t get any data?
Ignore the trigger on delete - that’s not happening now
r
have you deployed your script on customer deposit record
c
yeah
I can see the context does include salesorder
not sure why it returned undefined
will try again - could just be the way I was using the debugger - the script exits on that line
it’s a crappy debugger really
got it working
r
yeah it is. Better to deploy the script in testing mode and then test it
c
so that should be the sales order internal id
thanks 😄
r
you are welcome