how can I get form name in the server script?
# suitescript
a
how can I get form name in the server script?
t
getText from field 'customform'
a
@tuli that will throw an error
you can't use getText for the value has been set by setValue
t
On which record type are you ?
a
@tuli contact
t
message has been deleted
a
@tuli when you create a new record
you will see the error
or I think you can edit the record and change the form and save it
then you will see the error
t
in that particular case you can load the custom form record, and get the id , var cfr= record.load({         type: 'custform',         id: 181     })     var cftxt = cfr.getText({         fieldId: 'formname'     })
That will give you the name.
a
I've tried that
but it didn't work
t
Strange ,, working for me
a
are you sure?
t
obviously
a
if you open the form record
and load the record
the record type is not custform
t
message has been deleted
a
is it contact form?
here is custentryform
t
that is transaction form, it is custentryform, what is the issue then
a
recirdType doesn't exit
when you try to load custentryform
and if I try to load custform the error is record does not exist
I can get the record type
and it is custentryform
and the id is 176
but I can't load it
seems custentryform is not a valid type for search or load a record
Copy code
require(['N/record']);
var record = require('N/record');
var cfr= record.load({type: 'custentryform', id: 176})
var cftxt = cfr.getText('formname')
if I use custform the error is That record does not exist.
if I use custentryform which I believe is the correct type the error is
type is not valid
t
Yes, it is pretty weird.
Netsuite isn't doing justice with entry forms
a
so any way to get round this issue
t
Why do you need to know the name of the custom form , you are going to set yourself
I am not getting this in the first place.
Like what do you want to do with that ?
a
I want to run some code based on that
so user can chage the form
t
Based on text value of form ?
a
yes
t
Dynamic mode is the only option now
Don't know what are you upto still !
a
Dynamic mode?
@tuli could you please explain how dynamic mode can solve this before load?
s
I don't understand why you need the name. Why not just run the logic on the internalid of the form?
a
@Sandii because internal id could be different, also I'm looking for a word match in forms, so it wouldn't be just one form.
code will run for any form name that matches the word
s
I don't get the use case of needing this to happen when a user changes something but it happens beforeLoad? They can't change things beforeLoad
a
I think they can
if they change the form that will cause reload
and that will trigger beforeload
s
What do you need to do when they change the form? Why does it need to happen serverside?
a
I will hide some sublists and show an alert
let say if form name contains A
I will hide sublist AA
and if B hide BB
s
Giving an alert does not sound like something that makes sense to happen serverside. Have you tried just implementing this client side instead?
a
yes, the alert part is not important. although we can add the code server side.
I think we can't hide sublist clientside
s
Why not just hide the sublist on the definition of the form? Seems like something that makes no sense to script.
a
yes we can do that
but I need to hide some fields from standard sublists as well