How can I change the custom form on a customer rec...
# suitescript
m
How can I change the custom form on a customer record in netsuite? When I try (either in the UI or with suitescript) it re-sets to the Preferred form on save. Been setting
customform
with a text update in dynamic mode. Even testing with suitescript 1.0 in console I can change the form just fine, but then on save it re-sets to the original form. I think I'm missing a simple gotcha but not seeing anything in help docs.
added a logging statement before/after the setting that confirms the update-
Copy code
View	Debug	ccpayments after	02/14/2023	12:03 pm	Scientist Admin	64	Remove
2	View	Debug	ccpayments before	02/14/2023	12:03 pm	Scientist Admin	63
(internal id set from 63 to 64 prior to setting the other values, but then on save it reverts to 63)
a
those ids are the 2 custom form ids?
m
Yes
the SS line making the change is
Copy code
if (context.credit_card_payments === true) rec.setText('customform', 'Product Hub Customer Form');
in console w/ SS1 I see
reloads the page, confirm with
Copy code
nlapiGetFieldText('customform')
'Product Hub Customer Form'
but then on save it reverts right back to
Custom Customer Form
again
a
any other WFs or UE scripts, client scripts form scripts? that might be "fixing" it 🙂
m
Great question/tip, WFs are a bit of a mystery because the guy who works on them is a mad scientist so I'll dig into that, can't imagine why that would re-set the form though. And no UE scripts
r
Use the Scripted Records extension or page. Any of the above will be listed there.
a
I'm just thinking to force the right form for customer. a simple script or WF that just checks what the current form is, and then.. some logic, oh well product hub customers must have the hub field set, so if that's null they shouldn't have this form, set it to the normal customer form
m
product hub form is brand new, shouldn't be referenced anywhere
r
If replicable in the sandbox, disable half the scripts, try again, disable the other half. You basically perform a binary search for the problem script.
thinking 1
m
There are 2 suspended workflows, 1 active that sets an email field but maybe that email field isn't on the new form so it resets it?
a
you really work in an account with no UEs on the customer record and only 1 active workflow? crazy 😄
m
Well this is a development account, there are UEs, 1 is the one i created so I know that isn't doing anything. The others are a sticky notes plugin and then avalara
👍 1
a
oh there is a setting on forms, to store the form with the record, I don't think that would cause this issue tho, but I also haven't ever used it so... it might?
👍🏻 1
m
Yes checked that, it's unset
👍 1
r
Set it
m
on the preferred form or the one i'm trying to update it to?
a
both, one, then the other... trial and error FTW!
m
Haha yeah
a
so i know if you try and set a custom-WON customer to use the standard lead form instead of the standard customer form... that will do the same thing as what you're describing. but I assume that was just native behavior on native forms.
j
Could also try setting it using a beforeLoad or pageInit action in either script or workflow, rather than setting it on save. Generally, if Form A is marked as preferred that's the form that NetSuite will use for display. To get Form B to 'stick', set the 'Store Form with Record' on that form, or use permissions. You can set preferred forms for specific roles on the 'Forms' tab of the role definition. Check also the 'Roles' subtab of the custom form(s). Can set the form there as preferred for a role as well.
m
Thanks Jordan, I think you got to the heart of it there. I was able to get it to work by setting the custom form to Store Form. Definitely don't think the netsuite docs explain this.