CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Setting default value of non-custom activity field AFTER type is selected
Pages: [1]

Author Topic: Setting default value of non-custom activity field AFTER type is selected  (Read 441 times)

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Setting default value of non-custom activity field AFTER type is selected
April 06, 2014, 12:55:31 pm
Might just be having a mental block as to how to do this but I want to set the default value of assignee but only for a certain type of activity. When the person chooses New Activity, the type isn't selected yet, so I can't set it during buildForm at that point. If I wait until they choose the type, then when buildForm is called (via ajax) the only fields in "scope" are the custom fields associated with that type.

Am I missing an obvious hook?

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
Re: Setting default value of non-custom activity field AFTER type is selected
April 10, 2014, 07:07:33 pm
I would use buildForm to add a JavaScript resource:
http://wiki.civicrm.org/confluence/display/CRMDOC/Resource+Reference

In your js file you should be able to use JQuery to react to the Activity type selection and set the field defaults at that time. http://wiki.civicrm.org/confluence/display/CRMDOC/Javascript+Reference What might be tricky is triggering the the Ajax lookup for contacts on the assignee field?

If that doesn't work you should be able to at least clear the field and freeze it for editing. Then you can set the value in hook_civicrm_postprocess.
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Setting default value of non-custom activity field AFTER type is selected
April 10, 2014, 10:11:24 pm
Thanks for the response. What I've done in the meantime is hacked activity.tpl to add some stuff after buildCustomData, but maybe I can add something as you describe to monitor the change event in the activity type dropdown.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Setting default value of non-custom activity field AFTER type is selected

This forum was archived on 2017-11-26.