Mailing List Archive

Append Data to CustomFields
Hi,

I'm still quite new at RT and was wondering if there's a way to have
appendable/updatable CustomFields like the TimeWorked field?

Whenever I update a ticket, the TimeWorked field is blank, any value
(digits) I add will automatically be added to the old value, it'll make a
simple addition.

How can I do the same with CustomFields? Either via the webUI, scrip or
back-end (Update.html ? ModifyAll.html?)

I'm running RT 4.0.5

Thank you!
--
View this message in context: http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33920988.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
Re: Append Data to CustomFields [ In reply to ]
On Mon, May 28, 2012 at 10:44 PM, TheHoboKing
<demon_eyes_kyoms@hotmail.com> wrote:
>
> Hi,
>
> I'm still quite new at RT and was wondering if there's a way to have
> appendable/updatable CustomFields like the TimeWorked field?
>
> Whenever I update a ticket, the TimeWorked field is blank, any value
> (digits) I add will automatically be added to the old value, it'll make a
> simple addition.
>
> How can I do the same with CustomFields? Either via the webUI, scrip or
> back-end (Update.html ? ModifyAll.html?)

With a new custom field type I think. See how Date and IP types are
implemented. It's still wouldn't be clean customization, but a good
start in the right direction.

> I'm running RT 4.0.5
>
> Thank you!
> --
> View this message in context: http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33920988.html
> Sent from the Request Tracker - User mailing list archive at Nabble.com.
>



--
Best regards, Ruslan.
Re: Append Data to CustomFields [ In reply to ]
HoboKing,

You could create a CF with SeeCF rights only to Users and then write a
scrip so that when the TimeWorked field is updated, the scrip subtracts the
old value from the new value and then adds that result to the CF.
You could also add a condition to check the date and if it is month-end or
something you could move the final "TomeWorked" value to a Month-end Time
CF and then zero out the contiguos one.
That way, you won't run into problems of some user entering a non-inter
type value into the field. You might want to grant "ModifyCF" to the
SuperUSer or some management group of users so they can override the value
when necessary.
It all depends on what you want to accomplish.
TimeWorked is already designed to receive integers. So all you really need
is a CF to act as a monthly or yearly, etc. accumulator, along with a
routine to zero out at the end of that cycle.
The best way is to write a cronjob to run through all tickets on whatever
cycle you want to accumulate and have that routine do the
accumulate/move/zero work. That way you get ALL tickets updated
consistently, not just the ones that were updated in a given cycle.

Hope this helps.

Kenn

On Mon, May 28, 2012 at 11:44 AM, TheHoboKing
<demon_eyes_kyoms@hotmail.com>wrote:

>
> Hi,
>
> I'm still quite new at RT and was wondering if there's a way to have
> appendable/updatable CustomFields like the TimeWorked field?
>
> Whenever I update a ticket, the TimeWorked field is blank, any value
> (digits) I add will automatically be added to the old value, it'll make a
> simple addition.
>
> How can I do the same with CustomFields? Either via the webUI, scrip or
> back-end (Update.html ? ModifyAll.html?)
>
> I'm running RT 4.0.5
>
> Thank you!
> --
> View this message in context:
> http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33920988.html
> Sent from the Request Tracker - User mailing list archive at Nabble.com.
>
>
Re: Append Data to CustomFields [ In reply to ]
I would also strongly recommend you look at the "rt-extension-ldapimport", which will allow you to sync groups and users from AD using ldap.

Thanks,
Jok
--
| Joachim Thuau | IT Systems Engineer - Linux / SpaceX |
| Cell: 310-890-7937 | Office: 310-363-6153 |

From: Kenneth Crocker <kenn.crocker@gmail.com<mailto:kenn.crocker@gmail.com>>
Date: Monday, May 28, 2012 6:20 PM
To: RT User List <rt-users@lists.bestpractical.com<mailto:rt-users@lists.bestpractical.com>>
Subject: Re: [rt-users] Append Data to CustomFields

HoboKing,

You could create a CF with SeeCF rights only to Users and then write a scrip so that when the TimeWorked field is updated, the scrip subtracts the old value from the new value and then adds that result to the CF.
You could also add a condition to check the date and if it is month-end or something you could move the final "TomeWorked" value to a Month-end Time CF and then zero out the contiguos one.
That way, you won't run into problems of some user entering a non-inter type value into the field. You might want to grant "ModifyCF" to the SuperUSer or some management group of users so they can override the value when necessary.
It all depends on what you want to accomplish.
TimeWorked is already designed to receive integers. So all you really need is a CF to act as a monthly or yearly, etc. accumulator, along with a routine to zero out at the end of that cycle.
The best way is to write a cronjob to run through all tickets on whatever cycle you want to accumulate and have that routine do the accumulate/move/zero work. That way you get ALL tickets updated consistently, not just the ones that were updated in a given cycle.

Hope this helps.

Kenn

On Mon, May 28, 2012 at 11:44 AM, TheHoboKing <demon_eyes_kyoms@hotmail.com<mailto:demon_eyes_kyoms@hotmail.com>> wrote:

Hi,

I'm still quite new at RT and was wondering if there's a way to have
appendable/updatable CustomFields like the TimeWorked field?

Whenever I update a ticket, the TimeWorked field is blank, any value
(digits) I add will automatically be added to the old value, it'll make a
simple addition.

How can I do the same with CustomFields? Either via the webUI, scrip or
back-end (Update.html ? ModifyAll.html?)

I'm running RT 4.0.5

Thank you!
--
View this message in context: http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33920988.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
Re: Append Data to CustomFields [ In reply to ]
Oops -- this was intended for Rabin, as a reply to his active directory
integration questionĊ 

Jok
--
| Joachim Thuau | IT Systems Engineer - Linux / SpaceX |



On 5/29/12 8:47 AM, "Joachim Thuau" <JThuau@spacex.com> wrote:

