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

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

Recommended Posts

Posted

Hi, can you help me

I am creating a script that will be activated when a field specified as a button is clicked. When this script is performed, it makes use of the Get(ActiveFieldContents)function, by setting other (global) fields to the value of the clicked field, and finding records with criteria in the clicked field. However I cannot seem to get it to work. The first thing the script does is: (to prevent the script from continuing if the target field is empty)

If(Get(ActiveFieldContents) = ""

Show Custom Message "Please select a field"

Exit Script

End If

And this always results in the message being displayed. Another test I have done is simply defining a calculation field as Get(ActiveFieldContents) and placing it in a layout I use for data entry. Selecting different fields in browse mode and entering data seems to have no effect, the field always stays blank.

What am I doing wrong? Can Anybody guess why the Get(ActiveFieldContents) doesnt seem to work?

Many Thanks

Fred

Posted

Get(ActiveFieldContents) does work. However, it will not work for what you want.

In your first example, if the field is defined as a button, clicking on it will activate the script, not the field. You could start the script by Go To Field [ thisField] to activate the field, but then you would have to specify the field by name, and I guess that would defeat your purpose.

In your second example, when you click into the field, Get(ActiveFieldContents) gets the field's contents. But, for as long as your cursor remains in the field, the screen is not refreshed, so your calculation field remains empty. When you do click outside the field, the screen is refreshed - but at this time no field is active anymore.

Try this to see how it works:

- Define a global text field gActive

- Add a button to the layout with the action: Set Field [ gActive ; Get(ActiveFieldContents) ]

- Click inside any field, then click the button.

Posted

Can you suggest any way round the problem? What I have is a long list of global text fields, and on click one of these texts fields, or by other means, I want to be able to search for fields containing criteria defined by the text field clicked. I can do this one by one with individual scripts, but as I have over 50 fields this is tedious.

I will continue fiddling...

Posted

OK, think I have sorted, Have the fields want defined as records in another file. Then that field set as value set in that file, then import value set into main file. Simple scripting from then on.

One question though

Is it possible for search criteria to be another field?

Posted

Some "status" (now "get") functions, such as Get (ActiveFieldContents) are not meant to be seen in Browse mode, only to be used in calculations and scripts. I guess because they can't evaluate in order to show.

In the case where you're clicking on different fields, but want them to run a common script, I would use the new Script Parameter option, which you assign for each "button" attachment; it's at the bottom of the dialog. Just specify the field that it's attached to, and it will send the contents of that field. Use Get ( ScriptParameter ) to retrieve the value in your script.

If [ IsEmpty ( Get ( ScriptParameter ) )

Show Custom Dialog [ "Field is Empty" ]

Exit Script

End If

If you want to go to the field, in order to do a Find, or for any reason, you're going to have some problems. There is no Go To Field [ by calculated name ].* Further, by attaching a button to the field, it becomes impossible to get Active Field Contents or Name; because you're never actually in the field. And you can't Go To Field [ that field ] for this same reason. Catch 22 (old).

It would be possible to set both the field AND its name (as hard-coded text) into the Script Parameter, as 2 separate lines, then parsing both out again (don't forget to remove the silly extra

GoToField.zip

Posted

Hi to all

I think that what I serched for isn't possible...

It seems related to this topic.

How can I retrive the name of a field, based on a string ?

( GetFieldName(text) ) So, if I have 2 fields: Field1="Apple", Field2="Banana" the result of GetFieldName("Apple") will be: Field1 :

Posted

Thankyou, using scriptparameter works brilliantly, although I still do need to set it manually for each field, it is still much much quicker.

Posted

If you look at my script you'll see that I hard-coded the field name into the script parameter. Then I had to Loop through the fields on the layout (where it is possible to Get (ActiveFieldName) ), until one of them matched (hopefully). That's the method, primitive but effective.

You could do similar with Get (ActiveFieldContents), Looping though the fields, comparing the current field contents against a preset string value. If that's what you mean by "retrieve the name of a field based on a string"; do you mean "the name of the field who's contents are the string"?

Tip: Commit Records/Requests removes the cursor from the Tab Order, then Go To Next Field will begin at the 1st field. You must trap so people do not get stuck in an endless Loop, if what is specified is not on the layout.

I'm not at all sure what you're trying to do. I'm just guessing.

Posted

Hi, Fenton

thank you for your quick replay

You know that if I export a file as XML, there I can see the name of a field (of all the fields) and what is inside it...

So I serched for a tip to grab that name, not its contents !(but based on its contents)

Posted

Hi, Michael

I need the name of a field !!

I can't use the normal functions of FM7, or so I think !

I need it for recursively search into a repeating field.

Posted

I still don't understand the context. How will you input the field contents? And what will you do with the name of the field, once you get it?

IOW, I don't understand what is known and what not. Here's an example that does what you describe - but is it good for anything?

GetFieldName.fp7.zip

Posted

Yes, you are right...

I can't do anything with the name of a field in a script context.

But I think that it's possible to use the name in a custom function...

Your attachment does what I wanted, but you had to hard coded the names !

So, if I add a new Field5 with "ananas", and I search for ananas, nothing returns. (I would to add the Field5 !)

In the case of a repeating field, I wish to have Field1[5] as the result !!

Posted

You shouldn't be chasing this:

I need it for recursively search into a repeating field.

Since it's not a proper filestructure, such searches went out of fashion in 1995 when filemaker became relational! Repeating fields is for relational keys not for storing data.

--sd

Posted

I could have used the FieldNames() function - but then I would have to know the layout name. As I said - I don't know what the context is.

It seems to me this is a solution looking for a problem.

Posted

Hi

Yes, I know...

But there are so many people who stored something into so much repeating fields that I wished a function to change a repeating field into a text field:

GetRepeatition'sText(repeatingField), without using a Loop for each repeating field in a script.

Posted

Arghhh !

Yes, yes, yes !!

It was that "Middle" that makes me a wrong finder !

Thanks for your effort !

Tip1 : Do you knew that you can obtain the MAXREPEAT of a repeating field with:

GetAsNumber ( FieldType ( Get ( FileName ) ; "repeatingField") ) ??

Tip2: Do you knew that You can set a "value list" with the values coming from a repeating field :

Posted

GetAsNumber ( FieldType ( Get ( FileName ) ; "repeatingField") )

It escapes me where to exploit such knowledge ...could you think up an example??

Drilling people in "nice to know's" serves what purpose exactly??

--sd

Posted

Hi, Soren

I can't understand exactly what you said, but it seems to me that you are smiling back to me ?!!

If it is so, never mind !

If it is not so, please help me to understand better what you said !

BTW the MiddleRepetitions ( repeatingField ; startRepetition ; endRepetition ) custom function by Comment requests (as I supposed) the endRepetition (or the MAXREPEAT, if you want all the values of the repeating field).

This is a good example ?

Posted

My point is, why substitute one violation of 1NF with yet another violation?

I'm guessing here - but isn't our task as developers to avoid inadequate methods by and large ...if you enherit a solution stuffed to it's burstingpoint with reperaters - must initial work establish what relational structure to pursue to prevent redundance and inconsitency.

This means that only vanity prevents you from exploiting scripts to this once and for all task to transform data to fit into a new more reliably structure and wrongly stored information in it's proper place!!!

The words for such devotion to repeating fields must be "Byzantine" and "Elaborate" ...and even worse "Stubbornness" ...alright they have their place as keyfield holders if Custom Functions are out of reach!!!

--sd

Posted

I do not love "repeating fields". But we are forced to cohabit to them! As I have said to you, some solutions have been developed with this type of field and, in order to convert them with facility, I went trying one solution like that proposed by the friend Comment.

After all, these words are not present in the English dictionary of babelfish:

1NF

enherit

burstingpoint

inconsitency

stubbornness

alright

Posted

The use of the function is more simpler of the script

Not sure:


Loop

Exit Loop If [ ValueCount ( Untitled::theRepeat[1] ) = 10 ]

Set Field [ Untitled::theRepeat; Untitled::theRepeat & "

Posted

I think there may be more than one record... So it's two loops. And each record may contain a different amount of repetitions, so if you don't want to stack carriage returns it should be:

Go to Record [ First ]

Loop

Loop

Exit Loop If [ ValueCount ( Target ) = Count ( RepeatingSource ) ]

Set Field [ Target ; Target & "

Posted

Hi, Comment

You can't use Count(repeatingSource) !!

It were be too simple !!

You have to use the MAXREPEAT , as definited in other my post.

I try to explain: I have a repeatingField of 7 repeatition, but one is empty.

Monday

Tuesday

Thursday

Friday

Saturday

Sunday

Your solution gives:

Monday

Tuesday

Thursday

Friday

Saturday

That is wrong !

But: Replace Field Contents [ No dialog ; Target ; MiddleRepetitions ( RepeatingSource ; 1 ; GetAsNumber ( FieldType ( Get ( FileName ) ; "RepeatingSource") ) ]

is always correct wink.gif

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