Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Hi,

i want to write a small script that assigns Persons from a Table to different jobs of a task:

E.G:

Task "create design"

Operator: ________ ASSIGN

Assistent: ________ ASSIGN

Therefor I wrote a small script of two Steps.

In the first step is executed whan clicking on ASSIGN. I store the current layout, current record and current table as globals fields into another table. Then I change to a List-View of all persons with a "assign"-Button next to it. This button calls the second part of the script, which should set the appropriate person-field in the TASK-Record. (Set the current id to the field I script was called from.)

The problem is that I can select a Layout by calculation (e.g. a global field of a table). But I cannot select a field by calculation. I can only choose ONE exiting field.

So I would have to create a new script for each field of my TASK-Record.

did I miss something?

tom

Posted

Another idea: create value lists for Operator and Assistant. Choose from a Popup-List for both. The tasks could be one table, the operators in a second table, and the assistants in a third.

Posted

Update:

I almost found a workaround for this problem:

In the second part of the script I added a LOOP that interats trough all fields of the layout to check if it is equal to the desired target-field. The script looks something like...

SetField{_VARS_::pass_field; PERSON::id}

Go To Layout{ _VARS_::assign_person_to_layout}

Loop

ExitLoop if { Get(ActiveFieldName) = _VARS_::assign_person_to_field}

ShowCustomDialog("CurrentFieldName"; Get(ActiveFieldName))

Go to Next Field

End Loop

SetField {_VARS_::pass_field}

Note that _VARS_ is a table that holds my variables as global fields.

_VARS_::assign_person_to_layout is set to 'JOB' where I want to set the _person_task_1 or _person_task_2 (etc.) fields with the ids of records in the PERSON-Table.

This almost works, but accidently the field is a calcualated field of (Firstname & " " &lastname). That makes it not selectable and 'Go to Next Field' only affects fields in the currently active layout.

