systopia / de.systopia.moregreetings

CiviCRM Extension for additional greetings
GNU Affero General Public License v3.0
4 stars 10 forks source link

Derive fields to load from templates #2

Closed bjendres closed 7 years ago

bjendres commented 7 years ago

When loading the contact, derive the fields to return from the given templates. This has two benefits:

bjendres commented 7 years ago

@kpomaranska Did you have the time to test it yet? The code is in https://github.com/systopia/de.systopia.moregreetings/tree/dev_2

kpomaranska commented 7 years ago

@systopia Yes, and i'm afraid it does not see the custom fields :/ (tested on 4.7.18) - adding a {$contact.custom_xx} (in my case $contact.custom_28) in the greeting template on the more_greetings configuration screen does not return any value to the greeting field. Should the custom field be added somewhere else?

bjendres commented 7 years ago

Hm, that's weird. If you use the API (explorer) with Contact.get and return=custom_28, does it load it?

kpomaranska commented 7 years ago

Yes. if i input custom_28 i have to do it via "Other - choose a field not in this list", but i can also select it by field label (in my case test1). I've changed the $contact.custom_28 to $contact.test1 in the SMARTY, but it also does not work.

bjendres commented 7 years ago

So it works when loading the contact in the API explorer, but not as a {$contact.custom_28} token in the moregreetings? Are you sure you're using the version from the dev branch?

kpomaranska commented 7 years ago

Exactly. and yes :) i've just checked with Michał, and we have a dev branch version installed.

bjendres commented 7 years ago

ok, thank you. I'll have another look

bjendres commented 7 years ago

@kpomaranska Hm, I tested on my local 4.7.18 and it works perfectly.

Troubleshooting:

  1. Are you sure you're using the {$contact.custom_147} notation, where 147 is the ID of the CustomField?
  2. Is the related OptionGroup available for your contact? I mean, does it extend "Contact" or "Individual"?
  3. You know you have to change something at a contact to trigger the re-calculation of the greetings (or use the "save and apply"), right?
  4. Are you sure your test field is not protected?
kpomaranska commented 7 years ago

@systopia ok, i know what wasn't working - the "save and apply" button does not read the custom fields. When i change the template and cick "save and apply" there is nothing in the place of the custom field string. It also clears the existing custom filed strings in the "more greeting field". To see the string i need to edit any of the built in fields in the contact and save the changes - then the string reappears.

bjendres commented 7 years ago

@kpomaranska That was it! Sorry, my tests were always editing the contact. I found it and fixed it, thank you! Please test again with master, but it seems to work for me.

kpomaranska commented 7 years ago

@systopia it works :) thank you :)