Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5400 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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--

Posted

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.

Posted

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!

Posted

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

Posted

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.

Posted

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

This topic is 5400 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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