I just wonder, why I can't assign a Field just by it's fieldname? (Like SetField( person_name, Get(_VARS_::person_name) ). The world would be so wonderful. But it's filemaker-programming right now and I am going to bed with a slight headache...

Any ideas welcome...

tom

Posted

I agree that FileMaker has whet our appetitie with things like Go to Layout by calc, but has left us cold with the inability to do similar things with Set Field. Other times this has come up for me was with the Set Next Serial Value and the Import steps, which I recently placed in a loop for an update routine.

My workaround for both of these was to break out just those steps into separate scripts that accept parameters. For instance, here's a partial listing of my script for "Set Next Serial Value( WhichTable, NextSerialValue )", which, as you can probably tell from the syntax, takes two parameters: WhichTable and NextSerialValue:

If [ GetParameter( "WhichTable" ) = "AccessorialExpenses" ]

  Set Next Serial Value [ AccessorialExpenses::AccessorialExpenseID; GetParameter( "NextSerialValue" )

Else If [ GetParameter( "WhichTable" ) = "AuthorizedExpenses" ]

  Set Next Serial Value [ AuthorizedExpenses::AuthorizedExpenseID; GetParameter( "NextSerialValue" )

Else If [ GetParameter( "WhichTable" ) = "Containers" ]

  Set Next Serial Value [ Containers::ContainerID; GetParameter( "NextSerialValue" )

End If

As you can see, this isn't perfect, but at least it allows a looping script for my solution. A similar set of If-Else If-End If steps were created for the part of the loop that imports the old data, except it only takes a table name as the parameter. You could do something similar for your Set Field problem.

Chuck

Posted

Dear Chuck,

thank you for this suggestion! This approach is a solution for my problem. It's not very beautiful and flexible but it will work. I already thought about creating dummy-layouts for all possibles tables and jump to this layouts but something like this: (It's not valid filemaker script now).

Go To Layout("_dummy_" & Get(_VARS_::target_tableName))

Set Field (_VARS_::FieldCount,0);

LOOP

EXIT LOOP IF((Get(ActiveFieldName) = Get(_VARS_::target_fieldName) OR _VARS_::FieldCount < _VARS_::FieldNumber)

Go To Next Field;

Set Field(_VARS_::FieldCount, Get(_VARS_::FieldCount)+1)

LOOP END

IF(Get(ActiveFieldName) = Get(_VARS_::target_fieldName))

Set Field(,_VARS_::pass_value)

ELSEIF

ShowCustomDialog("Not found")

END IF

Go To Layout(Get(_VARS_::target_tableName))

I am new to Filemaker and not sure if I am hard enough for this kind of "programming" ;-)

sincerly

tom

Posted

Looks pretty good. You didn't set the number of fields on the layout into a variable. You must do that on the layout, before starting the loop. Also, your < should be >, 'cause FieldCount starts at 0 and is the counter (mixed the names up?). But since I don't know exactly what your FieldNumber field is I could be wrong.

Set the total count with:

ValueCount ( FieldNames ( Get ( FileName ) ; Get ( LayoutName ) ) )

Of course you know not to put any other fields than the ones you want on the layout. Merge fields seem to be OK, and are not even counted.

Another approach is to check whether the field is on the layout before even starting. Then you don't need to count, as you know that it either is or isn't (in which case you don't continue). Go to the layout (my field names; TO's name is FieldOnLayout):

PatternCount(

Posted

Hi Fenton,

obviously there is a lot more to FileMaker-programming, than I expected. I already did the script with some "if(_VAR_::target_field="field1")/else if(_VAR_::target_field="field2" .... " - statements. It works now, and I am pretty sure I will not touch it again.

I will surely use the ValueCount-approach in the future.

I have to check out the PatternCount-Code. I am not really sure how it works and have to do some experiments. But it looks most valueable. Since I am comming from perl-programming I have a strong background in pattern-matching and eager to use them in FM.

Thank you very much. It's great to learn from wizards like you.

tom

Posted

Well, the If statements would certainly work. But after about 10 fields it would start to get old. The ElseIf step would cut out some fluff :-]

Basically the whole Loop/Go to Field is a work-around for the fact that we cannot Set Field by name, Set Field [ a variable we populate with a field name, a value]. In some future version of FileMaker I hope we can, so it will become an obsolete trick (like exporting/importing portal records to sort them, gak! :-/

PatternCount is pretty much what it sounds like. It's not a "grep pattern," it's just whatever characters. It's case-sensitive, as is Substitute. Both good geeky functions.

It is a little odd being called a wizard by someone who knows Perl, which seems intimidating to me, but I'll accept it. We will expect you to answer grep questions; just kidding :-)

Posted

I am using a Case Statement to put grades into a Age Group. 0-2 Ranger Kid, 3-5 Discovery Ranger, 6-8 Adventure Ranger, 9-12 Expediton Ranger.

Depending what age group this boy is in I want it to pick the correct layout for his age group.

For example if the Grade field contains 0-2 I want my script to goto a layout called Summary Sheet Ranger Kid in the same file.

Anyone have a direction to go here? This is a new one for me.

Any help would be greatly appreciated.

Mark Jones

Posted

Hi Mark,

Perfect for Choose() (my favorite function), because each beginning Grade number is divisible by 3. smile.gif Here are a few options ...

Layout number by calculation: Choose(Div(Left(Grade; 1) ; 3) ; 1; 2; 3; 4)

You can then leave your layout names anything you wish and just move their layout order to match (so Ranger Kid is layout 1 etc).

You could also name your Layouts Summary Sheet Ranger Kid etc and use:

Layout Name by calculation: "Summary Sheet " & Choose(Div(Left(Grade; 1) ; 3) ; "Ranger Kid"; "Discovery Ranger"; "Adventure Ranger"; "Expediton Ranger")

Or you can name your layouts 0-2, etc and use Layout Name by calculation: Grade ... certainly the simplest but not nearly as much fun; and it limits what you can name the layouts. wink.gif

LaRetta

This topic is 7392 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.