```@NScriptType UserEventScript var field = scrip...
# suitescript
s
Copy code
@NScriptType UserEventScript

var field = scriptContext.form.addField({
            id: 'custpageinjectcode',
            type: 'INLINEHTML',
            label: 'Inject Code'
});
field.defaultValue = "<script> ...var desiredText = document.querySelector(...).innerText; alert(desiredText);'jQuery(function($){ require(['/SuiteScripts/clientSuiteScript.js'], function(mod){ mod.pageInit();});});'</script>"
Copy code
@NScriptType ClientScript

function (currentRecord) {

        function pageInit() {
            window.addEventListener("message", browser_ReceiveMessage, false);
            console.log('Added Listener...');

        }

        return {
            pageInit: pageInit
        }


        function browser_ReceiveMessage(event) {

            var curRec = currentRecord.get();
            console.log('Current Record ID', curRec.id)
        }//end function

    }//end main function

);//end script
How would I go about passing the 'desiredText' variable result in UserEventScript (the scraped data) to the ClientScript so that I can place it into a normal text variable and use it on the form?
b
it doesnt even look like the desiredText's value is from the user event script
e
Create a function that consumes desiredText as a parameter in your client script and reference it as mod.SomeFunction(desiredText) instead of mod.pageInit()
s
Ahh, okay. I'm outside my domain here, so I greatly appreciate your help.
b
you are doing some very weird things
s
Yes, it's hacking the DOM.
b
i would just start with adding your client script via https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4625445350.html
then do your desiredText logic in the pageInit entry point