AnsweredAssumed Answered

Loop Scriptphobia!

Question asked by EssexBiker on Dec 1, 2017
Latest reply on Dec 7, 2017 by philmodjunk

Hi, I hope you're all well.


I would consider myself an intermediate "developer" having enjoyed FM for about 8 years now.


That said, Loop scripts terrify me!


Currently, I have a script that heads to report layout, creates and saves a .pdf into a specified file path and I am able to send it to recipients via email.


Here's the deal.

The layout is based on a table "Employees" 

Each employee belongs to and related to their appropriate "Company"


So a one to many,  One Company has many Employees.


The CompanyID is in the report layout which is the context of Employees.


How would I best place a loop script around the existing save..... as .pdf and email script.....  so each company only gets their own employees?



In other words.


I think....


Enter Find

Set CompanyID in the find to (the first in the company table) in the "Employees" layout.

Perform Find

Create and send the .pdf

Go to the next record in company, create a find based on that value

create and send the .pdf

so on and so forth until we've created the report from the last company record, then exit.


I guess what I really need to understand is how to set the NEXT company


If anyone would help get face my Loop Script demon, I'll send you a cigar for Christmas!

All the best from a very chilly, Blighty!