FileMaker Scripting Best Practices

33
SCRIPTING BEST PRACTICES Emory Brown Application Developer https://www.dbservices.com

Transcript of FileMaker Scripting Best Practices

Page 1: FileMaker Scripting Best Practices

SCRIPTING BEST PRACTICESEmory BrownApplication Developerhttps://www.dbservices.com

Page 2: FileMaker Scripting Best Practices

Questions

If you have a question, please typist it into the console. If we

don’t get to your question, please send it to [email protected]

Page 3: FileMaker Scripting Best Practices

About You

Page 4: FileMaker Scripting Best Practices

About DB Services

•We are a team of analysts, developers, and designers creating custom applications to make your organization more effective and efficient. Learn more about our FileMaker services on our website.

•If you leave this presentation wanting learn more! Check out our FileMaker Blog where we post new content each month.

•To learn more about DB Services, check out our website at www.dbservices.com

Page 5: FileMaker Scripting Best Practices

Background

Work

Read more on me on our website, https://www.dbservices.com/, in the About section

• Application Developer atDB Services

• Certified in 15, 14,13, 12, 11• Working with FileMaker for 6 years• Sponsor at FileMaker Developer

Conference

• Member of FM Academy• Global presence (Canada, Europe,

Africa, South America)• Team focused on adding value

Page 6: FileMaker Scripting Best Practices

Scripting

When coding, choose two:• It works• Easy to read• Quick to write

Conventions help make code that works, faster to read and write.

Page 7: FileMaker Scripting Best Practices

Time Saving

Humans are the most expensive part of theapplication development cycle. • Template• Conventions• Scannable Code

Page 8: FileMaker Scripting Best Practices

Proper Context

Ensure script is run from intended contexts• Saves time testing• Create fewer bugs• Generic scripts

Page 9: FileMaker Scripting Best Practices

Error-Trapping Scripts

Three useful sub-scripts to consider in every script• Halt of not in browse mode• Halt if no records in found set• Commit record and halt if invalid*

Page 10: FileMaker Scripting Best Practices

Error-Trapping

Why Error trap?• Empower users• Speed up troubleshooting• Create user trust

**Don’t make generic error messages

Page 11: FileMaker Scripting Best Practices

Allow User Abort [Off]

Doesn’t make sense for users to be able to escape a script.

Page 12: FileMaker Scripting Best Practices

Set Error Capture [On]

Detailed error messaging empowers the user andhelps the developer troubleshoot

Page 13: FileMaker Scripting Best Practices

Exit Script Step

Page 14: FileMaker Scripting Best Practices

Error-Trapping

What to trap for• New Record• Delete Record• Set field• Go to related record*• Interacting with systems outside of FileMaker

Page 15: FileMaker Scripting Best Practices

Commenting

Not all comments are created equal• Readability• Clarity• Scannability

Page 16: FileMaker Scripting Best Practices

Commenting

Readability• Housekeeping• Section Headers• Spacing• Notations

Page 17: FileMaker Scripting Best Practices

No Comments

Page 18: FileMaker Scripting Best Practices

Minimal Spacing

Page 19: FileMaker Scripting Best Practices

Too Many

Page 20: FileMaker Scripting Best Practices

Clear Sections

Page 21: FileMaker Scripting Best Practices

Commenting

Clarity vs Noise• Anything being used in a non-

conventional way*• Stacked objects• Sort script steps*

Page 22: FileMaker Scripting Best Practices

Hidden/Stacked Objects

Page 23: FileMaker Scripting Best Practices

Commenting

Most important thing is DOING IT• Update comments as you code• Create a template script with

sections

Page 24: FileMaker Scripting Best Practices

Modular Code

Pros & Cons• Can save time testing or updating• Can also add time to later updates• Don’t over-engineer

Page 25: FileMaker Scripting Best Practices

Too Much

*Inconsistant

Page 26: FileMaker Scripting Best Practices

Too Much

Page 27: FileMaker Scripting Best Practices

Complex Code

Page 28: FileMaker Scripting Best Practices

Ziptastic API

Page 29: FileMaker Scripting Best Practices

Evaluate

Page 30: FileMaker Scripting Best Practices

Evaluate

Dangers of Evaluate( )• Tempts you to hardcode field names• Slower than native code• Security risks

Page 31: FileMaker Scripting Best Practices

Tips & Tricks

Script Debugger• Step-Into debugger• Turn off script trigger button

Page 32: FileMaker Scripting Best Practices

Naming Code

How to name variables well• Self-describing noun• Unique name• NO right answer

Page 33: FileMaker Scripting Best Practices

Q&A