>I would also strongly recommend you look at the
>"rt-extension-ldapimport", which will allow you to sync groups and users
>from AD using ldap.
>
>Thanks,
>Jok
>--
>| Joachim Thuau | IT Systems Engineer - Linux / SpaceX |
>| Cell: 310-890-7937 | Office: 310-363-6153 |
>
>From: Kenneth Crocker
><kenn.crocker@gmail.com<mailto:kenn.crocker@gmail.com>>
>Date: Monday, May 28, 2012 6:20 PM
>To: RT User List
><rt-users@lists.bestpractical.com<mailto:rt-users@lists.bestpractical.com>
>>
>Subject: Re: [rt-users] Append Data to CustomFields
>
>HoboKing,
>
>You could create a CF with SeeCF rights only to Users and then write a
>scrip so that when the TimeWorked field is updated, the scrip subtracts
>the old value from the new value and then adds that result to the CF.
>You could also add a condition to check the date and if it is month-end
>or something you could move the final "TomeWorked" value to a Month-end
>Time CF and then zero out the contiguos one.
>That way, you won't run into problems of some user entering a non-inter
>type value into the field. You might want to grant "ModifyCF" to the
>SuperUSer or some management group of users so they can override the
>value when necessary.
>It all depends on what you want to accomplish.
>TimeWorked is already designed to receive integers. So all you really
>need is a CF to act as a monthly or yearly, etc. accumulator, along with
>a routine to zero out at the end of that cycle.
>The best way is to write a cronjob to run through all tickets on whatever
>cycle you want to accumulate and have that routine do the
>accumulate/move/zero work. That way you get ALL tickets updated
>consistently, not just the ones that were updated in a given cycle.
>
>Hope this helps.
>
>Kenn
>
>On Mon, May 28, 2012 at 11:44 AM, TheHoboKing
><demon_eyes_kyoms@hotmail.com<mailto:demon_eyes_kyoms@hotmail.com>> wrote:
>
>Hi,
>
>I'm still quite new at RT and was wondering if there's a way to have
>appendable/updatable CustomFields like the TimeWorked field?
>
>Whenever I update a ticket, the TimeWorked field is blank, any value
>(digits) I add will automatically be added to the old value, it'll make a
>simple addition.
>
>How can I do the same with CustomFields? Either via the webUI, scrip or
>back-end (Update.html ? ModifyAll.html?)
>
>I'm running RT 4.0.5
>
>Thank you!
>--
>View this message in context:
>http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33920988.html
>Sent from the Request Tracker - User mailing list archive at Nabble.com.
>
>
Re: Append Data to CustomFields [ In reply to ]
Hi Kenneth,

Thank you for the reply and my apologies for the delay, I've been busy with
other projects.

I mentioned the TimeWorked field because that's how I'd like my other 'time'
CFs to behave but here's what I'm trying to achieve in more details.

I have two CFs: Emergency Hours | Schedule Hours
CFs type is 'Enter one value'

On ticket updates (users will most likely only update tickets from the WebUI
via comment/reply action), I'd like those CFs to behave as followed:

On update, the CFs should show no value. If my user(s) enter a value and
update the ticket, the value should be added to the previous value (users
will only be inputting integers).

i.e.:
Emergency Hours current value = 10
Users Update the ticket and adds 15 in the Emergency Hours
Emergency Hours should now display 25

Is there a way to achieve this via script or more in dept RT customization?

-I've tried to create another TimeWorked field but TimeWorked seems to be
all over the place and I couldn't identify the proper sections to add/modify
in order to 'duplicate' TimeWorked.

-I was also thinking if it may be possible to do it via scrip by;
OnComment or OnTransaction
Reading the value of 'Emergency Hours'
Storing the value in a temporary variable
Adding the new value to the old value. .i.e: Emergency Hours =
TemporaryEmergencyHoursTotal + EmergencyHours

-I also thought I could simply create another CF called
'EmergencyHoursTotal' and store the total there BUT then, on ticket display
only 'EmergencyHoursTotal' should be visible and 'Emergency Hours' should be
hidden, on ticket update only 'Emergency Hours' should be visible and
'EmergencyHoursTotal' should be hidden.

I read hiding/displaying specific CF can be achieved via the
MassageCustomFields callback but I don't find much information on how to
code my MassageCustomFields. This is the most informative code I've found in
regards to it.

http://cpansearch.perl.org/src/RUZ/RT-Extension-CustomField-HideEmptyValues-0.01/html/Callbacks/CustomField-HideEmptyValues/Elements/ShowCustomFields/MassageCustomFields

Sorry for my long long post, let me know if I should open a new tread in
regards to the MassageCustomFields info.

Thank you again!




Kenneth Crocker-2 wrote:
>
> HoboKing,
>
> You could create a CF with SeeCF rights only to Users and then write a
> scrip so that when the TimeWorked field is updated, the scrip subtracts
> the
> old value from the new value and then adds that result to the CF.
> You could also add a condition to check the date and if it is month-end or
> something you could move the final "TomeWorked" value to a Month-end Time
> CF and then zero out the contiguos one.
> That way, you won't run into problems of some user entering a non-inter
> type value into the field. You might want to grant "ModifyCF" to the
> SuperUSer or some management group of users so they can override the value
> when necessary.
> It all depends on what you want to accomplish.
> TimeWorked is already designed to receive integers. So all you really need
> is a CF to act as a monthly or yearly, etc. accumulator, along with a
> routine to zero out at the end of that cycle.
> The best way is to write a cronjob to run through all tickets on whatever
> cycle you want to accumulate and have that routine do the
> accumulate/move/zero work. That way you get ALL tickets updated
> consistently, not just the ones that were updated in a given cycle.
>
> Hope this helps.
>
> Kenn
>
> On Mon, May 28, 2012 at 11:44 AM, TheHoboKing
> <demon_eyes_kyoms@hotmail.com>wrote:
>
>>
>> Hi,
>>
>> I'm still quite new at RT and was wondering if there's a way to have
>> appendable/updatable CustomFields like the TimeWorked field?
>>
>> Whenever I update a ticket, the TimeWorked field is blank, any value
>> (digits) I add will automatically be added to the old value, it'll make a
>> simple addition.
>>
>> How can I do the same with CustomFields? Either via the webUI, scrip or
>> back-end (Update.html ? ModifyAll.html?)
>>
>> I'm running RT 4.0.5
>>
>> Thank you!
>> --
>> View this message in context:
>> http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33920988.html
>> Sent from the Request Tracker - User mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33933640.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
Re: Append Data to CustomFields [ In reply to ]
This is easily done with a scrip. You need a Ticket custom field to hold the totals and a Transaction custom field for the users to update during a reply or comment. The scrip will take the transaction custom field value and add it to the ticket custom field value to keep the running total.

I've absolutely done this before but a long time ago. It works great and I've built billing systems off of these values which seems like you are trying to do.

The only "gotcha" and it's a little one because once you start scrip development you'll know this; it is to use TransactionBatch mode on the scrip because that is the only way you will actually be able to see the Transaction custom field values.

Hope that gets you started.

Mike

Sent from my iPhone

On May 30, 2012, at 1:53 PM, TheHoboKing <demon_eyes_kyoms@hotmail.com> wrote:

