This message was deleted.
# suitescript
s
This message was deleted.
b
use the parent of the iframe to access the transfer order page
from there, i usually recommend using the parent require function to get access to N/currentRecord
d
How can I use this ? window.parent and where do i put the requite function?
b
window.parent gives access to the window global of the transfer order
that window has a require function as one of its properties
d
let parent = window.parent;
let record = parent.require('N/currentRecord')
like this?
b
parent is a terrible variable name, it shadows the parent in the global scope
d
Ye i know just for the solution
so thats how it should works
?
b
thats also not how you want to use the require function, you want the amd version instead
you may be able to get away with the the common js version of require if N/currentRecord is already loaded
d
parent.require (['N/currentRecord']); var currRec = require ('N/currentRecord'); var record = currRec.get(); ?
b
there is no difference between your first version and the second
both will fail if N/currentRecord is not already loaded
d
So i dont get this...
b
the amd version of require is very similar to the define function
go though the documentation to see how the second parameter is used
d
the examples there are not enough for me
b
how well do you know callback functions
d
I know.
b
just like a define function, the second parameter of the require function is a callback function where the parameters of the function are the dependencies specified in the first array parameter of the require function
d
I did this
Copy code
window.parent.require(['N/currentRecord'], function (currRec) {
    currRec = currRec.get();
    toLocation = currRec.getValue('transferlocation');
})
And its gets the value, but the issue here is the value cannot get out of the scope of the parent.. also if i assign it before
b
callbacks are asynchronous, you need to use techniques suitable for asynchronous code
d
its seems to be too complicated for just getting a value of a field... how can i do that in inventory transfer and not in transfer order
b
an inventory transfer is a single transaction, its inventory detail needs to handle fulfillment and receiving, so its url includes both locations
transfer order is multiple transaction, its inventory detail only needs to handle fulfilling, so it only needs to handle the from location
d
thats not make sense to me... there must be better option to get the values of parent record
c
May I ask what your script is going to achieve?
d
I just need to check the 'transferlocation' field of transfer order and then make a validation on validateLine ... '
in the inventory detail subrecord
b
the cheap and somewhat question approach is to use suitescript 1, which is synchronous
d
thats not an option..
b
suitescript 1 functions are all global
they are available on the window, even if you use suitescript 2
you can also deploy a client script on the transfer order to make sure N/currentRecord is loaded beforehand so that you can use the synchronous common js version of require
d
i know that solutions... but still its not make sense that i need to make another scripts for getting this...
also with window.parent
b
the reason your version worked was that netsuite put the information you wanted in the url of the inventory detail iframe
thats not an option for the transfer order since netsuite doesnt put it in the url
c
Usually when it's hard to do something & requires workarounds, it means that what you're doing isn't really common
😅 1
d
I know ite not realy common, but I need it.