Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

using a variable in another file's script

Featured Replies

Hello, I am wondering whether/how I can use a script variable in another file's script. By way of background, I have a database with individual sales records, and a salesperson ID is associated with each sale record. I have a separate database of salespersons (salesperson ID and demographic data). My goal is automatically to loop through the sales records, sort them by salesperson ID, then "save as pdf" for each salesperson so that they can see the details of their sales. My tactic has been to start in the salesperson database, which has only one record for each ID, grab that ID (presumably as a variable), then call a script in the sales database and find all sales for that salesperson ID, then save as pdf and email to the salesperson. I can't make the variable transfer to the other file's script, though, so I'm stuck. Ideas? Thanks--

You can send it as a scriptparameter.

Why is the system split into two files?

You could find the sales records you want, sort by salesperson and loop through them, creating PDFs and emailing them.

  • Author

Thanks for your quick response.

Regarding script parameters: I don't have experience with those--only a little experience with using variables within a script.

Regarding the reason for two files: The system is split into two files for historical reasons. I developed a contacts database before I developed the sales records database, so I just use the unique contact IDs in the contacts database as a linking field in the sales database.

Regarding running the script within the sales database: I am not sure how I would do this. Each salesperson has 50-100 sales (3000 records in the sales database, approximately 50 salespersons), and I don't know how I would construct the loop so that it would identify the 50 salesperson IDs amid 3000 sales records.

If you could provide guidance on these issues, I would appreciate it. Thanks!

The easiest and most robust way to do this is to use the relationship between sales person ID in each table. If you want only one sales person's sales records at a time then start in the Sales Person table then goto related records, show only related records. Print, export, etc.

I often use multi-key relationships and a portal for a really handy way to view such info. This way you have a dynamic list of data in the portal based on what you put into the multi-key relationship fields, including from and to dates, sales person, department, etc. really any fields you have in your portal records. You can then goto related records and print, etc with only your constrained list of data.

Cheers

Hey just read your post again and it sounds like you simply want to create a report for printing which contains all salespeople but in seperate pdf's? Well I never upgraded to a version of FM that produces PDFs natively (have been doing it with external free programs for years though triggered by FM). I'm assuming it just uses a post script to PDF generator like ghostscript so would work just like printing a report?

If my assumptions are true then you would probably need to generate a script that loops through each of your salesperson records, going to related records, print to PDF then go back to the salesperson table, go to next, etc.

This is the way to go. I didn't assume there was a relationship btw the two files, but if there is, then this will be a very straightforward loop.

This demo of how to pdf and email an invoice may help: Link

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.