>
> Hi Kenneth,
>
> Thank you for the reply and my apologies for the delay, I've been busy with
> other projects.
>
> I mentioned the TimeWorked field because that's how I'd like my other 'time'
> CFs to behave but here's what I'm trying to achieve in more details.
>
> I have two CFs: Emergency Hours | Schedule Hours
> CFs type is 'Enter one value'
>
> On ticket updates (users will most likely only update tickets from the WebUI
> via comment/reply action), I'd like those CFs to behave as followed:
>
> On update, the CFs should show no value. If my user(s) enter a value and
> update the ticket, the value should be added to the previous value (users
> will only be inputting integers).
>
> i.e.:
> Emergency Hours current value = 10
> Users Update the ticket and adds 15 in the Emergency Hours
> Emergency Hours should now display 25
>
> Is there a way to achieve this via script or more in dept RT customization?
>
> -I've tried to create another TimeWorked field but TimeWorked seems to be
> all over the place and I couldn't identify the proper sections to add/modify
> in order to 'duplicate' TimeWorked.
>
> -I was also thinking if it may be possible to do it via scrip by;
> OnComment or OnTransaction
> Reading the value of 'Emergency Hours'
> Storing the value in a temporary variable
> Adding the new value to the old value. .i.e: Emergency Hours =
> TemporaryEmergencyHoursTotal + EmergencyHours
>
> -I also thought I could simply create another CF called
> 'EmergencyHoursTotal' and store the total there BUT then, on ticket display
> only 'EmergencyHoursTotal' should be visible and 'Emergency Hours' should be
> hidden, on ticket update only 'Emergency Hours' should be visible and
> 'EmergencyHoursTotal' should be hidden.
>
> I read hiding/displaying specific CF can be achieved via the
> MassageCustomFields callback but I don't find much information on how to
> code my MassageCustomFields. This is the most informative code I've found in
> regards to it.
>
> http://cpansearch.perl.org/src/RUZ/RT-Extension-CustomField-HideEmptyValues-0.01/html/Callbacks/CustomField-HideEmptyValues/Elements/ShowCustomFields/MassageCustomFields
>
> Sorry for my long long post, let me know if I should open a new tread in
> regards to the MassageCustomFields info.
>
> Thank you again!
>
>
>
>
> Kenneth Crocker-2 wrote:
>>
>> HoboKing,
>>
>> You could create a CF with SeeCF rights only to Users and then write a
>> scrip so that when the TimeWorked field is updated, the scrip subtracts
>> the
>> old value from the new value and then adds that result to the CF.
>> You could also add a condition to check the date and if it is month-end or
>> something you could move the final "TomeWorked" value to a Month-end Time
>> CF and then zero out the contiguos one.
>> That way, you won't run into problems of some user entering a non-inter
>> type value into the field. You might want to grant "ModifyCF" to the
>> SuperUSer or some management group of users so they can override the value
>> when necessary.
>> It all depends on what you want to accomplish.
>> TimeWorked is already designed to receive integers. So all you really need
>> is a CF to act as a monthly or yearly, etc. accumulator, along with a
>> routine to zero out at the end of that cycle.
>> The best way is to write a cronjob to run through all tickets on whatever
>> cycle you want to accumulate and have that routine do the
>> accumulate/move/zero work. That way you get ALL tickets updated
>> consistently, not just the ones that were updated in a given cycle.
>>
>> Hope this helps.
>>
>> Kenn
>>
>> On Mon, May 28, 2012 at 11:44 AM, TheHoboKing
>> <demon_eyes_kyoms@hotmail.com>wrote:
>>
>>>
>>> Hi,
>>>
>>> I'm still quite new at RT and was wondering if there's a way to have
>>> appendable/updatable CustomFields like the TimeWorked field?
>>>
>>> Whenever I update a ticket, the TimeWorked field is blank, any value
>>> (digits) I add will automatically be added to the old value, it'll make a
>>> simple addition.
>>>
>>> How can I do the same with CustomFields? Either via the webUI, scrip or
>>> back-end (Update.html ? ModifyAll.html?)
>>>
>>> I'm running RT 4.0.5
>>>
>>> Thank you!
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33920988.html
>>> Sent from the Request Tracker - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
> --
> View this message in context: http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33933640.html
> Sent from the Request Tracker - User mailing list archive at Nabble.com.
>
Re: Append Data to CustomFields [ In reply to ]
Mike,

Yes, I believe this could be done with a scrip. I'd do all the calc work
with temp fields (defined in the perl code) and then put the results in the
CF.
Be careful to name your fields with a name that cannot be confused with an
RT delivered field. It's just not a clean way to go.
Also, make sure your condition for the update is when the exact field you
want to change has been updated and not just any update to the ticket.
This might mean creating an update scrip for each individual CF you want to
do this to. RT will execute all of them. Make they are set to TransBatch.

Kenn

On Wed, May 30, 2012 at 2:44 PM, Michael Coakley <mike.coakley@gmail.com>wrote:

> This is easily done with a scrip. You need a Ticket custom field to hold
> the totals and a Transaction custom field for the users to update during a
> reply or comment. The scrip will take the transaction custom field value
> and add it to the ticket custom field value to keep the running total.
>
> I've absolutely done this before but a long time ago. It works great and
> I've built billing systems off of these values which seems like you are
> trying to do.
>
> The only "gotcha" and it's a little one because once you start scrip
> development you'll know this; it is to use TransactionBatch mode on the
> scrip because that is the only way you will actually be able to see the
> Transaction custom field values.
>
> Hope that gets you started.
>
> Mike
>
> Sent from my iPhone
>
> On May 30, 2012, at 1:53 PM, TheHoboKing <demon_eyes_kyoms@hotmail.com>
> wrote:
>
> >
> > Hi Kenneth,
> >
> > Thank you for the reply and my apologies for the delay, I've been busy
> with
> > other projects.
> >
> > I mentioned the TimeWorked field because that's how I'd like my other
> 'time'
> > CFs to behave but here's what I'm trying to achieve in more details.
> >
> > I have two CFs: Emergency Hours | Schedule Hours
> > CFs type is 'Enter one value'
> >
> > On ticket updates (users will most likely only update tickets from the
> WebUI
> > via comment/reply action), I'd like those CFs to behave as followed:
> >
> > On update, the CFs should show no value. If my user(s) enter a value and
> > update the ticket, the value should be added to the previous value (users
> > will only be inputting integers).
> >
> > i.e.:
> > Emergency Hours current value = 10
> > Users Update the ticket and adds 15 in the Emergency Hours
> > Emergency Hours should now display 25
> >
> > Is there a way to achieve this via script or more in dept RT
> customization?
> >
> > -I've tried to create another TimeWorked field but TimeWorked seems to be
> > all over the place and I couldn't identify the proper sections to
> add/modify
> > in order to 'duplicate' TimeWorked.
> >
> > -I was also thinking if it may be possible to do it via scrip by;
> > OnComment or OnTransaction
> > Reading the value of 'Emergency Hours'
> > Storing the value in a temporary variable
> > Adding the new value to the old value. .i.e: Emergency Hours =
> > TemporaryEmergencyHoursTotal + EmergencyHours
> >
> > -I also thought I could simply create another CF called
> > 'EmergencyHoursTotal' and store the total there BUT then, on ticket
> display
> > only 'EmergencyHoursTotal' should be visible and 'Emergency Hours'
> should be
> > hidden, on ticket update only 'Emergency Hours' should be visible and
> > 'EmergencyHoursTotal' should be hidden.
> >
> > I read hiding/displaying specific CF can be achieved via the
> > MassageCustomFields callback but I don't find much information on how to
> > code my MassageCustomFields. This is the most informative code I've
> found in
> > regards to it.
> >
> >
> http://cpansearch.perl.org/src/RUZ/RT-Extension-CustomField-HideEmptyValues-0.01/html/Callbacks/CustomField-HideEmptyValues/Elements/ShowCustomFields/MassageCustomFields
> >
> > Sorry for my long long post, let me know if I should open a new tread in
> > regards to the MassageCustomFields info.
> >
> > Thank you again!
> >
> >
> >
> >
> > Kenneth Crocker-2 wrote:
> >>
> >> HoboKing,
> >>
> >> You could create a CF with SeeCF rights only to Users and then write a
> >> scrip so that when the TimeWorked field is updated, the scrip subtracts
> >> the
> >> old value from the new value and then adds that result to the CF.
> >> You could also add a condition to check the date and if it is month-end
> or
> >> something you could move the final "TomeWorked" value to a Month-end
> Time
> >> CF and then zero out the contiguos one.
> >> That way, you won't run into problems of some user entering a non-inter
> >> type value into the field. You might want to grant "ModifyCF" to the
> >> SuperUSer or some management group of users so they can override the
> value
> >> when necessary.
> >> It all depends on what you want to accomplish.
> >> TimeWorked is already designed to receive integers. So all you really
> need
> >> is a CF to act as a monthly or yearly, etc. accumulator, along with a
> >> routine to zero out at the end of that cycle.
> >> The best way is to write a cronjob to run through all tickets on
> whatever
> >> cycle you want to accumulate and have that routine do the
> >> accumulate/move/zero work. That way you get ALL tickets updated
> >> consistently, not just the ones that were updated in a given cycle.
> >>
> >> Hope this helps.
> >>
> >> Kenn
> >>
> >> On Mon, May 28, 2012 at 11:44 AM, TheHoboKing
> >> <demon_eyes_kyoms@hotmail.com>wrote:
> >>
> >>>
> >>> Hi,
> >>>
> >>> I'm still quite new at RT and was wondering if there's a way to have
> >>> appendable/updatable CustomFields like the TimeWorked field?
> >>>
> >>> Whenever I update a ticket, the TimeWorked field is blank, any value
> >>> (digits) I add will automatically be added to the old value, it'll
> make a
> >>> simple addition.
> >>>
> >>> How can I do the same with CustomFields? Either via the webUI, scrip or
> >>> back-end (Update.html ? ModifyAll.html?)
> >>>
> >>> I'm running RT 4.0.5
> >>>
> >>> Thank you!
> >>> --
> >>> View this message in context:
> >>>
> http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33920988.html
> >>> Sent from the Request Tracker - User mailing list archive at
> Nabble.com.
> >>>
> >>>
> >>
> >>
> > --
> > View this message in context:
> http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33933640.html
> > Sent from the Request Tracker - User mailing list archive at Nabble.com.
> >
>
Re: Append Data to CustomFields [ In reply to ]
Mike,

