-
-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRM-21180: Inline changes to custom fields aren't reflected in custom greetings + CRM-21474 add support for setting non-required fields to 'null' #11364
Conversation
…n custom greetings. Includes unit test. Toward CRM-21180: Better static var handling. Toward CRM-21180: removed static vars; removed unused method parameters. CRM-21180 add unit test for custom field being set in address CRM-21180 Inline changes to custom fields aren't reflected in custom greetings This incorporates Allan's work to cause custom fields to be updated when a custom value is updated. These have been reconciled with the changes to allow greeting fields to be set to null per CRM-21474 m
When a field is not required in the database the 'null' should be pass through the pseudoconstant validation. Note the unit test on this is failing because the BAO is not respecting setting null. Follow up patch
The pseudoConstant was against the wrong field
@twomice see what you think of this - incorporates your changes plus the related one I was working on |
This is great @eileenmcnaughton The code generally makes sense -- especially CRM_Contact_BAO_Contact_Utils::getTokensRequiredForContactGreetings() and CRM_Contact_BAO_Contact::updateGreetingsOnTokenFieldChange(). I tested locally and confirm this code solves the problem described in the JIRA ticket. |
@@ -1069,6 +1069,10 @@ static function &fields() { | |||
'entity' => 'Contact', | |||
'bao' => 'CRM_Contact_BAO_Contact', | |||
'localizable' => 0, | |||
'pseudoconstant' => array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pseudoconstant was against the wrong field!
CRM-21180: Inline changes to custom fields aren't reflected in custom greetings + CRM-21474 add support for setting non-required fields to 'null'
Overview
Reconciled fixes affecting contact greetings code:
Both WIP: CRM-21180: Inline changes to custom fields aren't reflected in custom greetings #11095 and https://github.com/civicrm/civicrm-core/compare/master...eileenmcnaughton:pseudo?expand=1 were working on the same code area & this is a reconciliation of the changes in both
Before
Steps to reproduce:
Note the system ID of an existing custom field. In this example we'll use Most Important Issue, custom field ID=1, options: Education; Environment; Social Justice.
Find any existing contact and set a value in the custom field, e.g., "Education"
Edit a contact's "Addressee" field to "Customized", with the value "{contact.custom_1}" and save the contact; note that the Addressee field now says "Education".
Change the value of this custom field via the appropriate inline editing or tab for the custom field group; alternatively, use the CustomValue.create API like so:
cv api CustomValue.create sequential=1 entity_id=N entity_table="civicrm_contact" custom_1="Env"
NOTE: This repro recipe will not work if you change this field value by using the "Edit" button for the contact (i.e., by navigating to to /civicrm/contact/add?reset=1&action=update&cid=[N]); or by using the Contact.create API)
Observe that the Addressee field value is NOT updated to reflect the new custom field value.
After
Technical Details
2 new functions introduced:
CRM_Contact_BAO_Contact::ensureGreetingParamsAreSet() - this is called earlier in create so we know that for BOTH updates & creates the fields have been set, if they should be. This prevents a NULL field being overwritten.
CRM_Contact_BAO_Contact::updateGreetingsOnTokenFieldChange() - checks whether the fields that are changed are used in the tokens & if so processes an update.
Comments