Self-referencing relationship - displaying data

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
ddumas
Posts: 389
Joined: Tue Apr 23, 2013 11:17 pm

Self-referencing relationship - displaying data

Post by ddumas »

I have the following BOs:

Member (all members subscribed)
FirstName, LastName, etc

MemberBlocks (list if members you do not want to receive any messages from)
Member (type=Member, allow multiple, owned by Member, default widget= grid)
BlockedMember (type=Member, not multiple, peer, default widget=combobox)
DateBlocked (date)
BlockReason (why you wish to block this member from sending you messages)

In my Member main form, I have a form section called MemberBlocks, which I add , edit Blocked Members. It's working.

However, when I navigate to that section, It works, but It only displays the ID of the BlockedMember in the grid . I see no way to display the BlockedMember's first and last name. See attachment. So, I need to displayed the related child records's First and Last name in the grid. When I press edit to edit, or add to add a new BlockedMember, the add / edit forms work fine, and I can see the Member, and BlockedMember first and last name.

So, all the association is working fine.

Dave
Attachments
SelfReferencing.PNG
SelfReferencing.PNG (11.48 KiB) Viewed 4467 times
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Self-referencing relationship - displaying data

Post by Jaymer »

you just need to add Shortcuts to the First/Last name field. then they'll show up in the list of fields to add to the Query(grid)

also, i would hope you'd start you're adventure naming fields 'correctly' (although that highly debatable)

member BO:
Fname
Lname
field 3
field 4
pm_BlockedMembers <---- indicates its a peer multiple, just by its name
ps_Company <--- peer single reference to "owner" Company record, not just Company (which could easily be confused as a string field for Company Name)


when you use "MemberBlocks", its like, is that a verb? is it a list? If its boolean, then it'd be MemberBlocksYN so you can tell anywhere down in code. but if its pm_MemberBlocks then you know its a reference list.

like i said, this is debatable - and Vlad doesn't ascribe to this, or all the teaching apps would be redone to show this strategy. So people (like u) don't get this when they begin and go down 1 path when many/some of us "pros" go down a different path. Then, when an experienced person has to step in to debug/help/continue an app, all the fields are named "wrong" and you can't tell "down in the bowels" what type of field you're dealing with because its just named "Invoices" instead of pm_Invoices (which says a lot just in the name).
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Self-referencing relationship - displaying data

Post by PointsWell »

Jaymer wrote:you just need to add Shortcuts to the First/Last name field. then they'll show up in the list of fields to add to the Query(grid)
On your MemberBlocks BO create a new attribute of type Shortcut. When you do this a field will become available immediately below the attribute type. Enter the path to the attribute that you want to show in the form:

Code: Select all

psMember.Name
Where psMember is the attribute on MemberBlock that relates to your Member BO.

As Jaymer says you can then use that Shortcut attribute on your grids. If you choose to make your grid editable in line then you use can use the Shortcut as your drop down. If you do this though, you can only use one depth of shortcut for inline edits, though you can reference multiple depths of relationships for just viewing.
ddumas
Posts: 389
Joined: Tue Apr 23, 2013 11:17 pm

Re: Self-referencing relationship - displaying data

Post by ddumas »

Thanks guys I will try the short cuts - , makes sense. I will also look at naming - it is indeed very important.

Dave
customaware
Posts: 2391
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Self-referencing relationship - displaying data

Post by customaware »

ddumas wrote: I will also look at naming - it is indeed very important.

Dave
Hence the presentation I sent you the link for yesterday Dave. ;-)
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
Post Reply