Berg Hansen (deprecated)
PortalLdapToBergHansenCSV
Description
This script generates a CSV file containing employee data formatted for Berg-Hansen. It retrieves data from a Portal LDAP, processes it, and optionally uploads the file to a remote SFTP server.
Input Parameters
log_only: Boolean indicating whether to only log the output without uploading it to the remote server.
Local Variables
genderTitleMap: A mapping of gender codes to titles (Mr/Ms).gender: A variable to store the gender of the employee.date: The current date formatted asyyyyMMdd.hours: The current time formatted asHHmmss.outputFileName: The name of the output CSV file.localFilePath: The local directory path where the output file will be saved.sessionPortalLDAP: Connection object for Portal LDAP.fileOut: The file output object for writing the CSV file.remoteFileSys: The remote filesystem object for SFTP connection.ldapRecords: The set of records fetched from Portal LDAP.outputData: An array to store the formatted output data.recordBergHansen: A record object to store the formatted data for each employee.formattedBirthdate: The formatted birthdate of the employee.selectedUsername: The selected username for the employee.selectedEmail: The selected email address for the employee.splitDeptCode: An array containing the split department code.numRecords: The number of records in the output data array.formattedTime: The current date and time formatted asyyyy-MM-dd HH:mm:ss:ms.outputStr: The final output string to be written to the CSV file.result: The result of the file save operation.
Workflow
- Initialize Variables
- Set initial values for variables and format the current date and time.
- Create Connections
- Establish a connection to Portal LDAP.
- Handle connection errors by logging and returning.
- Open Output File
- Open the local output file for writing in ISO-8859-1 character set.
- If
log_onlyis false, establish a remote SFTP connection.
- Query Records
- Fetch employee records from Portal LDAP based on specific filters and attributes.
- Process Records
- Iterate over each LDAP record and format the data for Berg-Hansen.
- Populate the
recordBergHansenobject with formatted values. - Append the formatted record to the
outputDataarray.
- Write Data
- Insert the header row into the
outputDataarray. - Join the array into a single string and write it to the local output file.
- If
log_onlyis false, upload the file to the remote SFTP server.
- Close Connections
- Close the local output file and the Portal LDAP connection.
- If a remote SFTP connection was established, close it as well.
External Systems and Communications
- Portal LDAP: Used to fetch employee records and attributes.
- Remote SFTP Server: Optionally used to upload the generated CSV file.
Response Codes/Outputs
- The script logs the output data and the result of the file save operation.
- If
log_onlyis false, the script uploads the file to the remote SFTP server and logs the result.
Summary
This script generates a CSV file containing employee data formatted for Berg-Hansen. It retrieves data from Portal LDAP, processes it, and optionally uploads the file to a remote SFTP server. The script handles various data formatting requirements and ensures that the output is correctly structured for Berg-Hansen's needs.
This text was generated by AI.