Actionfield with IdeaScript

13 posts / 0 new
Last post
CB's picture
CB
Offline
Joined: 10/19/2012 - 04:54
Actionfield with IdeaScript

and again...

Actionfield is a really nice toy to play with...

here is a short example

Sub Run_Actionfield

      'declaration
      '-----------

Dim sTableActionfieldMaster As String
Dim sTableActionfieldDetail As String
Dim sJoinFieldMasterDetail As String

sTableActionfieldMaster = ""
sTableActionfieldDetail = ""
sJoinFieldMasterDetail = ""    
    
sTableActionfieldMaster = Dir(Client.Workingdirectory + "MasterTableName.IMD")
sTableActionfieldDetail = Dir(Client.Workingdirectory + "DetailTableName.IMD")    

'Be careful:
'The JoinKey must exists in both tables !!!!!!!!!!!!!!!
'---------------------------------------
sJoinFieldMasterDetail = "JoinKeyNumeric"


Set db = Client.OpenDatabase(sTableActionfieldMaster)
Set table = db.TableDef

'sometimes it is better to first get as StringField (otherwise idea raise an error)
'and than the JoinKey Field (most times numeric)
'---------------------------------------------
Set field = table.GetField("StringField")
Set field = table.GetField(sJoinFieldMasterDetail)

'here is the point where the magic starts...
'---------------------------------
field.SetActionFieldForExtraction sTableActionfieldDetail, sJoinFieldMasterDetail, "", "", "", "", "", "", ""
db.Close    
    
Set db = Nothing
Set task = Nothing
Set field = Nothing
sTableActionfieldMaster = ""
sTableActionfieldDetail = ""
sJoinFieldMasterDetail = ""


End Sub


that's it....

@brian:
would it be possible to deactivate the trim function when using plain text in your forum?

cheers,
chris

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

Wow Chris,

Where did you find the field.SetActionFieldForExtraction function?  I was doing a script and I wanted to do just this and IDEA said that it wasn't possible!!!  This is great.  I am really curious where you found this as it is not part of the information in the language browser.

Do you mind me putting it in the snippet section of the site with credit to you?

I am trying to figure out how to post code better.  Once I figure something out I will let you know.

CB's picture
CB
Offline
Joined: 10/19/2012 - 04:54

brian...
sorry for the late response, but i was very busy..

that is the reason why i have post it. you can not find anything about it, but it works if you know how... :-)
i have received this information from a source of caseware international.
unfortunately i have not found a way to create a actionfield that can start a macro.. :-(

sure, make a snippet.. i think this website should be exactly for something like this..

it is a nice function, isn't it? :-D

cheers,
chris

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

Hi Chris,

This is a great function.  I have created a snippet for it on the site plus I updated one of my scripts with it.  I am working on IDEA to get the insider information on all the IDEAScript functionalities.  I was suppose to meet with them for lunch this month but V9 is coming out in the next couple of weeks plus they are moving their office so they are supper busy.  I am away for several weeks next month for work so I will try to meet with them when I am back in November or December.  I really want to know everything that the language can do!!

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

I have added a function to remove an action field in the snippet area of the site.

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

Unfortunately it seems that IDEA has removed this functionality in V9.  I hope to convince them to put it back.

groldi's picture
groldi
Offline
Joined: 04/06/2014 - 04:21

Hi @ all,
we found a way to create actionfields to start a macro. If you remove or rename a database the macro will not work. To fix it we wrote this macro:
 
Const ISS_Path = "C:\IndExtrActionfield_extr.iss" 'here you have to write your own path
Const ActionFieldType_Extraction As Long = 1
Const ActionFieldType_Macro As Long = 2
Option Explicit
Sub FixIdeaScriptActionFields
Dim otable As Object
Dim tableDef As Object
 On Error GoTo Crash
Set otable=Client.CurrentDatabase
Set tableDef=otable.tableDef
 On Error GoTo Crash2
Dim tableField As Object
Dim dbName As String
Dim field1 As String
Dim field2 As String
Dim field2_a As String
Dim field2_b As String
Dim field3 As String
Dim field4 As String
Dim field5 As String
Dim i As Long
For i = 1 To tableDef.Count
Set tableField = tableDef.GetFieldAt(i)
If tableField.ActionFieldType = ActionFieldType_Macro Then
tableField.GetActionFieldForIDEAScript field1, _
AF_Extraction, field2,AF_IDEAScript,field3,AF_Extraction,field4,AF_Extraction,field5
 
field2_a= Left(field2,InStr(1,field2,"~")-1)
field2_b= Right(field2,Len(field2)-InStr(1,field2,"~")+1)
field2 = otable.name & field2_b
 
If Left(field5,5)="Dummy" And Left(field4,5)="Dummy" Then
tableField.SetActionFieldForIDEAScript ISS_Path, _
AF_Extraction, field2,AF_IDEAScript,field3,AF_Extraction,field4,AF_Extraction,field5
End If
If Left(field5,5)="Dummy" And Left(field4,5)<>"Dummy" Then
tableField.SetActionFieldForIDEAScript ISS_Path, _
AF_Extraction, field2,AF_IDEAScript,field3,AF_IDEAScript,field4,AF_Extraction,field5
End If
If Left(field5,5)<>"Dummy" And Left(field4,5)<>"Dummy" Then
tableField.SetActionFieldForIDEAScript ISS_Path, _
AF_Extraction, field2,AF_IDEAScript,field3,AF_IDEAScript,field4,AF_IDEAScript,field5
End If
End If
Next i
GoTo CleanUp
Crash:
 MsgBox "Please choose a database!", 0+16, "Warning:"
GoTo CleanUp
Crash2:
 MsgBox "ERROR!", 0+16, " Warning :"
CleanUp:
Set tableField = Nothing
Set tableDef = Nothing
 
Set otable = Nothing
End Sub
 
Have fun
 
Gerold from germany 

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

Hi Gerold, thanks for the script.  Which version of IDEA was this written for?

groldi's picture
groldi
Offline
Joined: 04/06/2014 - 04:21

Hi Brian,
 
this script is written for IDEA Version 8.0.5.243 (german).
I have to try it on Version 9.1.1 (our latest version in germany).
 
Gerold Mammen

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

Thanks for the information.  I know they removed the action field function from version 9 but I have never checked if the put it back for version 9.1.1 as I did complain to IDEA about that.  If it works in 9.1.1 please let me know and I appreciate you sharing the script.

groldi's picture
groldi
Offline
Joined: 04/06/2014 - 04:21

I work for the german tax administration and about 20.000 user in our company are working with idea 8. If actionfields are removed from Version 9 many of our macros cannot run. I will try and see... 
It's a bug...not a feature 

Pages