Multiple Campaign Settings Change

All installation and configuration problems and questions

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

Multiple Campaign Settings Change

Postby kingleigh » Mon Jun 18, 2012 2:16 am

One of my clients have 600+ campaigns and i need to change the settings on all of them but want to do this without individually changing each one.

Can you tell me if there is a quick way to do this? If it is an sql query can you let me know the text please?

Thanks,
kingleigh
 
Posts: 2
Joined: Tue May 08, 2012 8:31 am

Re: Multiple Campaign Settings Change

Postby DomeDan » Mon Jun 18, 2012 6:13 am

I too have been thinking about this feature, started to write my own but ended up with a page just to show the difference between settings on the campaigns, and that has been handy time to time.

The query to change settings on all campaign is very simple, but its dangerous.
you should start out with a query that can count campaigns depending on some setting, for example lets check lead_order:
Code: Select all
SELECT lead_order, COUNT(*) FROM vicidial_campaigns GROUP BY lead_order

Code: Select all
+---------------------------+----------+
| lead_order                | COUNT(*) |
+---------------------------+----------+
| DOWN                      |        3 |
| UP LAST CALL TIME         |       19 |
| UP LAST CALL TIME 6th NEW |        2 |
+---------------------------+----------+

So most of my campaigns use "UP LAST CALL TIME", I want to update all campaigns to use that
but maybe there is a reason 3 of them uses DOWN that I didn't think about, thats why its good to look at the data before doing any big changes like updating 600 campaigns.
Vicidial Partner. Region: Sweden/Norway.
Does Vicidial installation, configuration, customization, add-ons, CRM implementation, support, upgrading, network-related, pentesting etc. Remote and onsite assistance.
Email: domedan (at) gmail.com
DomeDan
 
Posts: 1226
Joined: Tue Jan 04, 2011 9:17 am
Location: Sweden

Re: Multiple Campaign Settings Change

Postby mcargile » Tue Jun 19, 2012 4:31 pm

It would have to be done in MySQL. There is nothing in Vicidial to mass update campaigns. I do not recommend doing this unless you absolutely have to. If you mess something up you will have a very bad time fixing it.

As far as the SQL to accomplish this, we would need to know what you want to change.

If you go into the campaign and hover of the help dialog ? link for the field you want without clicking it, Firefox will display the JavaScript that is going to be executed. For instance Active in the campaign section looks like this:

Code: Select all
javascript:openNewWindow('/vicidial/admin.php?ADD=99999#vicidial_campaigns-active')


This opens a new window with the help dialog and jumps down to the anchor for that field. Matt named the anchors after the DB table / field that it involves for the most part using this format DBTABLE-DBFIELD. So for instance the field that controls if the campaign is active is in the 'vicidial_campaign' table and is called 'active'.

Once you know the table / field you want to change you need to go into the database and find out what is supposed to go into that field. Do a describe on the table and then do a select on that field to find out the sorts of values that are there. For instance vicidial_campaigns / active the describe looks like this:

Code: Select all
mysql> describe vicidial_campaigns;
+---------------------------------------+------------------------------------+------+-----+---------------------------------------------------------------+-------+
| Field                                 | Type                               | Null | Key | Default                                                       | Extra |
+---------------------------------------+------------------------------------+------+-----+---------------------------------------------------------------+-------+
| campaign_id                           | varchar(8)                         | NO   | PRI | NULL                                                          |       |
| campaign_name                         | varchar(40)                        | YES  |     | NULL                                                          |       |
| active                                | enum('Y','N')                      | YES  |     | NULL                                                          |       |
| dial_status_a                         | varchar(6)                         | YES  |     | NULL                                                          |       |
| dial_status_b                         | varchar(6)                         | YES  |     | NULL                                                          |       |
| dial_status_c                         | varchar(6)                         | YES  |     | NULL                                                          |       |
| dial_status_d                         | varchar(6)                         | YES  |     | NULL                                                          |       |
| dial_status_e                         | varchar(6)                         | YES  |     | NULL                                                          |       |

....


and a select will look something like this:

Code: Select all
mysql> select active from vicidial_campaigns;
+--------+
| active |
+--------+
| Y      |
| N      |
| Y      |
| Y      |
| N      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
| Y      |
+--------+
23 rows in set (0.00 sec)


This should give you a pretty good idea how the data should be formatted. Now it is time to build the query:

Code: Select all
UPDATE vicidial_campaigns SET active='Y' where active = 'N';


This query will set all of the campaigns to active that were not active. I realize this is really quite basic, but its a good place to start. One big thing to keep in mind is that you need to be really careful before doing this. I recommend backing up the table you are about to mess with before making changes, make the changes outside of production, and remember to test the changes before the agents log back in. You will be very unpopular if you screw something up on all of your campaigns and have no way to revert back. To back up a specific table you can use the mysqldump command like this:

Code: Select all
#> mysqldump asterisk vicidial_campaigns > campaign_backup.sql


If need be you can restore it like this:

Code: Select all
mysql> use asterisk;
mysql> \. campaign_backup.sql


This will drop the table, recreate it, and load it with the old values.

Lastly keep in mind that the web interface /api does a bunch of error checking to ensure that bad values are not inserted into the database. If you are going to be doing this frequently I highly recommend paying for us to write an API call to do what you are trying to accomplish rather than doing it manually. By doing it directly you run the risk of causing more headaches for yourself than is necessary.
Michael Cargile | Director of Engineering | ViciDialGroup | http://www.vicidial.com

The official source for VICIDIAL services and support. 1-888-894-VICI (8424)
mcargile
Site Admin
 
Posts: 617
Joined: Tue Jan 16, 2007 9:38 am


Return to Support

Who is online

Users browsing this forum: No registered users and 160 guests