Learn Your Functions – LayoutObjectNames
How many of you have used the LayoutObjectNames function? If I’m being honest, I haven’t really used it much until the last year and what I have found is it is an awesome function to use.
How does it work?
First it requires the parameters for fileName and layoutName. Once these are passed it will display a return delimited list of all object names on the layout. Here are some examples of how it can work.
Hardcode them into the function
LayoutObjectNames ( “Customers” ; “Invoices” )
Use as variables in a script
LayoutObjectNames ( $fileName ; $layoutName )
Use them with other functions
LayoutObjectNames ( Get ( FileName ) ; Get ( LayoutName ) )
One thing to note is if there are named objects on a slide control or tab panel, button bar, or portal it will wrap the object names in angled brackets ( <> ). For example if you have a slide control with an address in it as below.
It will return the object names formatted like this:
If the slide control has an object name it it looks like this.
So why do this?
If you haven’t read my blog Transactional Edits using JSON then go check it out. If you have, then you know I am using the FieldNames function which works exactly the same as LayoutObjectNames where you pass in the filename and the layout name and it returns a list of fields on the layout. In that post I am using the field names to store JSON for editing a record.
So why not just use FieldNames instead of LayoutObjectNames?
This method is used in the JarvisQBO file where the file field names don’t match the QuickBooks Online field names. By getting the object names ( QBO field names ) I am able to create the JSON to push to Quickbooks. By having the object names it allows you to get other information about the object like the source ( field ) or the contents ( value in the field ). So even when pulling data from QBO I am able to use the same object names to get the field names to set the fields which also makes the code reusable.
Keep an eye out for a demo file on this topic in future posts as part of a series I’m working on. If you don’t want to wait you can head over to jarviscrm.com where JarvisQBO is free.
Thanks for reading and contact us with any questions at 877-501-8038. Enjoy the rest of your week!