arrange columns with scripts

7 posts / 0 new
Last post
mobbie
Offline
Joined: 11/09/2015 - 05:06
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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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

mobbie
Offline
Joined: 11/09/2015 - 05:06

Thank you Brian

JHDCC
Offline
Joined: 02/15/2017 - 11:28

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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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
Offline
Joined: 02/15/2017 - 11:28

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"

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

Hi JHDCC,

Sorry I should have looked at that closer.  Glad you found the problem.

Brian