Timeline for How do you get contact_id in a custom form?
Current License: CC BY-SA 4.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 29, 2019 at 8:32 | comment | added | Simon Walden | OK, so the contact ID is not present in the form as I suspected. Frustrating that the other forms of getting the contactID aren't maintained, but maybe there is a reason. For other readers, just to clarify: ErikH's comment only gets you the current entityID - so in other words an activityID if the current entity is an activity etc. It doesn't get you the contactID unless you are in a contact. | |
Nov 28, 2019 at 19:54 | comment | added | Demerit |
As Erik notes there is $form->_entityId , and then assuming you mean the "reported by"/"author" contact of the existing activity being edited, you can do $result = civicrm_api3('Activity', 'get', ['return' => ["source_contact_id"], 'id' => $form->_entityId,]); and then the contact id is in $result['values']['source_contact_id'] .
|
|
Nov 27, 2019 at 12:12 | comment | added | Simon Walden | edited to give more info, but In this case the cust data is in an Activity for a civiCase | |
Nov 27, 2019 at 11:06 | history | answered | ErikH - CiviCooP | CC BY-SA 4.0 |