Thank you for the information, that's exactly what I was looking for.

Now, I tried to build a scrip from different online sources (I just started
learning Perl ...) but I'm never able to get the value from the Transaction
Custom Field.

I saw an earlier post from you describing pretty much what I'm trying to
achieve.

http://www.mail-archive.com/rt-users@lists.bestpractical.com/msg02029.html

Is there any chance you could send me the scrip?

P.S: I'll post my scrip early tomorrow as I'm no longer in the
office....perhaps someone can shed some light on the multiple things I must
be doing wrong.

Thank you!



Michael Coakley wrote:
>
> This is easily done with a scrip. You need a Ticket custom field to hold
> the totals and a Transaction custom field for the users to update during a
> reply or comment. The scrip will take the transaction custom field value
> and add it to the ticket custom field value to keep the running total.
>
> I've absolutely done this before but a long time ago. It works great and
> I've built billing systems off of these values which seems like you are
> trying to do.
>
> The only "gotcha" and it's a little one because once you start scrip
> development you'll know this; it is to use TransactionBatch mode on the
> scrip because that is the only way you will actually be able to see the
> Transaction custom field values.
>
> Hope that gets you started.
>
> Mike
>
> Sent from my iPhone
>
> On May 30, 2012, at 1:53 PM, TheHoboKing <demon_eyes_kyoms@hotmail.com>
> wrote:
>
>>
>> Hi Kenneth,
>>
>> Thank you for the reply and my apologies for the delay, I've been busy
>> with
>> other projects.
>>
>> I mentioned the TimeWorked field because that's how I'd like my other
>> 'time'
>> CFs to behave but here's what I'm trying to achieve in more details.
>>
>> I have two CFs: Emergency Hours | Schedule Hours
>> CFs type is 'Enter one value'
>>
>> On ticket updates (users will most likely only update tickets from the
>> WebUI
>> via comment/reply action), I'd like those CFs to behave as followed:
>>
>> On update, the CFs should show no value. If my user(s) enter a value and
>> update the ticket, the value should be added to the previous value (users
>> will only be inputting integers).
>>
>> i.e.:
>> Emergency Hours current value = 10
>> Users Update the ticket and adds 15 in the Emergency Hours
>> Emergency Hours should now display 25
>>
>> Is there a way to achieve this via script or more in dept RT
>> customization?
>>
>> -I've tried to create another TimeWorked field but TimeWorked seems to be
>> all over the place and I couldn't identify the proper sections to
>> add/modify
>> in order to 'duplicate' TimeWorked.
>>
>> -I was also thinking if it may be possible to do it via scrip by;
>> OnComment or OnTransaction
>> Reading the value of 'Emergency Hours'
>> Storing the value in a temporary variable
>> Adding the new value to the old value. .i.e: Emergency Hours =
>> TemporaryEmergencyHoursTotal + EmergencyHours
>>
>> -I also thought I could simply create another CF called
>> 'EmergencyHoursTotal' and store the total there BUT then, on ticket
>> display
>> only 'EmergencyHoursTotal' should be visible and 'Emergency Hours' should
>> be
>> hidden, on ticket update only 'Emergency Hours' should be visible and
>> 'EmergencyHoursTotal' should be hidden.
>>
>> I read hiding/displaying specific CF can be achieved via the
>> MassageCustomFields callback but I don't find much information on how to
>> code my MassageCustomFields. This is the most informative code I've found
>> in
>> regards to it.
>>
>> http://cpansearch.perl.org/src/RUZ/RT-Extension-CustomField-HideEmptyValues-0.01/html/Callbacks/CustomField-HideEmptyValues/Elements/ShowCustomFields/MassageCustomFields
>>
>> Sorry for my long long post, let me know if I should open a new tread in
>> regards to the MassageCustomFields info.
>>
>> Thank you again!
>>
>>
>>
>>
>> Kenneth Crocker-2 wrote:
>>>
>>> HoboKing,
>>>
>>> You could create a CF with SeeCF rights only to Users and then write a
>>> scrip so that when the TimeWorked field is updated, the scrip subtracts
>>> the
>>> old value from the new value and then adds that result to the CF.
>>> You could also add a condition to check the date and if it is month-end
>>> or
>>> something you could move the final "TomeWorked" value to a Month-end
>>> Time
>>> CF and then zero out the contiguos one.
>>> That way, you won't run into problems of some user entering a non-inter
>>> type value into the field. You might want to grant "ModifyCF" to the
>>> SuperUSer or some management group of users so they can override the
>>> value
>>> when necessary.
>>> It all depends on what you want to accomplish.
>>> TimeWorked is already designed to receive integers. So all you really
>>> need
>>> is a CF to act as a monthly or yearly, etc. accumulator, along with a
>>> routine to zero out at the end of that cycle.
>>> The best way is to write a cronjob to run through all tickets on
>>> whatever
>>> cycle you want to accumulate and have that routine do the
>>> accumulate/move/zero work. That way you get ALL tickets updated
>>> consistently, not just the ones that were updated in a given cycle.
>>>
>>> Hope this helps.
>>>
>>> Kenn
>>>
>>> On Mon, May 28, 2012 at 11:44 AM, TheHoboKing
>>> <demon_eyes_kyoms@hotmail.com>wrote:
>>>
>>>>
>>>> Hi,
>>>>
>>>> I'm still quite new at RT and was wondering if there's a way to have
>>>> appendable/updatable CustomFields like the TimeWorked field?
>>>>
>>>> Whenever I update a ticket, the TimeWorked field is blank, any value
>>>> (digits) I add will automatically be added to the old value, it'll make
>>>> a
>>>> simple addition.
>>>>
>>>> How can I do the same with CustomFields? Either via the webUI, scrip or
>>>> back-end (Update.html ? ModifyAll.html?)
>>>>
>>>> I'm running RT 4.0.5
>>>>
>>>> Thank you!
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33920988.html
>>>> Sent from the Request Tracker - User mailing list archive at
>>>> Nabble.com.
>>>>
>>>>
>>>
>>>
>> --
>> View this message in context:
>> http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33933640.html
>> Sent from the Request Tracker - User mailing list archive at Nabble.com.
>>
>
>
--
View this message in context: http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33941340.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
Re: Append Data to CustomFields [ In reply to ]
After some research and trial and errors I finally realise extracting values
from Transaction CFs is no longer possible.

