So currently I’ve been on this workday implementation team for a few months now. Because of the environment I am in we are currently a Powershell shop.
The task I am assigned with is basically conversion of the workday feed to integrate with our current Provisioning / PIM system along with uploading the generated data back into the workday system itself. One of the fields that need to be updated within workday is letting workday know what email was assigned in ActiveDirectory.
I basically landed on this… https://bitbucket.org/treestryder/powershell_module_workdayapi
It worked Amazing, However, the API it uses to upload an email to workday is via the “Maintain_Contact_Information_for_Person_Event_Request” API call. This will lock the Employee’s record to some degree so Workday has asked that I use “Change_Work_Contact_Information_Request” instead to update the User’s email information. I generated the following script below to handle the new API call from the workday library. Don’t forget you also need to add the “Set-WorkDayWorkerEmailEx” library in the PSM1 file like below to chain the new functionality from the library.

function WriteXmlToScreenHere ([xml]$xml)
{
    $StringWriter = New-Object System.IO.StringWriter;
    $XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter;
    $XmlWriter.Formatting = "indented";
    $xml.WriteTo($XmlWriter);
    $XmlWriter.Flush();
    $StringWriter.Flush();
    Write-Output $StringWriter.ToString();
}

function Set-WorkdayWorkerEmailEx {
<#
.SYNOPSIS
    Sets a Worker's email in Workday.

.DESCRIPTION
    Sets a Worker's email in Workday.

.PARAMETER WorkerId
    The Worker's Id at Workday.

.PARAMETER WorkerType
    The type of ID that the WorkerId represents. Valid values
    are 'WID', 'Contingent_Worker_ID' and 'Employee_ID'.

.PARAMETER WorkEmail
    Sets the Workday primary Work email for a Worker. This cmdlet does not
    currently support other email types.

.PARAMETER Human_ResourcesUri
    Human_Resources Endpoint Uri for the request. If not provided, the value
    stored with Set-WorkdayEndpoint -Endpoint Human_Resources is used.

.PARAMETER Username
    Username used to authenticate with Workday. If empty, the value stored
    using Set-WorkdayCredential will be used.

.PARAMETER Password
    Password used to authenticate with Workday. If empty, the value stored
    using Set-WorkdayCredential will be used.

.EXAMPLE

Set-WorkdayWorkerEmailEx -WorkerId 123 -WorkEmail worker@example.com

#>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true,
            Position=0)]
        #[ValidatePattern ('^[a-fA-F0-9\-]{1,32}$')]
        [string]$WorkerId,
        [ValidateSet('WID', 'Contingent_Worker_ID', 'Employee_ID')]
        [string]$WorkerType = 'Employee_ID',
        [Parameter(Mandatory = $true)]
        [ValidatePattern('^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$')]
        [Alias('EmailAddress')]
        [string]$Email,
        [ValidateSet('HOME','WORK')]
        [string]$UsageType = 'WORK',
        [switch]$Private,
        [switch]$Secondary,
        [string]$Human_ResourcesUri,
        [string]$Username,
        [string]$Password
    )

    if ([string]::IsNullOrWhiteSpace($Human_ResourcesUri)) { $Human_ResourcesUri = $WorkdayConfiguration.Endpoints['Human_Resources'] }

$request = [xml]@'
<bsvc:Maintain_Contact_Information_for_Person_Event_Request bsvc:Add_Only="false" xmlns:bsvc="urn:com.workday/bsvc">
    <bsvc:Business_Process_Parameters>
        <bsvc:Auto_Complete>true</bsvc:Auto_Complete>
        <bsvc:Run_Now>true</bsvc:Run_Now>
        <bsvc:Comment_Data>
            <bsvc:Comment>Email set by Set-WorkdayWorkerEmail</bsvc:Comment>
        </bsvc:Comment_Data>
    </bsvc:Business_Process_Parameters>
    <bsvc:Maintain_Contact_Information_Data>
        <bsvc:Worker_Reference>
            <bsvc:ID bsvc:type="Employee_ID">Employee_ID</bsvc:ID>
        </bsvc:Worker_Reference>
        <bsvc:Effective_Date>Effective_Date</bsvc:Effective_Date>
        <bsvc:Worker_Contact_Information_Data>
            <bsvc:Email_Address_Data>
                <bsvc:Email_Address>Email_Address</bsvc:Email_Address>
                <bsvc:Usage_Data bsvc:Public="true">
                    <bsvc:Type_Data bsvc:Primary="true">
                    <bsvc:Type_Reference>
                        <bsvc:ID bsvc:type="Communication_Usage_Type_ID">WORK</bsvc:ID>
                    </bsvc:Type_Reference>
                    </bsvc:Type_Data>
                </bsvc:Usage_Data>
            </bsvc:Email_Address_Data>
        </bsvc:Worker_Contact_Information_Data>
    </bsvc:Maintain_Contact_Information_Data>
