Solved

SetVariable script not working

Posted on 2011-03-08
12
703 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
Having just upgraded from Filemaker 11 to Filemaker 12 over the weekend, we thought we would add some tips for others making the same move.  In general, our installation went without incident. Please note that this is not a replacement for Chapter 5…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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