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 (Moderator: Donald Lobo) »
  • Having the added by user automatically added to the assigned to user field.
Pages: [1] 2

Author Topic: Having the added by user automatically added to the assigned to user field.  (Read 3296 times)

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Having the added by user automatically added to the assigned to user field.
April 02, 2011, 09:10:15 pm
Hi,

Client has admin staff that create activities etc. for other staff and so they work with mostly the assigned to field, but are forgetting to assign to themselves when they create the activity when it's not for someone else.  The idea is they'll remember to remove themselves from it (or can do it later) but they "lose" the activity otherwise.

What is the best way to go about implementing this?  Is it just overriding the template for that form or should I perhaps be targeting the javascript or using the formBuild (is that right?) hook?

Any direction much appreciated.

Malks

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Having the added by user automatically added to the assigned to user field.
April 03, 2011, 03:06:23 am
Hi,

What do you mean they loose the activity? That's still in their activity list even without the assigned to because they are the author, isn't it ?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Having the added by user automatically added to the assigned to user field.
April 05, 2011, 07:55:07 pm
Hi Xavier,

Yeah I get that the activity is still there, that's why I put it as "lose" :) 

I've written a calendar view for them that shows activities based on the assigned to fields which is what they work with most (admin people are creating a lot of activities for the rest of the business etc.) so showing activities using the added to field doesn't work as they don't want to see a lot of activities that they've created.

But they still need to see some of the activities they create.  They can assign themselves to it which is fine, but they are forgetting to do this and aren't seeing it in their calendar.  The solution wanted by the business is that the activity be assigned to them by default (so it will still appear in their calendar) and then they can un-assign if they forget.

Thanks.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Having the added by user automatically added to the assigned to user field.
April 06, 2011, 12:32:15 am
Hi,

Thx, now I understand. Could you share this calendar? Sounds like a tool some others could benefit from.

As for auto assign, check what elements are created in javascript, shouldn't be difficult to add an extra "me" + the user id in the right format.

Great post from hertzel on the topic of adding custom js http://civicrm.org/blogs/hershel/how-customize-civicrm-pages-jquery
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Having the added by user automatically added to the assigned to user field.
April 06, 2011, 05:50:02 am
Sure, where would I share this?  On github?  I am planning on writing a few little how to pages too (have one almost done on writing custom actions for search results), so on a general level where would you put this sort of stuff?

I saw Hertzel's blog post, it's good stuff.

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: Having the added by user automatically added to the assigned to user field.
April 06, 2011, 10:16:11 am

the howto pages should go on the civicrm wiki documentation

the code if packaged as a drupal module, should be uploaded to the drupal git repository

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

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Having the added by user automatically added to the assigned to user field.
April 06, 2011, 05:18:57 pm
OK, I don't think this as easy as I thought, as the assigned to field is an input that gets changed to an autocomplete so other jQuery is targeting it.  I thought I could just add an li to the list of autocomplete values but my jQuery is called before the autocomplete I think.  Is there any way around this that anyone can think of?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Having the added by user automatically added to the assigned to user field.
April 07, 2011, 03:11:43 am
Hi,

Try adding your code on load instead of on ready, should be triggered after the autocomplete.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Having the added by user automatically added to the assigned to user field.
April 07, 2011, 05:55:41 am
Nope I don't think that works either as load() is not really different from ready() in this case because it works on the DOM at the time it was called according to the jQuery FAQ.  There is now live() which gets around this for some events but not for load.  I think what I'm going to have to do is delegate the load event to a parent and use event bubbling (these are all new terms for me :)) and do it like that.  Live and learn.

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Having the added by user automatically added to the assigned to user field.
April 07, 2011, 06:20:00 am
grr, I don't think that's going to work either.  I can use delegation to get, for example, a click handler on the newly created elements but load and ready don't seem to bubble like other events.

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Having the added by user automatically added to the assigned to user field.
April 07, 2011, 06:56:34 am
Further to this, I can get it working if I use setTimeout, so I'm targeting the right elements, but that's not ideal either as you don't really know how long you should be waiting for and feels hacky.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Having the added by user automatically added to the assigned to user field.
April 07, 2011, 10:11:39 am
I don't know how possible this is. However you could certainly (I think) adjust the autocomplete code in the CiviCRM templates to call a function after converting the input.

That would be method #1 described in my blog post. It also has a place. :)
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Having the added by user automatically added to the assigned to user field.
April 07, 2011, 03:06:23 pm
Hi Hershel,

Thanks for your response (here and on the blog).  I had come to pretty much the same conclusion myself about this working with jQuery :)  Modifying/Overriding the template for this doesn't feel like the right solution, so I'm thinking I might try it in hook_civicrm_buildForm and see if I can do it by populating the default values for the field.  That might be a number 4 for your list.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Having the added by user automatically added to the assigned to user field.
April 07, 2011, 03:33:19 pm
Do let us know if that idea works. I have a feeling it won't, but I would be happy to hear otherwise. :)
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Having the added by user automatically added to the assigned to user field.
April 07, 2011, 03:52:16 pm
malks  - or do it in postprocess & set if empty to match the creator
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Having the added by user automatically added to the assigned to user field.

This forum was archived on 2017-11-26.