The feature has been removed since RT 3.6 and doesn't seem to have been
successfully implemented again. Mike seems to be the last reported
successful extraction of CFs and such. (If anyone has a patch or successful
scrip/solution to extract values from Trans-CFs, please by all means come
forward and tell me how wrong I am)

Now, for anyone interested, here's how I 'solved' my issue. Probably not the
cleanest, efficient way but it works for me.

I installed the RT::Extension::CustomFieldsOnUpdate extension in order to
have CFs on the Update form. Created 4 CFs, provided See and
ModifyCustomField rights to my users group to 2 CFs and SeeCustomField to
the other 2. This allowed the users to only see 2 fields during during the
Ticket Update process (the other 2 CFs were not visible since users didn't
have ModifyCustomField right)

My total is stored in the CFs which users cannot modify (since the scrip
makes the mod, update on the CF works fine). At every transaction, I check
the value of the hidden field, and add the value of the visible field (user
input) and store back the new total value in the hidden field, I then reset
the visible field to <nothing>.

Thank you all for your help



TheHoboKing wrote:
>
> Mike,
>
> Thank you for the information, that's exactly what I was looking for.
>
> Now, I tried to build a scrip from different online sources (I just
> started learning Perl ...) but I'm never able to get the value from the
> Transaction Custom Field.
>
> I saw an earlier post from you describing pretty much what I'm trying to
> achieve.
>
> http://www.mail-archive.com/rt-users@lists.bestpractical.com/msg02029.html
>
> Is there any chance you could send me the scrip?
>
> P.S: I'll post my scrip early tomorrow as I'm no longer in the
> office....perhaps someone can shed some light on the multiple things I
> must be doing wrong.
>
> Thank you!
>
>
>
> Michael Coakley wrote:
>>
>> This is easily done with a scrip. You need a Ticket custom field to hold
>> the totals and a Transaction custom field for the users to update during
>> a reply or comment. The scrip will take the transaction custom field
>> value and add it to the ticket custom field value to keep the running
>> total.
>>
>> I've absolutely done this before but a long time ago. It works great and
>> I've built billing systems off of these values which seems like you are
>> trying to do.
>>
>> The only "gotcha" and it's a little one because once you start scrip
>> development you'll know this; it is to use TransactionBatch mode on the
>> scrip because that is the only way you will actually be able to see the
>> Transaction custom field values.
>>
>> Hope that gets you started.
>>
>> Mike
>>
>> Sent from my iPhone
>>
>> On May 30, 2012, at 1:53 PM, TheHoboKing <demon_eyes_kyoms@hotmail.com>
>> wrote:
>>
>>>
>>> Hi Kenneth,
>>>
>>> Thank you for the reply and my apologies for the delay, I've been busy
>>> with
>>> other projects.
>>>
>>> I mentioned the TimeWorked field because that's how I'd like my other
>>> 'time'
>>> CFs to behave but here's what I'm trying to achieve in more details.
>>>
>>> I have two CFs: Emergency Hours | Schedule Hours
>>> CFs type is 'Enter one value'
>>>
>>> On ticket updates (users will most likely only update tickets from the
>>> WebUI
>>> via comment/reply action), I'd like those CFs to behave as followed:
>>>
>>> On update, the CFs should show no value. If my user(s) enter a value and
>>> update the ticket, the value should be added to the previous value
>>> (users
>>> will only be inputting integers).
>>>
>>> i.e.:
>>> Emergency Hours current value = 10
>>> Users Update the ticket and adds 15 in the Emergency Hours
>>> Emergency Hours should now display 25
>>>
>>> Is there a way to achieve this via script or more in dept RT
>>> customization?
>>>
>>> -I've tried to create another TimeWorked field but TimeWorked seems to
>>> be
>>> all over the place and I couldn't identify the proper sections to
>>> add/modify
>>> in order to 'duplicate' TimeWorked.
>>>
>>> -I was also thinking if it may be possible to do it via scrip by;
>>> OnComment or OnTransaction
>>> Reading the value of 'Emergency Hours'
>>> Storing the value in a temporary variable
>>> Adding the new value to the old value. .i.e: Emergency Hours =
>>> TemporaryEmergencyHoursTotal + EmergencyHours
>>>
>>> -I also thought I could simply create another CF called
>>> 'EmergencyHoursTotal' and store the total there BUT then, on ticket
>>> display
>>> only 'EmergencyHoursTotal' should be visible and 'Emergency Hours'
>>> should be
>>> hidden, on ticket update only 'Emergency Hours' should be visible and
>>> 'EmergencyHoursTotal' should be hidden.
>>>
>>> I read hiding/displaying specific CF can be achieved via the
>>> MassageCustomFields callback but I don't find much information on how to
>>> code my MassageCustomFields. This is the most informative code I've
>>> found in
>>> regards to it.
>>>
>>> http://cpansearch.perl.org/src/RUZ/RT-Extension-CustomField-HideEmptyValues-0.01/html/Callbacks/CustomField-HideEmptyValues/Elements/ShowCustomFields/MassageCustomFields
>>>
>>> Sorry for my long long post, let me know if I should open a new tread in
>>> regards to the MassageCustomFields info.
>>>
>>> Thank you again!
>>>
>>>
>>>
>>>
>>> Kenneth Crocker-2 wrote:
>>>>
>>>> HoboKing,
>>>>
>>>> You could create a CF with SeeCF rights only to Users and then write a
>>>> scrip so that when the TimeWorked field is updated, the scrip subtracts
>>>> the
>>>> old value from the new value and then adds that result to the CF.
>>>> You could also add a condition to check the date and if it is month-end
>>>> or
>>>> something you could move the final "TomeWorked" value to a Month-end
>>>> Time
>>>> CF and then zero out the contiguos one.
>>>> That way, you won't run into problems of some user entering a non-inter
>>>> type value into the field. You might want to grant "ModifyCF" to the
>>>> SuperUSer or some management group of users so they can override the
>>>> value
>>>> when necessary.
>>>> It all depends on what you want to accomplish.
>>>> TimeWorked is already designed to receive integers. So all you really
>>>> need
>>>> is a CF to act as a monthly or yearly, etc. accumulator, along with a
>>>> routine to zero out at the end of that cycle.
>>>> The best way is to write a cronjob to run through all tickets on
>>>> whatever
>>>> cycle you want to accumulate and have that routine do the
>>>> accumulate/move/zero work. That way you get ALL tickets updated
>>>> consistently, not just the ones that were updated in a given cycle.
>>>>
>>>> Hope this helps.
>>>>
>>>> Kenn
>>>>
>>>> On Mon, May 28, 2012 at 11:44 AM, TheHoboKing
>>>> <demon_eyes_kyoms@hotmail.com>wrote:
>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> I'm still quite new at RT and was wondering if there's a way to have
>>>>> appendable/updatable CustomFields like the TimeWorked field?
>>>>>
>>>>> Whenever I update a ticket, the TimeWorked field is blank, any value
>>>>> (digits) I add will automatically be added to the old value, it'll
>>>>> make a
>>>>> simple addition.
>>>>>
>>>>> How can I do the same with CustomFields? Either via the webUI, scrip
>>>>> or
>>>>> back-end (Update.html ? ModifyAll.html?)
>>>>>
>>>>> I'm running RT 4.0.5
>>>>>
>>>>> Thank you!
>>>>> --
>>>>> View this message in context:
>>>>> http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33920988.html
>>>>> Sent from the Request Tracker - User mailing list archive at
>>>>> Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33933640.html
>>> Sent from the Request Tracker - User mailing list archive at Nabble.com.
>>>
>>
>>
>
--
View this message in context: http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33958003.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
Re: Append Data to CustomFields [ In reply to ]
On 06/04/2012 09:46 AM, TheHoboKing wrote:
> After some research and trial and errors I finally realise extracting values
> from Transaction CFs is no longer possible.
>
> The feature has been removed since RT 3.6 and doesn't seem to have been
> successfully implemented again. Mike seems to be the last reported
> successful extraction of CFs and such. (If anyone has a patch or successful
> scrip/solution to extract values from Trans-CFs, please by all means come
> forward and tell me how wrong I am)

