0

I am trying to reset password with following script

/*
 *@NApiVersion 2.0
 *@NScriptType ClientScript
 */
require(['N/auth'],
 function(auth) {
 function changePass() {

                var password = '111';

                auth.changePassword({
                    currentPassword: password,
                    newPassword: '222'
                });

                 return 'ChangeDone';
 }


});

and i run it as RESTlet in SOAPUI

i receive this error:

error code: REFERENCE_ERROR error message:ReferenceError: "require" is not defined

Help Please!!

1 Answers1

1

You need to replace require with define.

See RequireJs - Define vs Require.

Due to the way NetSuite uses the AMD framework, it can be confusing to follow from the documentation, but in general you use define() in a script and only use require() when testing functions in a browser console.

Krypton
  • 4,394
  • 2
  • 9
  • 13
  • error code: REFERENCE_ERROR error message:ReferenceError: "define" is not defined – Maxim Makarovsky Jul 12 '18 at 13:15
  • I have to say this isn't the conclusion I would have jumped to. More likely OP has found a snippet on the internet and doesn't realise they need to load the requirejs script. Besides, I thought `define` and `require` came in the same package. – David Knipe Jul 12 '18 at 13:34
  • @DavidKnipe you're right. I was answering from my experience of NetSuite, and the fact that the script above is clearly written as a NetSuite script. Now looking closer I see that he's running it in SOAPUI, which I don't know anything about. Looking at the NetSuite documentation I also see this is the sample they give for their N/auth module. Not sure why OP's attempting to test it with SOAPUI as you can run these through the NetSuite framework, but not loading require.js does seem like the problem (NetSuite handles all that for you if you use their system). – Krypton Jul 12 '18 at 15:31