Mailing List Archive

Custom database query from within RT
Hello,



On the create ticket form I need to act upon a change to a drop down menu for a custom field (for this example 'Customer'), look up this value in a database table for a resulting default priority, and change the value in the priority drop down.



Ordinarily this wouldn't be hard in a basic HTML form, creating a db connection manually, but I can't find where to start doing this within RT. I'm not sure where I should be putting my db query code. Does RT allow me to put in a custom query somewhere and handle the db connection? Would a scrip be suitable to do what I need?



I've searched the mailing list and tutorials but can't find a similar problem. Specific files to change and alternative ideas on how do this would be appreciated as I am new to RT.



Regards,

Paul R


Think green - keep it on the screen.

This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
Re: Custom database query from within RT [ In reply to ]
On Fri, Mar 02, 2012 at 01:54:08PM +0000, Renney, Paul wrote:
> On the create ticket form I need to act upon a change to a drop down menu for a custom field
> (for this example 'Customer'), look up this value in a database table for a resulting default
> priority, and change the value in the priority drop down.
>
> Ordinarily this wouldn't be hard in a basic HTML form, creating a db connection manually, but
> I can't find where to start doing this within RT. I'm not sure where I should be putting my db
> query code. Does RT allow me to put in a custom query somewhere and handle the db connection?
> Would a scrip be suitable to do what I need?
>
> I've searched the mailing list and tutorials but can't find a similar problem. Specific files
> to change and alternative ideas on how do this would be appreciated as I am new to RT.

Are you doing your lookup inside RT's database or using an external
database? It sounds like you either want code using RT's API or a DB
connection running inside a Scrip.

-kevin
Re: Custom database query from within RT [ In reply to ]
Firstly, thanks for the reply.

It's good news I can do it using RT's API. The data I am using can be in the RT database.

I have looked for any documentation/examples/tutorials of how to use the API with custom tables but can't find any. Can anyone help here?

Regards,
Paul
________________________________________
From: rt-users-bounces@lists.bestpractical.com [rt-users-bounces@lists.bestpractical.com] on behalf of Kevin Falcone [falcone@bestpractical.com]
Sent: 02 March 2012 17:37
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Custom database query from within RT

On Fri, Mar 02, 2012 at 01:54:08PM +0000, Renney, Paul wrote:
> On the create ticket form I need to act upon a change to a drop down menu for a custom field
> (for this example 'Customer'), look up this value in a database table for a resulting default
> priority, and change the value in the priority drop down.
>
> Ordinarily this wouldn't be hard in a basic HTML form, creating a db connection manually, but
> I can't find where to start doing this within RT. I'm not sure where I should be putting my db
> query code. Does RT allow me to put in a custom query somewhere and handle the db connection?
> Would a scrip be suitable to do what I need?
>
> I've searched the mailing list and tutorials but can't find a similar problem. Specific files
> to change and alternative ideas on how do this would be appreciated as I am new to RT.

Are you doing your lookup inside RT's database or using an external
database? It sounds like you either want code using RT's API or a DB
connection running inside a Scrip.

-kevin

Think green - keep it on the screen.

This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.


--------
RT Training Sessions (http://bestpractical.com/services/training.html)
* Boston March 5 & 6, 2012
Re: Custom database query from within RT [ In reply to ]
On Sun, Mar 04, 2012 at 04:49:06PM +0000, Renney, Paul wrote:
> Firstly, thanks for the reply.
>
> It's good news I can do it using RT's API. The data I am using can be in the RT database.
>
> I have looked for any documentation/examples/tutorials of how to use the API with custom tables but can't find any. Can anyone help here?

Well, you can use RT's API to talk to RT's data.
If the table is in RT's database, you can get a database handle with
RT->Handle->dbh, but be aware that you're sharing that with RT.
If you want to connect to an external DB from within some RT code, you
want to review perldoc DBI.

-kevin

> ________________________________________
> From: rt-users-bounces@lists.bestpractical.com [rt-users-bounces@lists.bestpractical.com] on behalf of Kevin Falcone [falcone@bestpractical.com]
> Sent: 02 March 2012 17:37
> To: rt-users@lists.bestpractical.com
> Subject: Re: [rt-users] Custom database query from within RT
>
> On Fri, Mar 02, 2012 at 01:54:08PM +0000, Renney, Paul wrote:
> > On the create ticket form I need to act upon a change to a drop down menu for a custom field
> > (for this example 'Customer'), look up this value in a database table for a resulting default
> > priority, and change the value in the priority drop down.
> >
> > Ordinarily this wouldn't be hard in a basic HTML form, creating a db connection manually, but
> > I can't find where to start doing this within RT. I'm not sure where I should be putting my db
> > query code. Does RT allow me to put in a custom query somewhere and handle the db connection?
> > Would a scrip be suitable to do what I need?
> >
> > I've searched the mailing list and tutorials but can't find a similar problem. Specific files
> > to change and alternative ideas on how do this would be appreciated as I am new to RT.
>
> Are you doing your lookup inside RT's database or using an external
> database? It sounds like you either want code using RT's API or a DB
> connection running inside a Scrip.
>
> -kevin
>