[rt-users] Append Data to CustomFields

TheHoboKing demon_eyes_kyoms at hotmail.com
Mon Jun 4 09:46:12 EDT 2012


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 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.
>>> 
>> 
>> 
> 
-- 
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.




More information about the rt-users mailing list