Skip to Content.
Sympa Menu

comanage-users - [comanage-users] Getting Primary Name from related model

Subject: COmanage Users List

List archive

[comanage-users] Getting Primary Name from related model


Chronological Thread 
  • From: <>
  • To:
  • Subject: [comanage-users] Getting Primary Name from related model
  • Date: Wed, 1 Jul 2020 15:50:20 +0000

I created a new model object (to capture effort numbers) directly related to
CoPersonRole, which in turn references CoPerson. I am trying to do an index
list of my new objects that includes the Primary Name of the related person.
Name has the changelog behavior and I find the query does not reliably return
the correct (most recent) version.

I tried fiddling with my find args and never found a way to specify to return
the first name only. Perhaps someone knows how to do this (I assume sorting
the names ASC on is, etc) . Or perhaps I will have to individually query for
the Primary Name on each record in my controller.

One experiment I tried was to alter the CoPerson model, has one, PrimaryName
conditions element, adding one clause for the name_id:

'conditions' => array('PrimaryName.primary_name' => true,
'PrimaryName.name_id' => NULL ),

and that worked for my case but I don't know about other ramifications.

Any tips would be appreciated.

MikeM



Archive powered by MHonArc 2.6.19.

Top of Page