You can absolutely read back out values from Transaction CFs.
Unfortunately we can't guess what you're doing or why it's not working
without seeing the code. I suspect in your attempts you didn't follow
Mike's warning about needing to use the TransactionBatch stage for your
scrips.

Thomas
Re: Append Data to CustomFields [ In reply to ]
Hi Thomas,

Yes, I did attempt with TransactionBatch (and Create), the value obtained
from the Transaction CF is always ' ' as if it's unable to capture the
actual value.

Here's the code I was using, I've tried with different variation but was
never able to get the value that was being added in the Trans-CFs.

As a test, I was simply trying to get the value from the Trans-CFs and right
it back in a Ticket CF.

--------------
Custom Condition:
return 1;

Custom action preparation code:
return 1;

Custom action cleanup code:
my $ticket = $self->TicketObj;
my $cf_obj = RT::CustomField->new( $RT::SystemUser );

my $cf_name = "ValueFrom_tr-cf";
my $trcf_name = "tr-cf";

my $trcf_value = "1";

#Read and store the value of the Transaction CF "tr-cf"

$cf_obj->LoadByName(Name=>$trcf_name);
$trcf_value = $ticket->FirstCustomFieldValue($trcf_name);

#Add the value to the Ticket CF
$cf_obj->LoadByName(Name=>$cf_name);
$ticket->AddCustomFieldValue(Field=>$cf_obj, Value=>$trcf_value,
RecordTransaction=>0);

return 1;

---------------------------------------------------

Any ideas on what could be going wrong?

Thank you


Thomas Sibley wrote:
>
> On 06/04/2012 09:46 AM, TheHoboKing wrote:
>> After some research and trial and errors I finally realise extracting
>> values
>> from Transaction CFs is no longer possible.
>>
>> The feature has been removed since RT 3.6 and doesn't seem to have been
>> successfully implemented again. Mike seems to be the last reported
>> successful extraction of CFs and such. (If anyone has a patch or
>> successful
>> scrip/solution to extract values from Trans-CFs, please by all means come
>> forward and tell me how wrong I am)
>
> You can absolutely read back out values from Transaction CFs.
> Unfortunately we can't guess what you're doing or why it's not working
> without seeing the code. I suspect in your attempts you didn't follow
> Mike's warning about needing to use the TransactionBatch stage for your
> scrips.
>
> Thomas
>
>
--
View this message in context: http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33958371.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
Re: Append Data to CustomFields [ In reply to ]
You are trying to get the transaction value from the ticket. You need to use the transaction object.

I'm on my phone so I can't reply with example code. If someone else doesn't supply any I'll reply with some later.

Mike

Sent from my iPhone

On Jun 4, 2012, at 10:42 AM, TheHoboKing <demon_eyes_kyoms@hotmail.com> wrote:

>
> Hi Thomas,
>
> Yes, I did attempt with TransactionBatch (and Create), the value obtained
> from the Transaction CF is always ' ' as if it's unable to capture the
> actual value.
>
> Here's the code I was using, I've tried with different variation but was
> never able to get the value that was being added in the Trans-CFs.
>
> As a test, I was simply trying to get the value from the Trans-CFs and right
> it back in a Ticket CF.
>
> --------------
> Custom Condition:
> return 1;
>
> Custom action preparation code:
> return 1;
>
> Custom action cleanup code:
> my $ticket = $self->TicketObj;
> my $cf_obj = RT::CustomField->new( $RT::SystemUser );
>
> my $cf_name = "ValueFrom_tr-cf";
> my $trcf_name = "tr-cf";
>
> my $trcf_value = "1";
>
> #Read and store the value of the Transaction CF "tr-cf"
>
> $cf_obj->LoadByName(Name=>$trcf_name);
> $trcf_value = $ticket->FirstCustomFieldValue($trcf_name);
>
> #Add the value to the Ticket CF
> $cf_obj->LoadByName(Name=>$cf_name);
> $ticket->AddCustomFieldValue(Field=>$cf_obj, Value=>$trcf_value,
> RecordTransaction=>0);
>
> return 1;
>
> ---------------------------------------------------
>
> Any ideas on what could be going wrong?
>
> Thank you
>
>
> Thomas Sibley wrote:
>>
>> On 06/04/2012 09:46 AM, TheHoboKing wrote:
>>> After some research and trial and errors I finally realise extracting
>>> values
>>> from Transaction CFs is no longer possible.
>>>
>>> The feature has been removed since RT 3.6 and doesn't seem to have been
>>> successfully implemented again. Mike seems to be the last reported
>>> successful extraction of CFs and such. (If anyone has a patch or
>>> successful
>>> scrip/solution to extract values from Trans-CFs, please by all means come
>>> forward and tell me how wrong I am)
>>
>> You can absolutely read back out values from Transaction CFs.
>> Unfortunately we can't guess what you're doing or why it's not working
>> without seeing the code. I suspect in your attempts you didn't follow
>> Mike's warning about needing to use the TransactionBatch stage for your
>> scrips.
>>
>> Thomas
>>
>>
> --
> View this message in context: http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33958371.html
> Sent from the Request Tracker - User mailing list archive at Nabble.com.
>
Re: Append Data to CustomFields [ In reply to ]
I didn't see anyone else reply so here is some template code (very wordy to be clear) that should get you going...

