Jump to content
Sign in to follow this  
Dana G

Individual Pieces of Calc work until Combined in Script for Script Trigger

Recommended Posts

Purpose:  To capture the contents of a field before it is changed.  Compare the before to the after.  Highlight the after and screen capture then export.

 

I can't get past the first sentence and it's getting frustrating because it seems extremely simple.

 

1 Field:  OnDeck_t (text)  -  The OnDeck_t field data = On

2 Field:  OnDeck_before (Where I want to capture the OnDeck_t before it's changed)

 

I have an OnObjectEnter script trigger on the OnDeck_t field that runs this script:

Set Field By Name [substitute (Get (ActiveFieldName); "_t"; "_Before"); Get (ActiveFieldContents)]

 

If I do this it works fine.  (But I don't want it hard coded.  I will be using it for all the fields on the layout):

Set Field [OnDeck_before; Get (ActiveFieldContents)]

 

 

I have divided the Substitute (Get (ActiveFieldName); "_t"; "_Before") and Get (ActiveFieldContents) into separate lines in Data Viewer and both return expected results.  Why doesn't it work when it's part of a 'Set Field by Name' script step?

 

Thanks.

Share this post


Link to post
Share on other sites

You should have your trigger create a variable, perhaps $before, that consists of the text before anything is typed.

Share this post


Link to post
Share on other sites

OK I created a script called "Before".

 

It has one step:

Set Variable [$before; Value: Get(ActiveFieldContents)]

 

There is an OnObjectEnter script trigger on the OnDeck_t field (On; Off Radio buttons) with the "Before" script set.

 

From what I understand, the "Before" script should run after I click into the OnDeck_t field, making it active.  The script should set the $before variable to 'On' which is it's current contents.

 

It doesn't work.  The variable is blank.

 

Any ideas?

Share this post


Link to post
Share on other sites

$vars (local variables) only exist for the duration of the script and are lost once the script terminates - hence yours is blank

 

You need to use a $$var (global variable) - these remain in place until the file is closed.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Similar Content

    • By Asu
      Hello FM Mavens, 
      I am likely missing something. 
      I have a script step that calculates the dimensions of an image in a container field. There are many such fields so the script should work with any arbitrary one. 
      I get the name of the field by using script parameter Get(ActiveFieldName). 
      Let's say I have a container field "cont1". The script is triggered by entering the field.
      I am trying to calculate the height of the image by using 
      GetContainerAttribute (Get ( LayoutTableName ) & "::" & Get ( ScriptParameter ); "height" ) The results are question marks - I am not sure why. If I explicitly identify the fields then the expression works. 
      Tried the same expression (Get ( LayoutTableName ) & "::" & Get ( ScriptParameter )) in the script step "Set Field by Name" and it worked, which means that the expression correctly identifies the field the script is attached to. Then why is it not getting it the first step? What's wrong with the calculation? (FM17)
      Thanks
      Asu
       
      (I hope I posted it in the correct section)
    • By ash1474
      Hi, I am using this calculation in portal which calculates days in portal  Date - (GetNthRecord ( Date ; Get ( RecordNumber ) - 1 ) )
      how can i modify or do something else to avoid (?) in the first row.  Sample file attached for any modification/help.
      Thanks for any help
      DateCalc.fmp12
    • By Quant
      Hello,
      Could someone help me with this question?
      I have a row in a portal in wich i would like to make a calculation: Bedrag= Cases*Prijs,  but if Hoeveelheid is filled in then it should calculate Bedrag= Hoeveelheid*Prijs.
      The fields are all numeric. The calculation should be possible on one row, in this example i have made it on two.

      Yours sincerely
      Frans
       
    • By beckham
      Help Please, I am trying to figure out how to extract field contents via a calculation as follows:
      My lookup field is ABCDEFG-01-12345.jpg
      I want to automaticaly extract only 12345 to be placed into another field? I tried the Calculation Right ( Sorce field; 5 ) but that returns me 5.jpg
      any adivise is most welcome.
      Thank you
    • By George Rozakis
      Hi. 
      I have a single field, call it LETTER, with a massive calculation, but I want that calculation to be vary depending on another variable, ie a person. (Tom, George, Pete, ... ).  So I"m thinking I need a table of a calculation for each person.  Tom and his calculation, George and his calculation, etc , But how do I get those different calculations into the LETTER field.  Is it a lookup command?  
      Appreciate any help.
      George
       
       
×

Important Information

By using this site, you agree to our Terms of Use.