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) »
  • Support »
  • Using CiviCRM »
  • Using CiviCampaign (Moderators: Kiran Jagtap, xavier) »
  • Recommended approach to using the public API to sign petitions
Pages: [1]

Author Topic: Recommended approach to using the public API to sign petitions  (Read 3108 times)

mmikitka

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
Recommended approach to using the public API to sign petitions
May 24, 2013, 07:22:19 pm
I am using a petition to create new contact records and associate a survey Activity result with them. I plan to have two UIs for the survey: 1) a pretty, public UI with branding, responsive, HTML5, etc.; and, 2) an internal, data entry form for batch processing (will likely use the CiviCRM batch method). I wish to store the business logic in one place, and both UIs use the same API endpoint.

Can you please advise on the following ...

1) Is there an API method "sign petition" that will handle all the back-end logic?
2) If no, does it make sense to create a custom API endpoint in CiviCRM (via a hook/extension) to process the petition input, which is referenced by both UIs?

Thank you

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Recommended approach to using the public API to sign petitions
May 24, 2013, 07:29:23 pm
Since you are using Drupal, your best option for the front-end form would be with CiviCRM Webform Integration. Then you can make a nice pretty html5 form that stores survey results in Civi, without writing any custom code.
Try asking your question on the new CiviCRM help site.

mmikitka

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
Re: Recommended approach to using the public API to sign petitions
May 28, 2013, 12:10:14 pm
@Coleman For this particular situation, Drupal is not an option.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Recommended approach to using the public API to sign petitions
May 28, 2013, 02:11:57 pm
Oh ok, you do have that as your CMS in your profile.
A survey is basically just an activity, so use the activity api.
Try asking your question on the new CiviCRM help site.

mmikitka

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
Re: Recommended approach to using the public API to sign petitions
June 12, 2013, 06:00:05 pm
Coleman, thanks for the guidance. Drupal's CiviCRM webform module is quite robust (well done!), but I have a reservation:

CiviCRM webform does not honour the CiviCampaign petition data model - it simply sets the activity type to "Petition Signature", and ignores the survey ID and survey-profile relationships. Therefore, result cannot be integrated with the CiviCampaign workflow tools.

Do you object to the following enhancements to CiviCRM webform (I will investigate whether I have time to work on them):

1) Option to auto-create a survey based on the webform title provided by the user. In this case, the campaign would be mandatory. Default to TRUE

2) Option to use an existing contact and/or activity profile

3) Option to auto-create the contact and/or activity profile, and associate them with the survey provided by enhancement (1)

This would complete the Petition data model.

Also, at an over-arching design level, it seems as though Drupal's CiviCRM webform is the catch-all solution to problems with Profiles and derivatives (this is the third time that it was recommended to me). This does not seem to align with the CMS-agnostic design approach. Is the CiviCRM community intentionally moving towards a tighter coupling with Drupal?

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Recommended approach to using the public API to sign petitions
June 12, 2013, 08:28:30 pm
Quote
1) Option to auto-create a survey based on the webform title provided by the user. In this case, the campaign would be mandatory. Default to TRUE
Go for it :)
Quote
2) Option to use an existing contact and/or activity profile
3) Option to auto-create the contact and/or activity profile, and associate them with the survey provided by enhancement (1)
Can't use profiles in a webform, the two are mutually exclusive.
Quote
Also, at an over-arching design level, it seems as though Drupal's CiviCRM webform is the catch-all solution to problems with Profiles and derivatives (this is the third time that it was recommended to me). This does not seem to align with the CMS-agnostic design approach. Is the CiviCRM community intentionally moving towards a tighter coupling with Drupal?
That's one of those things about an open-source ecosystem. Some parts get planned out, others just happen.
I wrote webform integration 2 years ago, at that time nearly 90% of Civi sites were on Drupal and WP integration wasn't even on the table. So it seemed to make sense. If I had it to do differently I would put all those features into CiviCRM core. In fact I've proposed doing just that. However this would take time and money. So in the meantime, we have webform integration as a stopgap.
Try asking your question on the new CiviCRM help site.

mmikitka

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
Re: Recommended approach to using the public API to sign petitions
June 13, 2013, 07:26:15 pm
I don't understand your comment re: mutual exclusion of profiles. A profile is a collection of fields of a certain type, webform is a collection of fields of multiple types: it should be possible to a) restrict webform fields to only those present in a given profile, or (b) auto-create profiles based on the fields supplied by the user in the webform.

A Petition is an association of an Activity profile, a Contact profile and campaign; it should be possible to auto-create an Activity profile with only the Activity fields from the webform (the field types are known to webform anyways), and auto-create a second profile with only Contact fields.

Please clarify further.

I will pursue item #1 further (re: auto-create a survey)

Thanks,
matt

mmikitka

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
Re: Recommended approach to using the public API to sign petitions
June 20, 2013, 05:02:57 pm
Hi Coleman. I just submitted a working solution to enhancement #1.  See https://drupal.org/node/2024697.

regards.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Recommended approach to using the public API to sign petitions
June 20, 2013, 05:14:54 pm
Thanks for the patch.
In clarification of the profile thing. Webforms are collections of fields, and so are profiles, but there is no bridge between the two. There are concepts in profiles that don't exist in webforms (mapping, recaptcha, cms user), there are things that work very differently (grouping, tagging, redirecting, contact references), and there are things in webforms that don't exist in profiles (relationships, multiple contacts, editable option lists).
But the main barrier to bridging the two is the field naming convention (aka form key). Webform CiviCRM has a flexible and predictable naming convention (civicrm_2_contact_1_contact_prefix_id) which always corresponds to database columns and api entity names. Profiles fields on the other hand have unpredictable and sometimes frustratingly random names. (in this case the field name is individual_prefix, which doesn't correspond to anything in the database at all). To be fair, profiles were written a long time ago and therefore have had a great deal more time to accrue technical debt.
Try asking your question on the new CiviCRM help site.

mmikitka

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
Re: Recommended approach to using the public API to sign petitions
June 25, 2013, 06:03:07 pm
Thanks for the clarification, Coleman. I have a related question. A customer is building an external app that sucks petition activity data out of CiviCRM via the public API, stores it in a Rails app, etc. They are designing the app in such a way that there is no prior knowledge of the fields associated with a petition/survey. How can they obtain this information i.e., all of the custom fields associated with a petition activity created by webform by keying on the campaign and petition ID? Extracting all fields and checking non-NULL is not an option.

If I were using a pure Campaign solution, I would use the Individual and Activity Profiles associated with the petition/campaign, however auto-loading/auto-creating profiles is currently unsupported by the webform interface.

Thanks for considering.
matt

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Recommended approach to using the public API to sign petitions
June 25, 2013, 06:10:53 pm
I made some suggestions for the patch, will you take a look at that soon?
When you fetch an activity via the api, it ought to return custom as well as core fields - have you tried it yet?
Try asking your question on the new CiviCRM help site.

mmikitka

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
Re: Recommended approach to using the public API to sign petitions
June 25, 2013, 07:15:31 pm
RE: Comments on webform enhancement. I will be working on this in the coming week.

It is not clear to me how to *only* extract the fields associated with an activity (null and non-null).  It seems like one needs to know the field names beforehand, but that is not an option in this case.

mmikitka

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
Re: Recommended approach to using the public API to sign petitions
June 25, 2013, 07:16:27 pm
If you're able to provide a sample API request, that would be much appreciated.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviCampaign (Moderators: Kiran Jagtap, xavier) »
  • Recommended approach to using the public API to sign petitions

This forum was archived on 2017-11-26.