Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Why doesn't this calc work?

Featured Replies

The following unstored, Calculation yields a result of "Yes":

field_Test = Case ( RightWords( GetFieldName ( Self ) ; 1 ) = "Test" ; "Yes" ; "No" )

The following unstored calc, where Field is any field in the table, yields no result (Null):

field_Test = Case ( RightWords( GetFieldName ( Self ) ; 1 ) = "Test" ; Field ; "No" )

Why does this not work? That is, why does the calc work when the true case result is literal text, and it does not work when the true case result is a field. Note that the calc result is set to the correct data type, so date type mismatch is not the issue.

Darren

Darren Burgess

  • Author

Clarification - This issue is related to the storage of the calc.

So this calc:

field_Test = Case ( RightWords( GetFieldName ( Self ) ; 1 ) = "test" ; AnyField ; NULL )

When the results are unstored, either because it is manually set to unstored or because AnyField is an unstored field, then the calc breaks.

Why?

Hmmm...the more reductive question is:

An unstored calc field = GetFieldName(Self) returns the correct result.

An unstored calc field = RightWords(GetFieldName(Self) returns a null result.

Weird.

In fact,

Let(

$name = GetFieldName(Self);

$name)

returns a null result, though the var $name is created.

Can you post a file showing this? I suspect your first calculation doesn't work either.

If you want to reduce the question even further, try:

GetFieldName ( Self ) & "X"

So what the heck is going on?

1) For:

GetFieldName ( Self ) & "X"

I get TABLE::Field

2) For:

"X " & GetFieldName ( Self )

I get X TABLE::Field

3) For

Let([

$start = "Start";

$name = GetFieldName(Self);

$end = "End"];

1

)

I get a null result, but the $start and $end vars are populated.

If I change the storage from unstored to stored, I get the correct result.

Edited by Guest

I don't know. Frankly, I'm surprised that ANY reference to Self in an unstored calculation doesn't return an error. But in fact Self + 1 returns 1, which is clearly incorrect.

I suppose there is some safeguard in place to prevent an infinite loop in case of circular reference, and it kicks in even though GetFieldName ( Self ) isn't really a reference to self.

  • Author

ok, from another forum I got this response.

"Ah!

In an unstored calc the SELF function (or any self reference) doesn't resolve until the whole calculation finishes. It is the stored value which allows the GETFIELDNAME to resolve correctly. Not sure how to get around this."

Darren

  • Author

further clarification of the actual problem to solve:

Basically what I was trying to do, in a calculation field, was to use exactly the same calculation for each of several fields. Looking something like this:

calcField_Nurse = Case ( RightWords (GetFieldName ( Self ) ; 1 = Category ) ; anotherCalcField ; NULL )

calcField_Surgeon = Case ( RightWords (GetFieldName ( Self ) ; 1 = Category ) ; anotherCalcField ; NULL )

etc, etc

Where category is one of several person categories ( Nurse, Physician, Surgeon, etc) and anotherCalcField is unstored since it references another table.

I have sort of solved this with a custom function, but I am curious if it is possible to do this directly in the calculation.

Darren

from another forum I got this response.

"Ah!

In an unstored calc the SELF function (or any self reference) doesn't resolve until the whole calculation finishes. It is the stored value which allows the GETFIELDNAME to resolve correctly. Not sure how to get around this."

Could you name the source of this information, please?

I am not sure what exactly is your overall purpose here. Perhaps if we knew that, a simpler solution would present itself.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.