Solved

SetVariable script not working

Posted on 2011-03-08
12
723 Views
Last Modified: 2012-06-27
Hi
I am trying to generate a weekly  report which I want to send as an email  via the FMserver.
The script as it is now is not setting the field  ContractAlertToRenew4 so that the Find can take place and thereby generating the report which will show all employees who's contracts are due to expire within "X" Number of days.
Example:EmployeeID:"1"
ContractAlertToRenew4:"Contract Due to Expire in" "4"" Days".This alert will show for any contracts which are nearing expiry within a range of 0 to 10 days.
I need the result  :"Contract Due to Expire in" "4"" Days" (or "5" or"9" etc) to be set in the ContractAlertTo Renew4 Field or is there another way.
 Show All Records
Enter Find Mode [ ]
Set Variable [ $ContractDueToExpire; Value: Let (
[
DaysLeft = S_ PERMANENTS PLUS CONTRACTS::Days Left before contract Expires;
DayP = If ( DaysLeft = 0 or DaysLeft > 1 ; " Days" ; " Day" )
];
Case (IsEmpty ( S_ PERMANENTS PLUS CONTRACTS::Contract Start Date )or IsEmpty (S_ PERMANENTS PLUS CONTRACTS::
Contract end Date )
; "";
(DaysLeft < 10) and (DaysLeft >1) ; "Contract Due to Expire in " & DaysLeft & DayP
)) ]
Set Field By Name [ S_ PERMANENTS PLUS CONTRACTS::Contract Alert to renew 4; GetField($ContractDueToExpire) ]
Perform Find [ ]
0
Comment
Question by:Krisraychris
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
12 Comments
 
LVL 12

Expert Comment

by:North2Alaska
ID: 35068570
In order to set the value, one of two conditions have to be met.  1)  You have switched to a layout the is based on the table the field is in.  2) You have a relationship to the table from the table your current layout is based on.  Have you met one of these?
0
 

Author Comment

by:Krisraychris
ID: 35068886
I have checked and the  layout is based on the table in which the field is in.
0
 
LVL 4

Expert Comment

by:challengeday
ID: 35070475
Hi Krisraychris,

Try this:
Change the third to last step to Set Field instead of Set Field By Name.

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:North2Alaska
ID: 35070734
And I don't think it is GetField($ContractDueToExpire) either. This would ask FM to resolve the Variable and then get the field from the results.  If $ContractDueToExpire = 10, FM would be looking for field 10.  

So just use $ContractDueToExpire to set the value.
0
 

Author Comment

by:Krisraychris
ID: 35080067
Just a question
When I use the script below "The provided Find Criteria cannot be found"
Show All Records
Enter Find Mode [ ]
Set Variable [ $ContractDueToExpire; Value: Let (
[
DaysLeft = S_ PERMANENTS PLUS CONTRACTS::Days Left before contract Expires;
DayP = If ( DaysLeft = 0 or DaysLeft > 1 ; " Days" ; " Day" )
];
Case (IsEmpty ( S_ PERMANENTS PLUS CONTRACTS::Contract Start Date )or IsEmpty (S_ PERMANENTS PLUS CONTRACTS::Contract end Date )
; "";
(DaysLeft < 10) and (DaysLeft >1) ; "Contract Due to Expire in " & DaysLeft & DayP
)) ]
Set Field By Name [ S_ PERMANENTS PLUS CONTRACTS::Contract Alert to renew 4; $ContractDueToExpire ]
// Set Field [ S_ PERMANENTS

When I use a really simplified script step as below it works !! I need to set this script to run from the server and email the report.I would liek ot know why the above script step does not enter the data into the Contract Alert to renew field.
Show All Records
Enter Find Mode [ ]
// Set Variable [ $ContractDueToExpire; Value: Let (
[
DaysLeft = S_ PERMANENTS PLUS CONTRACTS::Days Left before contract Expires;
DayP = If ( DaysLeft = 0 or DaysLeft > 1 ; " Days" ; " Day" )
];
Case (IsEmpty ( S_ PERMANENTS PLUS CONTRACTS::Contract Start Date )or IsEmpty (S_ PERMANENTS PLUS CONTRACTS::Contract end Date )
; "";
(DaysLeft < 10) and (DaysLeft >1) ; "Contract Due to Expire in " & DaysLeft & DayP
)) ]
// Set Field By Name [ S_ PERMANENTS PLUS CONTRACTS::Contract Alert to renew 4; $ContractDueToExpire ]
Set Field [ S_ PERMANENTS PLUS CONTRACTS::Contract Alert to renew 4; "Contract Due To Expire" ]
Perform Find [ ]
0
 
LVL 12

Expert Comment

by:North2Alaska
ID: 35082251
A whole other direction may be to use a TO and relationship to better manage this.  You could create a global field and set it to 10, for example. Now do a self join where this field >= to S_ PERMANENTS PLUS CONTRACTS::Days Left before contract Expires.  This would provide you a list of all the records that re going to expire in the next 10 days or less.  No need to do the find at all.
0
 
LVL 4

Accepted Solution

by:
challengeday earned 500 total points
ID: 35084101
Try putting quotes around the field name like this:

Set Field By Name [ "S_ PERMANENTS PLUS CONTRACTS::Contract Alert to renew 4" ; $ContractDueToExpire ]
0
 

Author Comment

by:Krisraychris
ID: 35092013
Thanks , Just tried that but no go !
0
 
LVL 4

Expert Comment

by:challengeday
ID: 35096170
No go how?

is it not setting the correct field? If so, you might have a misspelling of the table or field name.

Is it not setting the right value? If so you might not have the right value in $ContractDueToExpire.

You can use the Data Viewer to see what is in that variable. You can also do:
Show Custom Dialog ["debug" ; $ContractDueToExpire]
and see what it is.
0
 

Author Comment

by:Krisraychris
ID: 35154124
Simple mistake on my side.
Thanks for the response.
0
 
LVL 8

Expert Comment

by:Tocacar
ID: 35410119
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Pop up windows can be a useful feature of any Filemaker database.  Though best used sparingly, they can be employed in a multitude of different ways, for example;  as a splash screen at login, during scripted processes to control user input, as pick…
Conversion Steps for merging and consolidating separate Filemaker files The following is a step-by-step guide for the process of consolidating two or more FileMaker files (version 7 and later) into a single file with multiple tables. Sometimes th…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question