Skip to main content

arrange columns with scripts

Dear All
Can anyone help me with how to arrange columns automatically? Now I just can arrange it from views and save as .VW2. I want it run automatically, please anyone can help me, thank you so much.

Brian Element Thu, 12/10/2015 - 07:32

Hi Mobbie,

There are no functions to just change the arrangement of the columns automatically.  There are a couple of ways to get around this, the first is if the script is performing any type of extraction or other function where you can list the columns in the order you wish by using the task.addFields function and listing the fields in order.

Also if you have created a view there is a script function that will allow you to open the view and use it on the file.  I think it is part of the client functions, sorry, I am on a computer that doesn't have IDEA so I can't look the function up right now.  If you can't find it let me know and I will look it up when I am using IDEA.

Brian

JHDCC Thu, 02/08/2018 - 10:31

Hi Brian
I'm trying to modify a known working ideascript macro so that the direct extraction re-orders the columns.
 
I've copied a simplified example below. In this example, the original database is ordered COL1, COL2, COL3, COL4 however, I want to the extract to be ordered COL4, COL1, COL2, COL3
 
Following your comments above, I've tried to use task.addFields, however, i get the following error
 
"Error on line 408 - Object does not support this property or method"
 
Line 408 is "task.addFields"COL4"" in the below example.
 
' Data: Direct Extraction
Function DirectExtraction1
Set db = Client.OpenDatabase("Extract.IMD")
Set task = db.Extraction
task.IncludeAllFields
dbName = "Extract Formatted.IMD"
task.addFields"COL4"
task.addFields"COL1"
task.addFields"COL2"
task.addFields"COL3"
task.AddExtraction dbName, "", ""
task.CreateVirtualDatabase = False
task.PerformTask 1, db.Count
Set task = Nothing
Set db = Nothing
Client.OpenDatabase (dbName)
End Function
 
I hope this is clear and my simplification hasn't complicated matters. I presume I've not added the task correctly? Could you please advise?
 
Thanks

Brian Element Thu, 02/08/2018 - 17:46

In reply to by JHDCC

Hi JHDCC,

The problem is most likely because you have the task.INcludeAllFields and the task.addFields, the two should not be together.  Try removing the task.IncludeAllFields and see if that fixes the problem.

Brian

JHDCC Fri, 02/09/2018 - 03:52

Thanks for the reply Brian
I removed "task.Include.All.Fields" and it still wouldn't work, but I managed to fix it by changing "task.AddFields" to "task.AddFieldToInc"