Select mulptiple fields for operations

8 posts / 0 new
Last post
Norbert_L's picture
Norbert_L
Offline
Joined: 09/03/2014 - 10:37
Select mulptiple fields for operations

Hi all,
I want to create a script where users can select multiple fields and for example delete them.
I found the right snippet (Using listboxs to select files/fields) but don't know how to change the script to read the fields instead of the files and perform a task on the selected fields.
thx :)

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Norbert,

I will put something together for you as a demo.  With the fields you end up have two dialogs, one to select the file you want to work on and the other to select the fields.  The fields would be stored in an array that would be returned when you exit the dialog, you would then use the names in this array to do whatever you want with the fields.

There is one problem with deleting fields, in V8 of IDEA, you could delete fields with no problem in IDEAScript, this was changed in V9 so that in order for the fields to be deleted you have to make sure that the option to "do not allow the deletion of non-virtual fields" has been turned off, as far as I know you can't turn it off from the script so if you are in V9 you will have to make sure the user has unclicked this option or else they will receive an error when trying to delete a non-vitural field.

Norbert_L's picture
Norbert_L
Offline
Joined: 09/03/2014 - 10:37

Hi Brian,
thanks again for your support!
I did not know that you could disable that via script, but I know that you can disable that option in the settings :)
Edit: It took a little till i get what you wrote :D
I'm using V8 at least till next summer. But thats not a big deal if a user had to turn on or off something in the settings

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Norbert,

Here is a script that I modified that will allow you to delete multiple fields within a database.  As you can see from the script, deleting the files only takes a few lines of code everything else is to generate the dialog.

Let me know if it is what you are looking for.

Brian

Norbert_L's picture
Norbert_L
Offline
Joined: 09/03/2014 - 10:37

Hi Brian, 
this looks very good :D thank you very much.
I'm going to try it tomorrow and let you know if it works like i wish to.
 
The basic idea is because colleagues asked me to help them to prepare imported excel files from SAP. 
They cant manipulate the files within excel because the files are too big. 
My first thought was to create a dialog with dropdowns where they can choose which field to delete, but then the number of fields is not dynamic. If I create 5 Dropdowns and they want to delete 6 fields I have to recreate the dialog. Due to the sreen resolution of our laptops I also have a little space problem...
To get the excel file into a usable form I need to delete fields and change some of them from character to numeric fields. So we could use the other scripts that do the extractions and other tasks.
With your code it should be easy that I add a second field select dialog to perform the step of changing other selected fields from character to numeric.
 
Norbert

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Another option, when selecting which fields to change to character fields you only show the character fields so the user doesn't have to remember which is which.  This can be done by adding a filter when deciding which fields to show in the dialog.

Good luck with your project.

Brian

Norbert_L's picture
Norbert_L
Offline
Joined: 09/03/2014 - 10:37

Hi Brian,
thx thats it :)
I'm going to try myself to create a second array with a dialog for another task. It is learning by doing for me ;)
 
Norbert

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

If you need any help let me know.

Brian