I have a client script and need access to the reco...
# suitescript
m
I have a client script and need access to the record id once the record is saved - is it possible to do this?
p
saveRecord()
gets called before UEs run, and before the record is saved, so no, the ID is not available. You probably want to use a userevent script (
afterSubmit()
) instead. What are you actually trying to do?
m
I was trying to link the sales order to a case record. I already have the SO client script for other purpose - but just needed a way to access the ID.
s
There is no id on creation that a client script could retrieve. If you are running your client on an already existing record, then yes you could get the id.
You could maybe reverse the connection and save the case id to the sales order rather than saving the sales order to the case id?
m
alright, thanks. because case would be the main record where all transactions are shown, we'd need the case to be the main reporting source. the client script page init sets some defaults on the SO, could we do this in a UE before load? if so maybe we can switch to a UE instead and then try getting the SO id on afterSubmit()
s
Yea use currentRecord.id to get the id and load the corresponding record