Jump to content

I'm Almost There...


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

Recommended Posts

Thanks for the prompt reply, BobWeaver. But I have set it up like this, and it will still not work correctly. It will omit the records as desired by the if functions, so that part works fine i think. But, it will only set the fields properly on the FIRST record.

Specifically, heres the results I get:

Records are omitted as desired. Out of a set of 5 records, three meet the criteria. The FIRST record in the filtered set will have the text and date desired in the correct fields, as instructed by the If functions. The remaining two records do not have the text or date entered, as if the Set Field and Current Date functions did not work. How should I fix this?

I hope this makes sense. Thanks again for all your help!!

Link to comment
Share on other sites

Oh, by the way:

The first record in the set is configured so that it meet the criteria of the 2nd If function (If [status(CurrentDate) >= Letters P Date1 + 4) and (Campaign4= "Auto") and (Letters1.2 = "Intro") and (IsEmpty(Letters1.2))

Set Field ["Letters1.2",""1st FollowUp""]

Insert Current Date [select, "Letters P Date1.2"]) and that is the record that seems to have the info entered properly. Makes a difference or no??

Link to comment
Share on other sites

Oh yeah, there's an omit step in there, isn't there. The problem is that after you omit a record it automatically goes to the next one, so the go to next record step will cause you to skip a record in that situation. So, you have to do this:

code:


Go to Record/Request [first] <----Here

Loop

If [status(CurrentDate) >= Letters P Date1 + 4) and (Campaign1 = "Auto") and (Letters1 = "Intro") and (IsEmpty(Letters2))

Set Field ["Letters2",""1st FollowUp""]

Insert Current Date [select, "Letters P Date 1.2"]

Go to Record/Request [exit after last][next] <----Here

Else

If [status(CurrentDate) >= Letters P Date1 + 4) and (Campaign4= "Auto") and (Letters1.1 = "Intro") and (IsEmpty(Letters1.2))

Set Field ["Letters1.2",""1st FollowUp""]

Insert Current Date [select, "Letters P Date1.2"]

Go to Record/Request [exit after last][next] <----Here

Else

If [status(CurrentRecordNumber)=Status(CurrentFoundCount)]

Omit Record

Exit Loop If [1]

Else

Omit Record

End If

End If

End If

End Loop

Go to Layout ["1st Follow Up Letter- Auto"]

Page Setup

etc.....


The Omit step makes things kinda messy, but it should be possible to rearrange the loop structure a bit to clean it up.

Link to comment
Share on other sites

Thank God! It works!! You don't know how happy I am. I must say, I don't quite understand how that works, so if you find time, could you please explain this step and under what conditions you need them??

Else

If [status(CurrentRecordNumber)=Status(CurrentFoundCount)]

Omit Record

Exit Loop If [1]

Else

Omit Record

I thank you sincerely for helping me with this project. With your help, I have been able to overcome these big obstacles. Thanks.

Link to comment
Share on other sites

When you execute a script where you are looping through records, normally you would put a "go to record/request[next][exit after last]" just before the "end loop" step. That way after you've gone through the loop once, it goes to the next record and repeats until you have processed all records. That doesn't work when you have an omit step in the script, because Filemaker automatically jumps to the next record after the omit step. Then the "go to next" step will effectively skip that record, and it won't get processed.

The exception is when the omitted record is the last one. In that case, Filemaker jumps back to the previous record which is now the new last record.

That snippet of code checks if you are on the last record before omitting the record. If not, it omits the record and carries on with the loop. If it is the last record, then it omits the record and then exits the loop ("exit loop if[1]" will always exit). Without, that code, the loop could get stuck omitting the last record in the found set until there are no records left.

Link to comment
Share on other sites

Ok. I'm sure youre all familiar with this script im writing by now. Rigsby told me that I need to put the Go to Record/Request/Page Next, exit after last at the end of my If function, before the Else Omit Record. But now that I have more conditions in my script, I don't know where to put it. Here is how it looks now:

Loop

If [status(CurrentDate) >= Letters P Date1 + 4) and (Campaign1 = "Auto") and (Letters1 = "Intro") and (IsEmpty(Letters2))

Set Field ["Letters2",""1st FollowUp""]

Insert Current Date [select, "Letters P Date 1.2"]

Else

If [status(CurrentDate) >= Letters P Date1 + 4) and (Campaign4= "Auto") and (Letters1.2 = "Intro") and (IsEmpty(Letters1.2))

Set Field ["Letters1.2",""1st FollowUp""]

Insert Current Date [select, "Letters P Date1.2"]

Else

Omit Record

End If

End If

End Loop

Go to Layout ["1st Follow Up Letter- Auto"]

Page Setup

-this is where I think I want to print-

So, when I run this script (and Ive tried to put the Go to Record/Request/Page in different spots) it seems to either NOT omit the desired records, or it will NOT Set Fields properly (it may only set field correctly in the first record).

My question is, where should I put the Go to Record/Request/Page [Next, exit after last] command in this script with more than one If?

Thanks for your help!!

Link to comment
Share on other sites

code:


Go to Record/Request [first] <----Here

Loop

If [status(CurrentDate) >= Letters P Date1 + 4) and (Campaign1 = "Auto") and (Letters1 = "Intro") and (IsEmpty(Letters2))

Set Field ["Letters2",""1st FollowUp""]

Insert Current Date [select, "Letters P Date 1.2"]

Else

If [status(CurrentDate) >= Letters P Date1 + 4) and (Campaign4= "Auto") and (Letters1.2 = "Intro") and (IsEmpty(Letters1.2))

Set Field ["Letters1.2",""1st FollowUp""]

Insert Current Date [select, "Letters P Date1.2"]

Else

Omit Record

End If

End If

Go to Record/Request [exit after last][next] <----Here

End Loop

Go to Layout ["1st Follow Up Letter- Auto"]

Page Setup

etc.....


Link to comment
Share on other sites

This topic is 8241 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.