[rt-users] Append Data to CustomFields
Michael Coakley
mike.coakley at gmail.com
Wed May 30 17:44:12 EDT 2012
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 at 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 at 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.
>
More information about the rt-users
mailing list