Jump 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.

CDML If: Field: statement not working correctly...

Featured Replies

Hi

I'm using FileMaker Unlimited 5 and am having trouble with a CDML If statement.

I've been using CDML for almost a year now and have encountered something similar before.

I think I was told it was a bug in the web companion but here goes...

I have a CDML if statement on my format page which tests a value of a field.

Here's what I've got...


[FMP-Record]



[FMP-If: Field: ODD|EVEN .eq. ODD]

<tr align="left" valign="top" class="row1">

<td>[FMP-Field: ODD|EVEN]</td>

</tr>

[FMP-Else]

<tr align="left" valign="top" class="row2">

<td>[FMP-Field: ODD|EVEN]</td>

</tr>

[/FMP-If]



[/FMP-Record]



There's a field in my database called EVEN|ODD which is an unstored calculation. It detects the current record number and works out whether it is an even or odd record, then pastes the text 'ODD' or 'EVEN' into that field as appropriate.

The reason for this is that I want to add alternate colour coding for record rows on my results page so if it is odd you see above it uses the CSS class row1, and if it is even it should use the CSS class row2.

Only it's not working like that.

Looking at the FileMaker Unlimited machine the results look fine.

The value of ODD|EVEN is calculated correctly and the value alternates with each record.

However on the results page I get an odd, two evens, then two odds, then 3 evens in a seemingly random spread.

Meaning my alternating row CSS code gets changed and the thing looks bad.

Even though the value of ODD|EVEN is calculated correctly on the FileMaker Unlimited

Does anyone know why this happens?

I found a way round this in the past by instead of doing a [FMP-If] for each record to test the value, a calculation field displays whichever version of <tr... is appropriate.

I'd prefer not to have to 'get round' something like this and wondered if it was something I've done wrong above.

To see this weird effect take a look at:

http://192.168.1.5:591/FMPro?-DB=AMDPROS...kip=0&-Find

Even though on FMU the values of ODD|EVEN do not correspond to what the record shows on the results page.

Anything obvious that people can see that I'm missing?

Thanks

Ben

  • Author

I did think at first that it might be something to do with my sort order but the records are correctly sorted by the field SHOP NAME both on the results page and on the copy of FileMaker Unlimited.

Any ideas?

This is driving me insane.

Ben

Ben,

The Calculation field may be calculating before the sort. Did you test by having the field, and RecordNumber, display as a list in a browser window?

We usually use Javascript to alternate row colours. For example:

<script>[FMP-Record]

if ([FMP-CurrentRecordNumber] % 2 != 0)

{

document.write('<tr align="left" valign="top" class="row1">');

document.write('<td>[FMP-Field: ODD|EVEN]</td>');

document.write('</tr>');

}

else

{

document.write('<tr align="left" valign="top" class="row2">');

document.write('<td>[FMP-Field: ODD|EVEN]</td>');

document.write('</tr>');

};

[/FMP-Record]

</script>

All the best.

Garry

  • Author

If I generate a CDML page as you say above, using a list of ODD|EVEN and FMP-CurrentRecordNumber then the records are sorted correctly with record numbers increasing from 1 to whatever.

However the value of ODD|EVEN is incorrect.

It might not be the ODD|EVEN calculation that's causing the fault. It might be that FileMakers Status(CurrentRecordNumber) is performed before the sort as you say.

Even though I hate JavaScript I guess that's the only way for now.

Thanks for the suggestion.

Ben

Create an account or sign in to comment

Important Information

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

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.