Custom Condition

# Get the transaction object
my $TransObj = $self->TransactionObj;

# Make sure the transaction is a Comment before we check anything else
unless ($TransObj->Type eq "Comment") {
return 0;
}

# Now get the custom field value for our transaction
my $TransCustomFieldName = "TransCustomFieldName";
my $TransCustomFieldValue = $transObj->FirstCustomFieldValue($TransCustomFieldName);

# Log it for debugging
# NOTE: I always log with the queue name because I may use the same type of routine in multiple queues
$RT::Logger->debug("$self->TicketObj->QueueObj->Name: $TransCustomFieldName = $TransCustomFieldValue");

# return 0 unless our value changed
return 0 unless ($TransCustomFieldValue != 0);

1;

Preparation Code

1;

Clean-up Code

my $TicketObj = $self->TicketObj;
my $TransObj = $self->TransactionObj;
my $QueueObj = $TicketObj->QueueObj;

# First get the current value of our Ticket Custom field we want to update
my $TransCustomFieldName = "TransCustomFIeldName";
my $TransCustomFIeldValue = $TransObj->FirstCustomFieldValue($TransCustomFieldName);
# Make sure to normalize your Transaction Custom Field Value if needed (in this case it isn't but if you are processing multiple Transaction Custom Fields it may be)
# if (!$TransCustomFieldValue) { $TransCustomFieldValue = 0; }

# This code looks different because it is pulled right from the Wiki with some simple modifications. Best to keep the same structure for maintainability.
my $CFName = "TicketCustomFIeldName";
my $CFValue = $TicketObj->FirstCustomFieldValue($CFName);
# Make sure you normalize your Ticket Custom Field Value too
if (!$CFValue) { $CFValue = 0; }

# Or whatever you want to do with it...
$CFValue += $TransCustomFieldValue;

my $DefaultValue = '0';
my $RecTransaction = 1;
$RT::Logger->debug("$QueueObj->Name: $CFName -> $CFValue");

my $CFObj = RT::CustomField->new($QueueObj->CurrentUser);
$CFObj->LoadByNameAndQueue(Name => $CFName, Queue => $QueueObj->id);
unless ($CFObj->id) {
$CFObj->LoadByNameAndQueue(Name => $CFName, Queue => 0);
unless ($CFObj->id) {
$RT::Logger->debug("$QueueObj->Name: $CFName doesn't exist, Queue - " . $QueueObj->Name);
return undef;
}
}
my($result, $msg) = $TicketObj->AddCustomFieldValue(
Field => $CFObj->id,
Value => $CFValue,
RecordTransaction => $RecTransaction
);
unless ($result) {
$RT::Logger->debug("$QueueObj->Name: Couldn't set $CFValue as value for CF $CFName : $msg");
return undef;
}

1;

NOTES:

1. Make sure you change the TransCustomFieldName variable to your actual field name
2. You may have to change the check to see if your field value changed. For my type of field in this scrip it was simple enough to do the test I'm doing. (Also, I'm a Perl newb so don't think this is pretty Perl.)
3. Make sure you change the CFName variable to your actual field name
4. Make sure you normalize your TicketCustomFieldValue variable just in case it hasn't been set yet. Additive values are never fun when you start with an unknown
5. MUST BE TransactionBatch
6. Use at your own peril, I haven't tested this code and it is freely given to the public domain as-is, enjoy!

I hoe that helps.

Thanks,

Mike

On Jun 4, 2012, at 10:42 AM, TheHoboKing wrote:

>
> Hi Thomas,
>
> Yes, I did attempt with TransactionBatch (and Create), the value obtained
> from the Transaction CF is always ' ' as if it's unable to capture the
> actual value.
>
> Here's the code I was using, I've tried with different variation but was
> never able to get the value that was being added in the Trans-CFs.
>
> As a test, I was simply trying to get the value from the Trans-CFs and right
> it back in a Ticket CF.
>
> --------------
> Custom Condition:
> return 1;
>
> Custom action preparation code:
> return 1;
>
> Custom action cleanup code:
> my $ticket = $self->TicketObj;
> my $cf_obj = RT::CustomField->new( $RT::SystemUser );
>
> my $cf_name = "ValueFrom_tr-cf";
> my $trcf_name = "tr-cf";
>
> my $trcf_value = "1";
>
> #Read and store the value of the Transaction CF "tr-cf"
>
> $cf_obj->LoadByName(Name=>$trcf_name);
> $trcf_value = $ticket->FirstCustomFieldValue($trcf_name);
>
> #Add the value to the Ticket CF
> $cf_obj->LoadByName(Name=>$cf_name);
> $ticket->AddCustomFieldValue(Field=>$cf_obj, Value=>$trcf_value,
> RecordTransaction=>0);
>
> return 1;
>
> ---------------------------------------------------
>
> Any ideas on what could be going wrong?
>
> Thank you
>
>
> Thomas Sibley wrote:
>>
>> On 06/04/2012 09:46 AM, TheHoboKing wrote:
>>> After some research and trial and errors I finally realise extracting
>>> values
>>> from Transaction CFs is no longer possible.
>>>
>>> The feature has been removed since RT 3.6 and doesn't seem to have been
>>> successfully implemented again. Mike seems to be the last reported
>>> successful extraction of CFs and such. (If anyone has a patch or
>>> successful
>>> scrip/solution to extract values from Trans-CFs, please by all means come
>>> forward and tell me how wrong I am)
>>
>> You can absolutely read back out values from Transaction CFs.
>> Unfortunately we can't guess what you're doing or why it's not working
>> without seeing the code. I suspect in your attempts you didn't follow
>> Mike's warning about needing to use the TransactionBatch stage for your
>> scrips.
>>
>> Thomas
>>
>>
> --
> View this message in context: http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33958371.html
> Sent from the Request Tracker - User mailing list archive at Nabble.com.
>
Re: Append Data to CustomFields[SOLVED] [ In reply to ]
Hi Mike,

