Reputation: 1
I am trying to implement automatic phone number formatting into NetSuite I am having some issues getting my script to work. Basically if someone enters a phone number into a customer record, "1234567890" for example, it will automatically format to "(123) 456-7890". You can see my script below along with the error message I receive when creating a new script record.
Fail to evaluate script:
{"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"missing ; before statement (SS_SCRIPT_FOR_METADATA#21)","stack":[]}
Upvotes: 0
Views: 1121
Reputation: 5276
Why do you need a script for this? NetSuite already does this, based on the Phone Number Format setting at Setup > Company General Preferences. Check you have this field set correctly according to your preference.
If for whatever reason it turns out you do need a script for this, there are several issues with the script you posted:
fieldChanged()
entry point. You would need to wrap the logic contained in lines 10 to 20 inside a function, and then reference that in the return statement at the bottom. EG: If you called the function phone()
your return statement would be return {fieldChanged: phone}
.nlapiGetRecordId()
and nlapiLoadRecord()
) in a SuiteScript 2.0 script. Under some circumstances these functions may be available so it might work, but even if it does, it certainly isn't best practice.context
parameter. IE: function fieldChanged(context)
. That context parameter contains a reference to the current record (context.currentRecord
). Work with that instead of attempting to load the record separately.Upvotes: 0