Views:

Applies To:

GroupID 8 and above – Synchronize

Business Requirement:

In GroupID, different kinds of files, such as CSV and .txt, are used to update attributes in Active Directory through a Synchronize job.

We have a requirement that when a CSV file is processed by a Synchronize job, it should be moved to the archive folder present on our server and renamed by appending the date-stamp to the file name. For example, if the file name is Excel123HR12, it should be moved to the archive folder with the name Excel123HR12-datemonthyear.

Is it possible with GroupID Synchronize?

Solution:

Yes, it is possible with a GroupID Synchronize job. Use the Global Script Editor feature for the Synchronize job to achieve it.

Steps:

  1. Launch GroupID Management Console.

  2. Click Synchronize > All Jobs and then click the required Synchronize job.

  3. On the Select Source page, make sure that relevant information is updated. In this example, we have taken a file, Excel123HR12.csv, from the root drive, C:\.

  4. On the Field Map(s) page, click Edit Global Script.

  5. The Global Script Editor is displayed.

  6. Locate the following lines of code:

    Sub DTM_Shutdown(ByVal dtmsource As Object, ByVal args As EventArgs) Handles DTM.Shutdown
            ' User-definable script goes here -----------------
            ' -------------------------------------------------
    End Sub
  7. Replace the above lines of code with the following by changing parameters as required. The parameters are:

    1. Dim SourcePath As String="C:\Excel123HR12.csv"
      In the code below, change the path of the file to the source file.
      In this example, it was placed in the root drive, i.e., C:\ and it was named as Excel123HR12.csv.

    2. Dim DestPath As String="C:\Archive\Excel123HR12.csv"
      In the code below, change the path of the file to the folder where you want to archive this CSV file.
      In this example, we transferred the file to the Archive folder in the C drive, C:\Archive\Excel123HR12.csv.
      Make sure that the Archive folder or any other folder you want to transfer the CSV file already exists.

    Sub DTM_Shutdown(ByVal dtmsource As Object, ByVal args As EventArgs) Handles DTM.Shutdown
            ' User-definable script goes here -----------------
            ' User-definable script goes here -----------------
        Dim SourcePath As String="C:\Excel123HR12.csv"
        Dim DestPath As String="C:\Archive\Excel123HR12.csv"
        Dim FileName As String="Excel123HR12"
        If System.IO.File.Exists(SourcePath) Then        
          File.Move(SourcePath,DestPath)
          Dim DT as Date=Date.Now
          Dim NewName As String = FileName & "-" & DT.Day & DT.Month & DT.Year & ".csv"
          'msgbox(NewName)
          My.Computer.FileSystem.RenameFile(DestPath, NewName)
            Else
          'msgbox("FileNotPresent")
            End if
            ' -------------------------------------------------
    End Sub
  8. After that, click Build > Compile Script.

  9. Close the Global Script Editor and save the changes by clicking Yes.

Note: After the job is run, the file will be sent to the Archive folder specified in the destination path. So, if you try to run the job again, it will not run as the file would not be available at the Source path. To rerun the job, provide the file back in the original path, or change the path in the Global Script Editor.
Comments (0)