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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
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 } |