RT-Extension-ImportCustomFieldValues Compatiblity

Hello,
Does anyone know if RT-Extension-ImportCustomFieldValues is compatible with RT5? Metacpan states 4.2 and 4.4, but in another section also says greater.

I need to create custom fields with select lists that are extensive and would like a way to create them quickly vs manually.

Thanks in Advance,
Julie

@MT_CW

There is a good chance that’ll work. I reckon give it a shot on a test instance.

Was interested in this extension as it would be useful.

I changed the Makefile.PL and META.yml to:

x_rt_too_new: 6.0.0

It installed on RT 5.0.8

It installs. The new menu option “Import from CSV” appears. I can upload a file, but it seems to get no further than the “Importing [file]…” stage.

So I can confirm it doesn’t work on RT 5.x.

Should be possible to do something with the REST2 API though.

Okay,

So using the code in the ImportCustomFieldValues extension as a bit of inspiration, I wrote a little script to import from CSV to CustomFields:

$ ./rt_customfield.pl --file=/home/robl/custom_fields.csv --replace
>> Old value 286 deleted
>> Old value 287 deleted
>> Field: TestImport, Value: Option 1 successfully imported
>> Line 2: missing field: Description
>> Old value 288 deleted
>> Field: TestImport, Value: Option 1 successfully imported
>> Field: TestImport, Value: Option 2 successfully imported

I had to add an extra column to the CSV to tell it which CF to import the values to. CF names are not unique system-wide though, so it may need some further improvement to tell it where you want to import the CF to (i.e. ticket queue CF, global CF, user, group etc.)

The CSV looks like:-

CustomField;SortOrder;Name;Description;Category
TestImport;0;Option 1;Some Desc;CAT 1
TestImport;10;Option 2;;Some other thing;CAT 2

I like to add a header row, because then the exact order of the fields doesn’t matter. It also doesn’t matter if the CSV contains other columns not used by the script. But it’s a simple change to the script if the CSV has no headers. The delimiter etc. can also be changed.

Importantly I want to make this script export an existing CF to a CSV. This allows taking a backup in case you need to undo it, and also I want to be able to set up the CFs etc and get it all correct on my test RT server, before exporting it and importing it on the live box.

If I clean this script up a bit, would you be interested in it?

R.

Hi, I’m the author of this extension, I will make it compatible to RT 5 and 6 if possible, as soon as possible !

2 Likes

Just tried on RT 6 alpha and it works (after changing the x_rt_too_new. Do you have any error in the logs, in the UI? Can you give me your CSV sample?

For the header row, I can support it, but it should be backward compatible. Maybe I can add a checkbox option?

I may also add an export button, that would be a nice feature (like exporting current values, editing them and importing them back).

1 Like

Emmanuel & Rob,
Thank you for working together to update this extension. My team hasn’t tried to install it yet, so i’ll ask them to hold until it’s RT5 compatible. Please keep me posted.

I couldn’t see anything interesting in the logs. Restarted and cleared the mason cache a few times. Reinstalled it a couple of times.

But on my test 5.0.8 at least, I couldn’t get it to move past the “Importing…” step. I thought it may be a permissions thing, but I tried it as root user also.

CSV file I tried looked like:

0;Option 1;Some Desc;;
10;Option 2;;Some other thing;;

I tried various things, including invalid values to try and make it throw an error somewhere, but nothing changed.

Your CSV works here, but the second line is wrong (two “;” between name and description)…

You should be able to try it here: https://demo.request-tracker.fr/Admin/CustomFields/Modify.html?id=7''

Works there. Same file shows up the errors I made in the file, and imports the valid values.

But on mine it doesn’t get that far. Just:

Importing test_cf.csv

Is there a way to increase the debugging?

R.

I tested on 5.0.7 with sucess too.

So I go on a CF, I click on Import from CSV, I choose a file to import and click on “Import”, then I get a screen with “Importing test.csv” and a table with the list of values to be imported. Then I click on “Confirm” and I’m back at the initial import screen with a yellow backgrounded text listing the actions done.

At which step are you stuck? On which OS/version?

Here’s what it looks like on my test 5.0.8. (With horrible colours set so I don’t confuse with live!)

Comparing your screenshot, it looks like I’m not getting to the next step, but returns to the first step after the file is uploaded.

OS: Debian 11.11, (bullseye) perl v5.32.1

:rofl:

Still very strange, maybe you have something in your browser console (F12) ? Which browser?

Edge - but same happens in Chrome.

Nothing much shows in the console - a few minor layout/header issues.

I tried disabling a few other extensions to see if that was an issue, but so far no change. Hmmm.

In the mean time, I uploaded a 0.04 which for me works with RT 5 and 6, with export feature added: RT-Extension-ImportCustomFieldValues-0.04 - Allow to import customfield values from CSV file - metacpan.org

@Rob_Lister : hard to help you without much informations, please tell me if you find something!

1 Like