The solution is pretty simple, like we do it for other web pages by using the ‘windows.opener
Basically, you just need to take care of calling this ‘windows.opener‘ property from the ‘GET’ part of the Suitelet script, as it won’t work in the ‘POST’ part. Or we can say, from where the script will run (client-side or server-side), this property works only for those scripts running from the client-side (Client Script).
Suppose, you need to pass those data from the child form to the parent form when you click a submit button on the child form and for this you are using the Netsuite form’s submit button in that Suitelet like:-
As we know, when the submit button will be clicked, it will execute the logic for ‘POST’ part (if any) written in the Suitelet script. But, this script will run in the server-side, for which, you won’t be able to use this ‘windows.opener‘ property for passing data to the parent form. We do have a solution for this, by just using a simple form button in place of the submit button and trigger a client function in its OnClick event like:-
form.addButton(‘btnsubmit’, ‘Submit’, ‘UpdateParentForm();’);
For calling this ‘UpdateParentForm()‘ function you need to create a client script with a .js file containing this function and then attach that client script to the child form like:-
Now, when the user will click the button in the child form, it will call the client script function and the script will run in the client-side. So, here in the ‘UpdateParentForm()‘ function we can use the ‘windows.opener‘ property to pass data from child form to the parent form like:-
In the above code, ‘windows.opener‘ calls the ‘nlapiSetFieldValue‘ Netsuite API for the parent form to set the value in ‘custpage_getfromchild‘ field present in that form and ‘nlapiGetFieldValue‘ Netsuite API is called for the child form and gets the field value of ‘custpage_passthisvalue‘ present in the child form.