Is there a way to get the SELF command to work in a Custom Function?
I expect not. Self can only be used where the context makes it unambiguous - where it's intrinsically obvious which object the function is referring to. Since a calculation can appear in a variety of contexts (field definition, Conditional Formatting, script step, etc., etc.), I don't believe this will work.
However, there may be another way to accomplish a similar goal. What exactly are you trying to do? There may be another method for de-furring the feline.
What are you really trying to do?
"Self" in a CF (Custom Function) is having the CF call itself. Which you can only do by calling it as a function "with parameters". This means "Self" is incomplete in the context of a CF.
Returns the content of the object in which the calculation is defined.
The Self function provides a way for a calculation to reference the object with which it is associated without having to explicitly reference the object.
Self is a function that automatically refers to the 'object' in which it is defined. But it cannot refer to itself as a function as that creates a circular reference.
I am creating yet cooler way to make Inline labels
$var.table=If (IsEmpty ($table) ;Get ( LayoutTableName );$table);
$field = Substitute ( Substitute ( Self ; " " ; "" ) ; "_" ; "" )
$var.table &"::" & $field
You can apply the Conditional Formatting to make the Label 500 px and you only need to do this once for the labels on your main table
If you have a portal then you just set the $table to the Table you are using for that. I wanted to put it in a CF so I can not have to enter the Calculation engine to to this. I almost go it to work with Enclosing objects to get the Portals TO but not quite.
The Self gets the text of the label and get the feild name for the Isempty. It works well Fields have regular names or if your fields have a Space or _ instead of spaces. If you have some stange Naming Convention then you need to modify the CF.
What about passing the field name as a parameter using GetLayoutObjectAttribute?
I would need to have my fields with object names, no? I rarely give object names to fields unless I have to. I want this to use the text of the label itself since FM makes the labels for me I can just drop this in on what it makes.
Well, I was suggesting giving your labels object names, but yes, you'd have to name the objects.
You're probably best just leaving it as a Conditional Formatting calc and doing a copy-and-paste job in this case. Unless Jimmy has a better idea (which is entirely possible).
You can use self in a custom function since FM 10.
Self is a unique function because it is both a pointer to the field value and a pointer to the field itself.
GetFieldName is able to use the latter.
So a function like Getfieldname ( self ) would return the full field name if used in a calc field like function ( self )
You would think that you're sending the field value only, but in fact you're also sending a reference to the field.
Le 25 avr. 2013 à 19:49, kaostika <email@example.com> a écrit :
créé par kaostika dans Advanced Discussion - Afficher l'intégralité du fil de discussionI would need to have my fields with object names, no? I rarely give object names to fields unless I have to. I want this to use the text of the label itself since FM makes the labels for me I can just drop this in on what it makes. Répondre à ce message en répondant à ce courriel -ou- aller au message sur FileMaker Technical NetworkDémarrer un nouveau fil de discussion dans Advanced Discussion par courriel ou à l'adresse FileMaker Technical NetworkGérer vos préférences email. FileMaker Developer Conference 2013 • San Diego, California • 12-15 Août 2013 • www.filemaker.com/devcon
créé par kaostika dans Advanced Discussion - Afficher l'intégralité du fil de discussion
Répondre à ce message en répondant à ce courriel -ou- aller au message sur FileMaker Technical Network
Démarrer un nouveau fil de discussion dans Advanced Discussion par courriel ou à l'adresse FileMaker Technical Network
Gérer vos préférences email.
FileMaker Developer Conference 2013 • San Diego, California • 12-15 Août 2013 • www.filemaker.com/devcon
Fabrice, can you expand on that a bit? "You would think that you're sending the field value only, but in fact you're also sending a reference to the field."
I'm not sure how both values are passed; or how you choose which result you want and know for certain which result you've actually generated.
(edit) Though maybe this illustrates your point.
You cant use the SELF in the CF dialog box, you can use it in a function
Inlinelabel (_table ;_self) = Inlinelabel ("",SELF)
$field = Substitute ( Substitute ( _self ; " " ; "" ) ; "_" ; "" )
It seems to work this way, so I dont need to do much work to get these labels to work. I will add the getlayoutobjectattribute to detect TO's automatcially in a bit
Modified file, added a repeating field.
Those are Fields, I am using Test Labels. My CF works if you Pass the SELF to the CF.
Maybe you could post a file illustrating what you're doing/trying to do. I don't quite see it right now.
That's how I sometimes use it. Passing a Self() to a cutom function to parse the field name.
I think this is a quality of how FileMaker evaluates calculations and GetFieldName() and not anything special about Self(). Try putting the field name in, instead of Self() and you get the same result.
Here is a demo of what I am doing.
Ok I want to use SELF in the custom, not passed to it. So when I open up Custom Function and add new Custom Function, I want to put SELF in the calculation box. Filemaker says I cant
Well, first of all, yes, FileMaker is right. You can't.
But what would be the point?
Self inside of a custom function would be a reference to the custom function. And we can already do recursion.
Back to the issue: what is it you are really trying to accomplish?
Ok so I have the labels over each field. I need to turn them off when the field is Filled out. I dont want to do that hundred of times. With the CF I can select all the labels and then format them to disappear when the field they refer to is not empty. I use the SELF function to get the label text so that the GETFIELD know what field is empty or not empty. There is another Technique for this but it Changed the Field it self and Is a bit too complicated.
I'm pretty sure you can't. Not even Evaluate ( "Self" ) works. Self() is designed to be used in calculations that apply to objects and fields.
But you have a working solution. What's wrong with what you've got?
I wanted to remove the extra step of putting in the SELF in the CF. Also I need a way to pick up the TO from the portal it in. I got it almost working last night with naming the portal then getting the contained object or enclosing object I forget.
It works in FM 12. See the demo file I put up in an earlier post. If I remove the formatting you can see the text over the field. So it seems to trigger with out a refresh
Are you defining the Conditional Formatting of all the labels at one time? That will work for local fields but not related fields, even your CF must have the related fields table passed into it.
If so just add conditional formatting that makes the text and fill clear and use this calculation. It does not require a custom function.
IsEmpty ( GetField ( Self ) )
Since you cannot know the related fields Table name unless you enter it manually you can modify this calculation for related fields by adding the table name.
IsEmpty ( GetField ( "tablename::" & Self ) )
These conditionally format the label without a custom function and requires no more data passing than your proposed CF.
are you ready for a bit of philosophy?
First of all, I wrote an article on the subject, but it's in French and I don't know how Google would translate it: http://www.1-more-thing.com/Self-Contenu-la-fonction-cognitive.html
While passing Self as a function parameter, you indeed send two pieces of information. That's very unusual in the FileMaker world.
The first piece of information is the field content, just like GetField or Get (ActiveFieldContents), or simply a field reference in the expression. Side note : French localization of FileMaker translates Self as Contenu (content), which was very appropriate in version 9 because that's all what self was doing (and very poorly at the time)
Since FileMaker 10, we have GetFieldName(). This function and only this is able to extract the second piece of information carried by Self: a reference to a field.
So if you have a function MyFunction ( field ), that does this : GetFieldName ( field )
And you use this function in MyTable::MyField calculation : MyFunction ( self )
--> the result will be "MyTable::MyField".
It is very interesting because you'd expect it to return an error. You seem to be passing a value to the function, not a field reference. But in fact you are.
Think of a clipboard. If you copy, say, a jpg file in the Mac Finder. Paste it to some other directory in the Finder, it will duplicate the file. Paste it in a text editor, you'll get the file name as a string. It means the clipboard contains several pieces of data, and you don't paste always the same thing, depending on context.
Same goes for Self : if passed to GetFieldName, it returns a field reference, otherwise a value.
Do you have a demo Fabrice. We can see how it works. the CF allows for related table with the first paramter. My goal is to get this info from the Portal the text is contained. So far no luck. The Get layout Obj Att doesnt let me get this
To get the fully qualified field name and use it to determine the conditional formatting of the label even in a portal use this.
FieldNames ( Get ( FileName ) ; Get ( LayoutName ) ) ;
Self & "¶"
; 1 ; 1 )
"¶" ) + 1
If there are two labels exactly ending in the same name, for example "my_promo_code" and "promo_code" then it will only return the first one listed on the layout for the "promo_code" label, which may be the wrong one. Will also not format the last one. But you can probably figure out how to do that one.
Also DOES work as desired when there are multiple portal rows.
Thanks, I think I have a method that will work bases on the Field Names method. I am going to try it.
Retrieving data ...