Solved

SetVariable script not working

Posted on 2011-03-08
12
706 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sync a Wordpress with Filemaker 9 512
FM - Formatting Merge Fields 4 549
Display results of a checkbox set 5 241
FileMakerPro10 required fields interfering with data entry. 3 63
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…
Problem: You have a hosted FileMaker database and users are tired of having to use Open Remote or Open Recent to access the database. They say, "can't you just give us something to double-click on rather than have to go through those dialogs?" An…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now