</bsvc:Maintain_Contact_Information_for_Person_Event_Request>
'@

$request = [xml]@'
<bsvc:Change_Work_Contact_Information_Request xmlns:bsvc="urn:com.workday/bsvc" bsvc:version="v30.0">
    <bsvc:Business_Process_Parameters>
        <bsvc:Auto_Complete>true</bsvc:Auto_Complete>
        <bsvc:Run_Now>true</bsvc:Run_Now>
    </bsvc:Business_Process_Parameters>

    <bsvc:Change_Work_Contact_Information_Data>
        <bsvc:Person_Reference>
            <bsvc:ID bsvc:type="Employee_ID">Employee_ID</bsvc:ID>
        </bsvc:Person_Reference>
        <bsvc:Event_Effective_Date>Event_Effective_Date</bsvc:Event_Effective_Date>
        <bsvc:Person_Contact_Information_Data>
            <bsvc:Person_Email_Information_Data bsvc:Replace_All="true">
                <bsvc:Email_Information_Data >
                    <bsvc:Email_Data>
                        <bsvc:Email_Address>Email_Address</bsvc:Email_Address>
                    </bsvc:Email_Data>
                    <bsvc:Usage_Data bsvc:Public="true">
                        <bsvc:Type_Data bsvc:Primary="true">
                            <bsvc:Type_Reference>
                                <bsvc:ID bsvc:type="Communication_Usage_Type_ID">WORK</bsvc:ID>
                            </bsvc:Type_Reference>
                        </bsvc:Type_Data>
                    </bsvc:Usage_Data>
                </bsvc:Email_Information_Data>
            </bsvc:Person_Email_Information_Data>
        </bsvc:Person_Contact_Information_Data>
    </bsvc:Change_Work_Contact_Information_Data>
</bsvc:Change_Work_Contact_Information_Request>
'@

    $request.Change_Work_Contact_Information_Request.Change_Work_Contact_Information_Data.Person_Reference.ID.InnerText = $WorkerId
    if ($WorkerType -eq 'Contingent_Worker_ID') {
        $request.Change_Work_Contact_Information_Request.Change_Work_Contact_Information_Data.Person_Reference.ID.type = 'Contingent_Worker_ID'
    } elseif ($WorkerType -eq 'WID') {
        $request.Change_Work_Contact_Information_Request.Change_Work_Contact_Information_Data.Person_Reference.ID.type = 'WID'
    }

    $request.Change_Work_Contact_Information_Request.Change_Work_Contact_Information_Data.Person_Contact_Information_Data.Person_Email_Information_Data.Email_Information_Data.Email_Data.Email_Address = $Email
    $request.Change_Work_Contact_Information_Request.Change_Work_Contact_Information_Data.Event_Effective_Date = (Get-Date).ToString( 'yyyy-MM-dd' )
    $request.Change_Work_Contact_Information_Request.Change_Work_Contact_Information_Data.Person_Contact_Information_Data.Person_Email_Information_Data.Email_Information_Data.Usage_Data.Type_Data.Type_Reference.ID.'#text' = $UsageType

    $request.Change_Work_Contact_Information_Request.Change_Work_Contact_Information_Data.Person_Contact_Information_Data.Person_Email_Information_Data.Email_Information_Data.Usage_Data.Type_Data.Primary =
        if ($Secondary) {'0'} else {'1'}
    $request.Change_Work_Contact_Information_Request.Change_Work_Contact_Information_Data.Person_Contact_Information_Data.Person_Email_Information_Data.Email_Information_Data.Usage_Data.Public =
        if ($Private) {'0'} else {'1'}

    #Write-Output "Sending: " $request
    WriteXmlToScreenHere($request)
    #Write-Host "Sending: " 
    Invoke-WorkdayRequest -Request $request -Uri $Human_ResourcesUri -Username:$Username -Password:$Password | Write-Output
}

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax