Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 728
  • Last Modified:

SetVariable script not working

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
Krisraychris
Asked:
Krisraychris
  • 4
  • 3
  • 3
  • +1
1 Solution
 
North2AlaskaCommented:
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
 
KrisraychrisAuthor Commented:
I have checked and the  layout is based on the table in which the field is in.
0
 
challengedayCommented:
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!

 
North2AlaskaCommented:
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
 
KrisraychrisAuthor Commented:
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
 
North2AlaskaCommented:
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
 
challengedayCommented:
Try putting quotes around the field name like this:

Set Field By Name [ "S_ PERMANENTS PLUS CONTRACTS::Contract Alert to renew 4" ; $ContractDueToExpire ]
0
 
KrisraychrisAuthor Commented:
Thanks , Just tried that but no go !
0
 
challengedayCommented:
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
 
KrisraychrisAuthor Commented:
Simple mistake on my side.
Thanks for the response.
0
 
TocacarCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now