Hi all, How can I get all the body field ids relat...
# suitescript
b
Hi all, How can I get all the body field ids related to a record type, without loading any specific record of that type? Not looking to get field values, just the ids.
c
You want to get a list of all attribute values without loading the record?
You could use N/search.lookupFields
b
No, actually I want the list of all body field ids from a record type, not field values (updating the OP to avoid confusion)
c
Record.getFields()
that might require you to load the record though, not sure.
b
yup, will have to load the record for it first
c
If this was Java, we could use the reflection API, I don't believe there is something similar in SuiteScript, this isn't a standard use case.
Someone with a deeper understanding of JS might know than me.
e
You don't need to load a record, you can create one and then get the fields without saving it
b
Interesting That should work, thanks
c
Outside the box thinking 🙂
b
I have the field ids. How do I also get labels for those fields? 🙂 I need to show the fields in a list and I don’t think showing IDs to users is the best way.
e
Loop through your fields and call
myrecord.getField(fieldId)
. That will give you the field and the label and type
b
That would make my API very slow. I pulled 145 fields which means I will have to make 145 calls to
.getField
For context, I’m trying to get a similar list of fields that you get when you click
Customize
in the pay bills page
e
try it, it's not as bad as you think. you could cache the results, they're not likely to change very often I would think
👍🏼 1
w
When you have a record-object, I think that most information is included in the record-object. getField() is just a function to retrieve it from the object. If you do it in the client, there are no calls to the backend to work with the record.
Copy code
console.time()
console.log(rec.getFields().map(fieldId => rec.getField(fieldId)?.label).filter(x => x))
console.timeEnd()
Above takes 3ms for me in the console. Creating the record could take some long time though.
b
That makes sense, thanks for the clarification
record.getFields
didn’t provide me the list of fields which exactly matched the list of columns NetSuite provides on the customize page. 🥹
Any one know how to get the list of additional columns present in the
Customize Sublist
page which you get to when clicking the
Customize
button on the
Pay Bills
page?
e
record.getSublistFields
b
The page says
Customize Sublist
but the columns are not from any sublist. They are body fields from
Vendor Bills
record type.
and few from
Vendor
record type
w
What are you exactly trying to do?
b
I’m trying to replicate the
Customize
feature from the native NetSuite in a plugin.
293 Views