Action Field

This snippet was created by CB and it allows us to use IDEAScript to create an action field.  The function takes three parameters:
The master file, this is the file in which the field will hold the action (i.e. this field will become a link and when click on will extract all the records from the secondary file)

  1. The detail file, this is the file that contains the transactions that will be extracted.
  2. This is the common field between the two (must be the same name) that the action will be linked by.

Thanks CB for posting this to the forum, I didn't know that you could do this!!!

Added a routine to remove an action field.

It seems that this function has been removed from IDEA 9, hopefully they will put it back in future versions.

Snippet: 
'********************************************************************************************
' function: runActionfield
' Paramaters: Master database
'                    Detail database
'                    Common field
' Purpose: Creates an action field between the two databases using the common field
' Returns: Nothing - adds action field to Master database file
'********************************************************************************************

Function runActionfield(sTableActionfieldMaster As String, sTableActionfieldDetail As String, sJoinFieldMasterDetail As String)

     Dim db As database
     Dim table As table
     Dim field As field
     Dim task As task
     
     'Be careful:
     'The JoinKey must exists in both tables !!!!!!!!!!!!!!!
     '---------------------------------------
     
     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("VENDOR_NUMBER")
     Set field = table.GetField(sJoinFieldMasterDetail)
     
     'here is the point where the magic starts...
     '---------------------------------
     field.SetActionFieldForExtraction sTableActionfieldDetail, sJoinFieldMasterDetail, "", "", "", "", "", "", ""
     db.Close   
         
     Set db = Nothing
     Set table = Nothing
     Set task = Nothing
     Set field = Nothing

End Function

Sub Main
Call removeActionField("FileName.IMD", "FIELD NAME")
End Sub

'*******************************************************
'* Removes an action field
'* Parameters: Filename of file that contains field
'* Field Name that has the action field
'* Removes an action field that has been previously created.
'****************************************************************

Function removeActionField(sFile As String, sField As String)
Set db = Client.OpenDatabase(sFile)

' Get the table definition.

Set table = db.TableDef

' Get a field from the table.

Set field = table.GetField(sField)

field.RemoveActionField
End Function