Thank you for the code and explanation, this is exactly what I needed.

The code works like a charm, just had to correct some minor typos in some
variable calls.

I'm glad to say I was terribly wrong when I said it was no longer possible
to obtain the value from Transaction CFs via scrips.

Thank you all for your time and help



Michael Coakley wrote:
>
> I didn't see anyone else reply so here is some template code (very wordy
> to be clear) that should get you going...
>
> Custom Condition
>
> # Get the transaction object
> my $TransObj = $self->TransactionObj;
>
> # Make sure the transaction is a Comment before we check anything else
> unless ($TransObj->Type eq "Comment") {
> return 0;
> }
>
> # Now get the custom field value for our transaction
> my $TransCustomFieldName = "TransCustomFieldName";
> my $TransCustomFieldValue =
> $transObj->FirstCustomFieldValue($TransCustomFieldName);
>
> # Log it for debugging
> # NOTE: I always log with the queue name because I may use the same type
> of routine in multiple queues
> $RT::Logger->debug("$self->TicketObj->QueueObj->Name:
> $TransCustomFieldName = $TransCustomFieldValue");
>
> # return 0 unless our value changed
> return 0 unless ($TransCustomFieldValue != 0);
>
> 1;
>
> Preparation Code
>
> 1;
>
> Clean-up Code
>
> my $TicketObj = $self->TicketObj;
> my $TransObj = $self->TransactionObj;
> my $QueueObj = $TicketObj->QueueObj;
>
> # First get the current value of our Ticket Custom field we want to update
> my $TransCustomFieldName = "TransCustomFIeldName";
> my $TransCustomFIeldValue =
> $TransObj->FirstCustomFieldValue($TransCustomFieldName);
> # Make sure to normalize your Transaction Custom Field Value if needed (in
> this case it isn't but if you are processing multiple Transaction Custom
> Fields it may be)
> # if (!$TransCustomFieldValue) { $TransCustomFieldValue = 0; }
>
> # This code looks different because it is pulled right from the Wiki with
> some simple modifications. Best to keep the same structure for
> maintainability.
> my $CFName = "TicketCustomFIeldName";
> my $CFValue = $TicketObj->FirstCustomFieldValue($CFName);
> # Make sure you normalize your Ticket Custom Field Value too
> if (!$CFValue) { $CFValue = 0; }
>
> # Or whatever you want to do with it...
> $CFValue += $TransCustomFieldValue;
>
> my $DefaultValue = '0';
> my $RecTransaction = 1;
> $RT::Logger->debug("$QueueObj->Name: $CFName -> $CFValue");
>
> my $CFObj = RT::CustomField->new($QueueObj->CurrentUser);
> $CFObj->LoadByNameAndQueue(Name => $CFName, Queue => $QueueObj->id);
> unless ($CFObj->id) {
> $CFObj->LoadByNameAndQueue(Name => $CFName, Queue => 0);
> unless ($CFObj->id) {
> $RT::Logger->debug("$QueueObj->Name: $CFName doesn't exist, Queue
> - " . $QueueObj->Name);
> return undef;
> }
> }
> my($result, $msg) = $TicketObj->AddCustomFieldValue(
> Field => $CFObj->id,
> Value => $CFValue,
> RecordTransaction => $RecTransaction
> );
> unless ($result) {
> $RT::Logger->debug("$QueueObj->Name: Couldn't set $CFValue as value
> for CF $CFName : $msg");
> return undef;
> }
>
> 1;
>
> NOTES:
>
> 1. Make sure you change the TransCustomFieldName variable to your actual
> field name
> 2. You may have to change the check to see if your field value changed.
> For my type of field in this scrip it was simple enough to do the test I'm
> doing. (Also, I'm a Perl newb so don't think this is pretty Perl.)
> 3. Make sure you change the CFName variable to your actual field name
> 4. Make sure you normalize your TicketCustomFieldValue variable just in
> case it hasn't been set yet. Additive values are never fun when you start
> with an unknown
> 5. MUST BE TransactionBatch
> 6. Use at your own peril, I haven't tested this code and it is freely
> given to the public domain as-is, enjoy!
>
> I hoe that helps.
>
> Thanks,
>
> Mike
>
> On Jun 4, 2012, at 10:42 AM, TheHoboKing wrote:
>
>>
>> Hi Thomas,
>>
>> Yes, I did attempt with TransactionBatch (and Create), the value obtained
>> from the Transaction CF is always ' ' as if it's unable to capture the
>> actual value.
>>
>> Here's the code I was using, I've tried with different variation but was
>> never able to get the value that was being added in the Trans-CFs.
>>
>> As a test, I was simply trying to get the value from the Trans-CFs and
>> right
>> it back in a Ticket CF.
>>
>> --------------
>> Custom Condition:
>> return 1;
>>
>> Custom action preparation code:
>> return 1;
>>
>> Custom action cleanup code:
>> my $ticket = $self->TicketObj;
>> my $cf_obj = RT::CustomField->new( $RT::SystemUser );
>>
>> my $cf_name = "ValueFrom_tr-cf";
>> my $trcf_name = "tr-cf";
>>
>> my $trcf_value = "1";
>>
>> #Read and store the value of the Transaction CF "tr-cf"
>>
>> $cf_obj->LoadByName(Name=>$trcf_name);
>> $trcf_value = $ticket->FirstCustomFieldValue($trcf_name);
>>
>> #Add the value to the Ticket CF
>> $cf_obj->LoadByName(Name=>$cf_name);
>> $ticket->AddCustomFieldValue(Field=>$cf_obj, Value=>$trcf_value,
>> RecordTransaction=>0);
>>
>> return 1;
>>
>> ---------------------------------------------------
>>
>> Any ideas on what could be going wrong?
>>
>> Thank you
>>
>>
>> Thomas Sibley wrote:
>>>
>>> On 06/04/2012 09:46 AM, TheHoboKing wrote:
>>>> After some research and trial and errors I finally realise extracting
>>>> values
>>>> from Transaction CFs is no longer possible.
>>>>
>>>> The feature has been removed since RT 3.6 and doesn't seem to have been
>>>> successfully implemented again. Mike seems to be the last reported
>>>> successful extraction of CFs and such. (If anyone has a patch or
>>>> successful
>>>> scrip/solution to extract values from Trans-CFs, please by all means
>>>> come
>>>> forward and tell me how wrong I am)
>>>
>>> You can absolutely read back out values from Transaction CFs.
>>> Unfortunately we can't guess what you're doing or why it's not working
>>> without seeing the code. I suspect in your attempts you didn't follow
>>> Mike's warning about needing to use the TransactionBatch stage for your
>>> scrips.
>>>
>>> Thomas
>>>
>>>
>> --
>> View this message in context:
>> http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33958371.html
>> Sent from the Request Tracker - User mailing list archive at Nabble.com.
>>
>
>
>
--
View this message in context: http://old.nabble.com/Append-Data-to-CustomFields-tp33920988p33970403.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.