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.

Automatic number when importing

Featured Replies

I have a field that is a counter for a specific persons records in a file. This works fine so long you manualy create new records. The problem is when I import records then the value don't get any bigger then one (1). To count a persons records I use a self relationship and the following calculation in the field.

code:


If( fieldname <> "";

If( Count(Selfrelationship::fieldname <> "";

Count(Selfrelationship::fieldname)+1;"1");"")

It counts the time a record with fieldname exists and put that + 1 in the counter field.

Is there some smart way to solve a problem like this? At second thought the solvation dosen't have to be smart so long it works wink.gif

//Henkan

The calculation is your problem. Change your entire calculation to:

Count(selfrelationship::fieldname)

-bd

Alternatively, you could create a calculated numerical field for each record where the result is always "1" and use the Sum function instead (ie. "Sum(selfrelationship::C_Constant)".

By using this method, you never have to manually increase any field and even records that are imported will have a value of "1".

  • Author

quote:

The calculation is your problem. Change your entire calculation to:

Count(selfrelationship::fieldname)


If I use this calculation the first record for this person will have no value. That will mess things up when I realy want a value in this field and has set the field to "Not empty".

I haven't tried the other suggestion yet but although it seems to solve the problem with no value in the field will the second post realy get 2 as value? Or have I got it wrong that the Sum like Count only sees records that already exists and not the one I' creating? Maybe if I take Sum(selfrelationship::C_Constant) + 1, but I tried that with Count and it didn't work. I have to try that out later today. I'm happy for all suggestions.

//Henkan

Henkan,

If you utilize my suggestion the record will have a value of "1" in the C_Constant field the moment you create it, and therefore the Sum will count it.

  • Author

Rob thanks for your answer.

I tested your calculation but I don't get a value into the field. It is empty after the import. What have I done wrong??? crazy.gif

What I did was created a field, Calc1, which I equeld with 1. I set the calculation in my counterfield, Counter, to Sum(selfrelationship::Calc1). The selfrelationship is based on my foreign key.

  • Author

Forget the last post. I figured it out.

The problem was that I didn't have the Count field as calculation fieldtype, it was numeric. When I changed it all works fine. blush.gif

Thanks again for your help Rob.

  • Author

On the other hand it didn't work like I thought it would. I can't store the value and FM says something about the reason could be because it referes to a relation field.

This shouldn't be that hard to do, is it me that hasn't got the hold om FM yet? It proberly is

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.