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.

Merge Names...

Featured Replies

brain is just a bit fried....

Trying to create a merge of names from a portal

TableA -

TableB will have First & Last Name and a option to Show/Hide boolean and and an sort display order field:

1 John Doe

2 Mary Doe

4 Peter Doe

3 Sarah Doe - 1 //boolean hidden

The Calculated Display TableA the cf should return the following

Results: [color:red]Doe, John & Mary & Peter

Now if you change the order of the values:

3 John Doe

2 Peter Doe

1 Mary Doe

Results: [color:red]Doe, Mary & Peter & John

If there are multiple last names:

4 John Doe

3 Mark Public

2 Peter Doe

1 Mary Doe

Results: [color:red]Doe, Mary & Peter & John; Public, Mark

grouping the last names together.

Also would like to have an option to inverse the display so it reads First Name Last:

[color:red]Mary, Petter, John Doe & Mark Public

Ideas appreciated... :

maybe another occurence of tableB <> to hidden field with a relationship sort by LastName then Order

would give you the rigth order to use List() on LastName and FirstName as parameter for a CS in a unstored calc field in TableA

since the last name will be sorted just go recursively tru the list of last name until lastname is different from last to display like your example

You may have solved this already, but here's a skeleton of a recursive custom function that could work in mfrapp's field in TableA.

/*

MergeNames( firstNameList; lastNameList )



Notes:

- Lists should be sorted

- Convert to tail recursion if handling large lists

*/



Let([

nameFirst = GetValue( firstNameList; 1 );

nameLast = GetValue( lastNameList; 1 );



nameLastPrev = $$cf_nameLast;

$$cf_nameLast = nameLast;



appendResult = 

Case( 

//-- If first entry

IsEmpty( nameLastPrev ); nameLast & ", " & nameFirst;

//-- If new last name

nameLast <> nameLastPrev; "; " & nameLast & ", " & nameFirst;

//-- Else (in same family)

" & " & nameFirst

)



];



appendResult

&

Case( ValueCount( lastNameList ) > 1;



//-- If more values, continue

MergeNames( RightValues( firstNameList; ValueCount( firstNameList ) - 1 )

; RightValues( lastNameList; ValueCount( lastNameList ) - 1 )

);



//-- Else, clear global variables

Let( $$cf_nameLast = ""; "" )



) //End Case



) //End Let

Edited by Guest
Changed function name to MergeNames()

I was hoping there would be a clever way to solve this with a few List functions and some substitution, but couldn't get it to work. It seems that there would be yet a more elegant way to do this, especially when adding the option to reverse the presentation of first and last name. I'd enjoy seeing what you come up with.

  • Author

Thanks for the suggestions,

here is what I ended up doing... like what mfrapp suggested.

Created multi predicate self joined relationship by ID & Last Name - sorted by the order.

tableB>-

In TableB:

cName_LF =

Case ( not IsEmpty( end ) or hide ; "" ;

TextStyleAdd ( LastName ; Bold ) & ", " & Substitute ( List ( tableB_Family::FirstName ) ; "¶" ; " & " )

)

Then in tableA:

cName_LF =

Let ( [

v1 = Substitute ( list.unique ( List ( tableB::cName_LF ) ; "" ) ; "¶" ; "; " ) ;

v2 = "Vacant"

] ;

Case ( IsEmpty (v1) ; v2 ; v1 )

)

I am using 2 CF CustomList & UniqueList (renamed) the result that is returned is the unique occurrences of the items in the list. Items that are hidden don't show.

There are two more fields in each table that provide the inverse, display of FirstLast Name format.

If i were fully caffeinated. I suspect that this could all be achieved directly in TableA with out needing a field in tableB or the extra self join. Using CustomList. Maybe another day.

Thanks for sharing the result.

My approach was aimed at using one field in TableA, but what you ended up with is very clean and easy for someone else to understand and modify. Maybe it would be worth the extra credit of using one field if you had to implement the feature somewhere else.

Create an account or sign in to comment

Important Information

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

Account

Navigation

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.