| Previous topic :: Next topic |
| Author |
Message |
saj49
Joined: 03 Dec 2007
Posts: 41
Location: Folsom CA
|
| Posted: Sun May 04, 2008 3:08 pm Post subject: Automatic changing of owner once the sales oreder is created |
|
|
As soon as the sales order is uploaded on to the site we need to assign the sales order to different group to process it and we have already created the sharing privileges to the creator. The number of orders have increased and we have now to handle more than 100 orders every day. We started trying to write a Trigger in the database so that once a row is added in the sales order it will trigger the owner to be changed to differenet groups as assigned by the trigger delending on the " creatorid" and "smownerid". At the moment as we observe:
1 As sooon as the sales order is created a crmid s created and corresponding "creatorid" and "smownerid"is available in the vtiger_crmentity table.
2 But the the moment we assgn the order manually to a group by changing the owner the "smownerid" becomes "0" in vtiger_crmentity.
3 Onceit is assgned to a group where is the relationship defined......like you have for leads in vtiger_leadgrouplrelation.
4 Can anyone help us bydefining the relationship in he tables and how to create a trigger so that whenever a sales order is uploaded it will automatically be assigned to a predfined Group as per the trigger. We are ot able to find the relationship table to te group for Sales orders....
This is very urgent. Can anyone help?
Raj |
|
| Back to top |
|
carloz
Joined: 11 Sep 2007
Posts: 437
Location: Brescia, Italy
|
| Posted: Sun May 04, 2008 4:33 pm Post subject: Automatic changing of owner once the sales oreder is created |
|
|
hi saj49,
what about so_grouprelation? :-)
mysql> describe vtiger_sogrouprelation;
+--------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| salesorderid | int(19) | NO | PRI | NULL | |
| groupname | varchar(100) | YES | MUL | NULL | |
+--------------+--------------+------+-----+---------+-------+
2 rows in set (0.20 sec) |
|
| Back to top |
|
saj49
Joined: 03 Dec 2007
Posts: 41
Location: Folsom CA
|
| Posted: Sun May 04, 2008 5:07 pm Post subject: Re: Automatic changing of owner once the sales oreder is cre |
|
|
Thanks a lot Carlos. I do see the table. It was tupid of me not to look at "so" and I was looking at "salesordergrouprelation."
Can you please guide me to write a trigger. The trigger should operate once the salesorder is created and the trigger will change the owner from the creator to a group based on the " Subject".
That means once the sales order created and uploaded on to our website the trigger will change the owner from "XXXX" to a group ID "YYYY" where the subject is " AAAA". Once we have on e query we have about 16 triggers each one based on the creator, the group and the subject.
I really appreciate your quick response and solicit your kind help.
Raj |
|
| Back to top |
|
joebordes
Joined: 18 Aug 2006
Posts: 1089
Location: Alicante/Valencia, Spain
|
| Posted: Sun May 04, 2008 10:31 pm Post subject: Re: Automatic changing of owner once the sales oreder is cre |
|
|
Hi,
I'd say you are complicating things.
You should make the change inside vtigerCRM using it's functions.
In all modules you have a save_module() function where you can execute any operations you need right after an entity is created or edited. So you add the change right there in the code using vtigerCRM functions. I'm sure vtigerCRM has functions to make the group assignment easily.
If you want a quote you know my email :-)
Regards, Joe
TSolucio |
|
| Back to top |
|
carloz
Joined: 11 Sep 2007
Posts: 437
Location: Brescia, Italy
|
| Posted: Mon May 05, 2008 7:27 am Post subject: Re: Automatic changing of owner once the sales oreder is cre |
|
|
hi Raj,
my experience with triggers is *very* limited :-|
anyway, a trigger on the vtiger db should be something like this:
CREATE TRIGGER lead_trigger
AFTER INSERT ON vtiger_leadaddress
FOR EACH ROW
UPDATE vtiger_leaddetails SET leadstatus = 'Green' where leadsource = 'web site';
this trigger would set to green the status of any lead whose source is the website after any insert on the leadaddress table
the trigger you need might be a little more complicated, since your subject field and your groupname are on different tables - i guess you'll need a join
ciao
carloz
ps: are you creating the salesorder from inside vtiger? maybe hacking the save.php file of the module could be an option too |
|
| Back to top |
|
carloz
Joined: 11 Sep 2007
Posts: 437
Location: Brescia, Italy
|
| Posted: Mon May 05, 2008 7:40 am Post subject: Re: Automatic changing of owner once the sales oreder is cre |
|
|
ops.
sorry, joe, i guess i did not refresh my browser properly, and missed your reply.
pls ignore my last post
ciao
carloz |
|
| Back to top |
|
saj49
Joined: 03 Dec 2007
Posts: 41
Location: Folsom CA
|
| Posted: Mon May 05, 2008 5:40 pm Post subject: Re: Automatic changing of owner once the sales oreder is cre |
|
|
Thanks Carlos. Yes we are creating the sales order from inside the vtiger CRM. The code has to link the creation of the sales order and while saving it look at the subject and owner and change it to a corresponding group.
it is like this:
if subject = A and Assigned To = B then change owner to Group "ABC
if subject = M and Assigned To = N then change owner to Group "MNO" like that....
DO you have any suggestion how to do it in save.php under modules/salesorder so that once the sales order is created and before saving this command is executed and then saved.
I appreciate your kind help
Raj |
|
| Back to top |
|
carloz
Joined: 11 Sep 2007
Posts: 437
Location: Brescia, Italy
|
| Posted: Wed May 07, 2008 12:18 pm Post subject: Re: Automatic changing of owner once the sales oreder is cre |
|
|
HI Raj,
I'm sorry I can't write the proper code for you - not now, at least.
anyway, my way would be to write down some if statements and some corresponding sql updates on the proper tables :-)
ciao
carloz |
|
| Back to top |
|
saj49
Joined: 03 Dec 2007
Posts: 41
Location: Folsom CA
|
| Posted: Wed May 07, 2008 3:44 pm Post subject: Re: Automatic changing of owner once the sales oreder is cre |
|
|
Thanks Carlos. For me also it is easy to understand.... What we do now is:
1 As soon as the sale order is uploaded on to the CRM, depending on the Subject and who uploaded the sale order (owner) we manually assign to to a predefined group.
2 As I understand as soon as the sale order is uploaded it updates the vtiger_crmentity, an order number gets generated and when we change the owner to a group on the sales order the owner id changes to "0" in vtiger_crmentity.
3 simultaneously the vtioger_sogrouprelation gets updated by relating the order number and the group.
Am I right that this is the process. If there is a relationship between the order number generated at crmentity and the subject in the sales order the sql query can be written.
Can you guide me here please
Thanks
sraj49@comcast.net |
|
| Back to top |
|
carloz
Joined: 11 Sep 2007
Posts: 437
Location: Brescia, Italy
|
| Posted: Thu May 08, 2008 11:12 am Post subject: Re: Automatic changing of owner once the sales oreder is cre |
|
|
Hi Saj49,
I'm sorry I can't be of any further help.
My suggestion is to have some experienced vtiger developer customize the code for you.
Ciao,
Carloz |
|
| Back to top |
|
| |