Has anyone spent much time creating customer payme...
# suitescript
m
Has anyone spent much time creating customer payments via suitescript? I'm doing it in the console as a test and every time I set the expense account it errors out with
code: 'RangeError', details: 'Maximum call stack size exceeded'
, in the UI I can confirm there should only be like 5 journal entries populating (pre-setting currency)
Doing it via
Copy code
rec.setText('aracct', ...)
c
Please post your code - it sounds like you're stuck in a loop with no exit
m
I've tried it two ways, here's some quick pseudo code. I'm doing it in the browser console so it's this simple-
Copy code
// require record, set to var record
// transform customer to customer payment (dynamic) - rec = record.transform({ fromType: 'customer', toType: 'customerpayment', fromId: customerId })
// set currency - rec.setText('currency', 'Euro')
// set expense account - rec.setText('aracct', arAccount)
or
Copy code
// require record
// rec = record.create({ type: 'custoemrpayment' })
// rec.setText('customer', customerName)
// rec.setText('currency', 'Euro')
// rec.setText('aracct', arAccount)
c
Are you doing anything recursive?
m
nope that's literally it
here with values. I tried it before setting currency then after (I know that loading the customer record was redundant)
to show how few journal entry lines this actually is, here's a screenshot of these 3 values set in the UI on a new customer payment
c
Thank you for sharing your code. Your argument(s) for setText are incorrect - please see the documentation here.
Unless it's overloaded, which is possible. However, I would try using an options object to see if the error persists
m
Hmm interesting, I've never had to use that syntax before with setText but i'll certainly give it a shot, thank you! I wonder if
ignoreFieldChange
will help
Hmm yeah with ignoreFieldChange it essentially acts like a standard record vs dynamic, but the problem is that I need it to load the lines sublist lines (journal entry lines) so it's like-
Copy code
rec.setText({
    fieldId: 'aracct',
    text: '11008 Accounts Receivable : Unbilled Marketplace Revenue',
    ignoreFieldChange: true
});
DynamicRecord {getMacros: ƒ, getMacro: ƒ, executeMacro: ƒ, …}
rec.getLineCount('items')
-1
vs if I use
ignoreFieldChange: false
then it times out again
c
Ah, do you have some client script on the page with fieldChanged functions that are getting caught in a loop?
Sorry, I should think a moment before posting - I'm not familiar with executing record.transform in the browser, and I don't know if that would actually trigger any client script (or workflows for that matter). Perhaps there is still a dependent field that should be set first? Are you in OneWorld with multiple subsidiaries?
m
Sorry for the delay was having lunch. That's a good idea about perhaps some sort of workflow or something running. Yes OneWorld w/ multiple subsidiaries. Working with the default subsidiary though
Scripted Record shows a few workflows and a couple of user event scripts (those definitely shouldn't be triggered). I'm going to try disabling everything on the record
c
Is that account only for one subsidiary? Are you confident that your default subsidiary is the one selected for the new created transformed record, or should you set it first before you set the AR account? When you create this type of transaction in the UI and update that AR field, can you see anything else on the page change in response?
m
It's multi-subsidiary (though only has associated records under one, we just default them to all). Just confirmed it is set on transform. Unfortunately even suspending all workflows and un-deploying all user event scripts still the same issue
I don't think I see any additional fields update in the UI when selecting the expense report
r
Are you sure it's not some other script or workflow in the event chain? I feel like it has to be.
It's a very specific error, usually to do with recursion.
m
Not that I can find, I went to the Scripted Record and unchecked Deployed on all scripts and set all workflows to Suspended. About to jump on a zoom with netsuite support
Maybe there's a custom field that has some wonky scripting/formulas? It's interesting that it works via UI
c
Let us know how it turns out!
m
support encountered the same issue even when they built a small script to test themselves from their side (vs my testing in the browser console) so they're looking into it and hopefully I'll hear back tomorrow
c
fingers crossed
m
Disappointingly they said that after reviewing internally they 'don't recommend' i make a record in the console and only do it via full script records. Very frustrating since I'm only trying to set up a single record in the console so i can use it for researching what I have to do.
r
That just means your support rep doesn't know what they're talking about. lol Using the console and writing a client script are using the very same APIs...
m
Yep
r
Did you clear your cache?
m
Copy code
Upon consulting this case internally and testing it within the internal QA environment, we do not recommend testing within the console log. 

Ideally, use one of the SuiteScripts for testing such as Suitelet to test whether the code is working as intended or not.
I'll have to waste time making a script that fails now
Clear my cache, no though I've tried it in multiple browser tabs. I can try it in incognito as well I suppose
r
You might have an old version of a client script you / someone was working on that was cached by the browser.
Caching along with the convoluted DOM makes client scripting an absolute nightmare in NetSuite
m
I'm not using a client script or anything. Just literally loading up my record module, creating a blank customer payment, and trying to assign a customer to it
r
I would try it. Whenever something truly wacky happens I clear my cache. It's fixed countless issues on the client side
m
Fair enough, but I just tried in incognito with same issue-
Copy code
require (['N/record'])
=> ...
record = require ('N/record')
=> {Event: {…}, create: ƒ, load: ƒ, copy: ƒ, transform: ƒ, …}
rec = record.create({ type: 'customerpayment', isDynamic: true })
=> DynamicRecord {getMacros: ƒ, getMacro: ƒ, executeMacro: ƒ, …}
rec.setValue('customer', 27623)
=> N.js?NS_VER=2023.1&minver=17&buildver=31238:2444 Uncaught nlobjError {id: null, code: 'RangeError', details: 'Maximum call stack size exceeded', stacktrace: "stacktrace: function nlobjError(code, error, suppr…rguments: {'undefined','aracct','undefined',-1}\n\n", suppressnotification: false, …}
r
If that doesn't work, try using
setValue
instead of
setText
. Set text is wonky. I never use it.
m
i did use setValue there
👍 1
I used to only use setValue but personally i haven't seen much of a difference between it and setText
These customers do have a bunch of unapplied journals but it's problematic to tie the journals out if I can't even access them!
They ended up saying sorry guess it doesn't work in console...
👏 1