AnsweredAssumed Answered

How can I best manage my Leads queue?

Question asked by Renato Renato on Jul 8, 2014

I am implementing a queue of leads:

1. New leads are assigned to admin user

2. The real users of the leads list needs to click in a button to get a new lead, when they click, a new lead of a lead queue, that is assigned to admin, is re-assingned to them.

This is working, but sometimes there are 3 or 4 records the same lead (same email), and I want to assigned all this records to the same SugarCRM user.

To solve this issue, I created a test on my action:

1. I retrieve the next record of the queue

2. Test on my leads queue if records emails already has assigned to a user before, if yes, I assigned this record to the "owner", and move on for the next record.

This works 90% of the time, but, if I have 2 new records on the queue and this records are from the same email, and 2 users clicks on the button on the same time, one record goes to one user and another goes to another user.

I thought that I could create a shared memory variable to create a semaphore for just one user execute this action a time. So, on the first line of the action I change the global variable to "false" and all others executions has to wait, when I finish, I change to "true" again, and the next execution will start.

Is there a way to this on Sugar ? Using a global setting that is stored on database ?
Anyone has a better way ?