Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3676 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I'm trying to use the Set Field By Name step in an effort to extend coding and simplify a script.  The script is called by a button that passes the name of the field into the script as a parameter.  In the calculation to specify the target field I'm using:

 

GetFieldName(Evaluate(Get(ScriptParameter)

 

The script is finding the target field as it should.  So this side of the script step is functioning as I'd hope.

 

The stumble is on the calculated result side of the script.  The calculated result is based on a test of which field is being acted on.  Basically, I'd like to use a Let statement to specify the field name to check in a case statement.  Something like:

 

Case(IsEmpty(GetFieldName(Evaluate(Get(ScriptParameter)))) ;
 1 ; 
GetFieldName(Evaluate(Get(ScriptParameter)))= 0 ; 1 ;
0)
 
This part fails.  It seems unable to know which field it should be looking at.  I know this is possible and that I must be using the wrong functions.  I'd welcome any suggestions as to how to structure the right side of the Set Field By Name step.
 
Thanks in advance.
Posted

I don't understand your question at all:

 

First, what exactly is the content of your script parameter?

 

Next, what does "a test of which field is being acted on" mean? Do you want to examine the contents of the given field before setting it??

Posted

Thanks for your questions and I'm sorry that my post was confusing.

 

1. The script parameter is the field name that is to be acted upon.  It is just the name of the field and I'm using that successfully to tell the script step which field to set.

 

2. Yes. I'd like to be able to examine the contents of that given field in a case statement and act accordingly.

 

Thanks in advance.

Posted

If the field to be acted on is called Model F then the script parameter passes the words Model F.  No quotations etc. just the name of the field to be acted upon.

 

I've attached a little prototype file so you can better see what I'm trying to do.

Posted
the script parameter passes the words Model F.  No quotations etc.

 

That's not possible. if you are passing text, it must be quoted - though you may not see it until you re-enter the dialog.

 

Anyway, this is not a good method, because if you rename the field, the script will break. You may wonder why I dwell on this part. It's because I think you have an unnecessary complication here and once this is sorted, the second part will fall in place.

 

 

Is there a reason why you cannot pass the parameter as =

GetFieldName ( YourTable::Model F )

Or is the target field in another table?

 

 

I've attached a little prototype file

 

I don't see it, but I cannot open .fmp12 files anyway, so it doesn't matter.

Posted

I'm just getting back to this now.

 

Thanks for that helpful suggestion.  I have modified the script parameter as you suggest.  It continues to work just fine and now is sturdier as you suggested.  Thank you for that.

 

I still have an issue on the calculated result part of the script step.  I'm trying to pass the field name into the calculation so that it can be evaluated and acted on appropriately.  It seems unable to determine what the contents of the specified field is.  The step reads:

 

Set Field By Name [Get(ScriptParameter) ; Let(X = Get(ScriptParameter ; Case(IsEmpty(X) ; 1 ; X = 0 ; 1 ; 0))

 

Where the script parameter is: GetFieldName(table name::field name)

 

I've reproduced the prototype in a .fp7 format but I'm not able to post it here, presumably because of my permission level here on the forum.

 

Thank you for any help you can provide.

This topic is 3676 days old. Please don't post here. Open a new topic instead.

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
×
×
  • Create New...

Important Information

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