Hello, when I try to create a new contact record ...
# suitescript
j
Hello, when I try to create a new contact record using restlet, I am getting
Copy code
"TypeError: Cannot call method \"getParameter\" of undefined (Contact Company from URL.js$1108550#5)",
Here is code sample
Copy code
var objRecord = record.create({
                type: record.Type.CONTACT,
                isDynamic: true,
            });

            return objRecord;
b
same answer you got on the qa site, start looking into your user event scripts
fair chance one of them only works in the ui and its deployment has not been properly setup to only run in the ui
j
when execute it using userevent it gets executed and a new contact can be created but I when call using REST API it throws error
b
user event scripts dont trigger other user event scripts
j
Copy code
function addContact() {
            var nameData = {
                firstname: 'John',
                middlename: 'Doe',
                lastname: 'Smith'
            };

            var objRecord = record.create({
                type: record.Type.CONTACT,
                isDynamic: false,
                defaultValues: null
            });

            objRecord.setValue({
                fieldId: 'subsidiary',
                value: '1'
            });
            for (var key in nameData) {
                if (nameData.hasOwnProperty(key)) {
                    objRecord.setValue({
                        fieldId: key,
                        value: nameData[key]
                    });
                }
            }
            var recordId = objRecord.save({
                enableSourcing: false,
                ignoreMandatoryFields: true
            });
            log.debug('contact : ', recordId);
        }
I have this function on separate file like helper so that it can be called from userEventscript or Restlet script. When this function is called from userEventScript it works fine, but when calling the function from Restlet script I am getting the error.
b
fine, we shall go the long
create a new user event script on your contacts
set it up beforeLoad and only make it log that it ran
deploy it to your contacts
use the scripted records page to change the execution order of user events on contacts so that your new user event script runs first
then repeat your test so that you can see how user events work
j
I am sorry @battk I didn't get you here. I am trying to create new contact record when someone register in my web application. As am not trying to create contact from NetSuite UI do I have to deploy the code under user event script.
b
ive given you my primary guess at what the problem is
its probably a user event script
your defense of it is that your code in a user event script works fine
my response to you was that user event scripts dont trigger other user event scripts
so defending the problem user event script by saying it works with user event scripts is not a defense
headbang 1
you dont seem to understand that behavior, so you will have to discover it yourself
i gave you directions on what i think is the easiest way to see that user event scripts dont trigger user event scripts