Monthly Archives: October 2019

TCC

TCC – Referencing a User-defined Field Explicitly in an Import File

I ran across this and thought that it was odd. On a candidate import, instead of using the standard field Prefix, we were needing to target a user defined selection elements named Prefix. The error being returned was the following:

Error Detail:
Code: internal
Description: A general internal error occurred.
Reason: Relation “Prefix” not found for the entity “Candidate” in the product pack
The error occurred in the following step: Prepare Import
The corresponding code for this error in version 1.0 would have been: -1

It was odd because one is a field and the other a selection. The fix can be found in Doc ID 1047706.1 on the MOS.
Basically to explicitly declare a user defined field/selection, you need to prefix CustomField: to the field name in order to specify you’re speaking of a custom field. So Prefix,Description becomes CustomField:Prefix,Description and the error is solved.

Update:
This post isn’t as clear as it should be so here’s a better example. Let’s say you have a custom field in experience that’s called ReasonForLeaving. This is a custom field that is the same as the standard field called ReasonForLeaving. The reasons why it’s named the same are not important what is, is calling the right field:
Standard field would be:
TalentUser,Profile,Experiences,ReasonForLeaving
Custom field would be:
TalentUser,Profile,Experiences,CustomField:ReasonForLeaving

So make sure the ‘CustomField:’ declaration is for the field and not the reference location.


PowerShell

Powershell – Archive Log Files by Day

Log files, you have to love them because they allow you to figure out what’s going on but what do you do with them, by default they just keep writing and writing and at some point you need to do something with them.
I found this powershell script that can do exactly that and put it here for safe keeping

##############
# This script requires WMF version >= 5.0 -  Download WMF 5.1 from https://www.microsoft.com/en-us/download/details.aspx?id=54616
# The directory that has the files desired to be imported MUST HAVE TRAILING "\"
$path = "C:\onedrive_tt\Client\AbbVie\TCC_Touchpoints\doc\20190910-ResponseFiles\results\"
# Optional filter to only touch files with specified extension 
$mask = "*.csv" 
$ZipFileName= "CompressedBackup.zip"
#Filter to only touch files older than specified hours
$hours = 24
# Begin SMTP Server information 
# $SMTPPassword = "PlainText SMTP Password"
# $SMTPUser = "SMTP Authentication user, will also be SMTP From: address"
# $SMTPServer = "my.smtpserver.com"
# $SMTPTo = 'receive@myemail.com'
# $SMTPSubjectFail = "ZIP Folder script failed to run"
# $secpasswd = ConvertTo-SecureString $SMTPPassword -AsPlainText -Force
# $mycreds = New-Object System.Management.Automation.PSCredential($SMTPUser, $secpasswd)
# End SMTP Configuration
$problem = $false
$date = (Get-Date).tostring("yyyyMMdd")
#Pre setting error message to no issue, will change later in the script
$errorMessage="no issue"


#############


try {
    # Get all items from specified path, recursing into directories but not returning directories themselves. Excluding files with modificiation dates less than $hours
    $files = Get-ChildItem $path -Recurse -Include $mask | where {($_.LastWriteTime -lt (Get-Date).AddHours(-$hours)) -and ($_.psIsContainer -eq $false)} 
    foreach ($file in $files) {
        $Directory = $path + $file.LastWriteTime.Date.ToString('yyyyMMdd')
        if (!(Test-Path $Directory)) {
	        New-Item $directory -type directory
	    }
	    Move-Item $file.fullname $Directory
    }
    $folders = Get-ChildItem $path -Directory  | % { $_.FullName }
    foreach ($folder in $folders) {
        $zipname = $folder + $ZipFileName
        if (!(test-path $zipname)){
        compress-archive -LiteralPath $folder -DestinationPath $zipname
        }
        if (test-path $zipname){
        remove-item -Recurse $folder 
        }
        else {
        Write-host $zipname + "Did not create, so I'm not deleting" + $folder
        }
    }
}
catch {
    $problem = $true
    $errormessage = $_.Exception.Message
}
finally {
    if ($problem){
        Write-Host $errorMessage
        # Send-MailMessage  -SmtpServer  $SMTPServer -UseSsl -From $SMTPUser -To $SMTPTo -Subject $SMTPSubjectFail  -Body $ErrorMessage -Credential $mycreds  
    }
    else {
        Write-Host "Script ran sucessfully"
    }
}