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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Assign Relationship with a queue
Pages: [1]

Author Topic: Assign Relationship with a queue  (Read 1656 times)

aspagarino

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 10
  • San Diego Joomla
    • California Center for Sustainable Energy
  • CiviCRM version: CiviCRM 4.3
  • CMS version: Drupal 7
Assign Relationship with a queue
January 17, 2012, 12:32:52 pm
We would like to have a form that when it submits the contact information it triggers a relationship with a contractor base on a query.

So if there are 3 contractors in a group we would like to have

Applicant 1 assigned to Contractor 1
Applicant 2 assigned to Contractor 2
Applicant 3 assigned to Contractor 3
Applicant 4 assigned to Contractor 1
Applicant 5 assigned to Contractor 2....

Would a pre or post hook will be able to do this? Not sure if the CASE component would be a better way to manage this... if so I imagine that there is not a queing assignment.

We are on Durpal 6.2 and CiviCRM 3.2.3

Any initial help/advice/pointers/suggestions would be highly appreciated... thanks

Andres

Open Source is Green

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Assign Relationship with a queue
January 17, 2012, 04:57:31 pm

assuming u r using a profile, your best bet would be to do this via the postProcess hook on the profile

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Assign Relationship with a queue
January 18, 2012, 12:05:56 am
we wrote a small 'random' module for a situation that requires the Activities - created via Webform/Civicrm to be delivered consequetively to the 'counsellors' who are 'on call' - for D7
originally the roster of people was likely to change at any point so the module needed to keep checking if the next person in the queue was still in the group.
if that sounds useful am happy to share
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

aspagarino

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 10
  • San Diego Joomla
    • California Center for Sustainable Energy
  • CiviCRM version: CiviCRM 4.3
  • CMS version: Drupal 7
Re: Assign Relationship with a queue
January 18, 2012, 08:50:25 am
Thanks Pete... that would be great if you can share... It's the queue section that I am a little lost.

Andres
Andres

Open Source is Green

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Re: Assign Relationship with a queue
January 18, 2012, 02:22:52 pm
I've attached the 'webform_random' module Pete mentioned. I'm not sure how applicable it will be to your situation, though, as it's very much tailored to both webform_civicrm and with a coulple hardcoded node ids to boot.

But the basic logic is thus:

  • When loading the webform node (prior to submission), check whether the current assignee is still part of the assignee pool (this pool changes from day to day)
  • If they no longer exist, randomly assign a new person (we have to randomly assign someone as we no longer have enough information to consecutively 'walk' the assignee array since it has changed)
  • Otherwise, on successful webform submission, change the assignee and set it to the next person in the array or back to the start if we've reached the end. If the assignee happens to no longer exist in the array any more (eg. the assignee pool has been reshuffled) then we default to randomly selecting an assignee

This 'queue' logic relies on an ordered array of potential assignees that stays in the same order for most of the time (and when the order changes we have to default to randomly selecting someone). For our purposes, this 'roughly sequential' outcome was good enough.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Assign Relationship with a queue
January 20, 2012, 07:25:59 pm
Nice to see the finished product of that little module.
btw, the line
require_once $GLOBALS['civicrm_root'] . '/api/api.php';
is not necessary because civicrm_initialize() automatically loads the api.
Try asking your question on the new CiviCRM help site.

aspagarino

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 10
  • San Diego Joomla
    • California Center for Sustainable Energy
  • CiviCRM version: CiviCRM 4.3
  • CMS version: Drupal 7
Re: Assign Relationship with a queue
January 23, 2012, 08:44:52 am
Will share when it's done...
Andres

Open Source is Green

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Assign Relationship with a queue
January 24, 2012, 02:15:04 pm
Torrance, I'm not sure, but it looks like your code may enter an infinite loop if there's less than 2 assignees available. If I were you I'd change lines 72-79 from
Code: [Select]
  // If there are no assignees available, assign to '0'.
  if (count($assignees) == 0) {
    $assignee = 0;
  }
  // If there is just one assignee available, we can only pick them.
  else if (count($assignees) == 1) {
    $assignee = key($assignees);
  }
to
Code: [Select]
  // If there are no assignees available, assign to '0'.
  if (count($assignees) == 0) {
    return 0;
  }
  // If there is just one assignee available, we can only pick them.
  else if (count($assignees) == 1) {
    return key($assignees);
  }
to avoid entering the do:while loop when not appropriate
Try asking your question on the new CiviCRM help site.

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Re: Assign Relationship with a queue
January 25, 2012, 01:40:08 pm
Thanks Coleman, well spotted! I guess I'd just been lucky in avoiding that till now.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Assign Relationship with a queue
January 25, 2012, 03:58:24 pm
Glad to help  :)
Try asking your question on the new CiviCRM help site.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Assign Relationship with a queue

This forum was archived on 2017-11-26.