soapworkday-api

Workday API to Delete Contact Information


I am using Workday's API to delete an employees' work email address. The problem is that in order to delete I need the unique reference ID for the field. The docs have the service Get_Change_Work_Contact_Information_Request that they say is formatted to be used as input for the Change_Work_Contact_Information_Request service, but I am having trouble using it in my request.

This is what I have right now, I build the Get_Change_Work_Contact_Information_Request as $idrequest and pass it into the 'ID' within Change_Work_Contact_Information_Request. The error I get is "Validation error occurred. Invalid ID value. 'Array' is not a valid ID value for type = 'Email_ID'"

        $idrequest = [
            'Get_Change_Work_Contact_Information_Request' => [
                'Request_References' => [ 
                    'Person_Reference' => [
                        'ID' => ['_' => "{$empid}",
                                'type' => 'Employee_ID'
                        ]
                    ]
                ]
            ]
        ];

        $params = [
            'Change_Work_Contact_Information_Request' => [
                'Business_Process_Parameters' => [
                    'Auto_Complete' => '1',
                    'Run_Now' => '1'
                ],

                'Change_Work_Contact_Information_Data' => [
                    'Person_Reference' => [
                        'ID' => ['_' => "{$empid}",
                                'type' => 'Employee_ID'
                        ]
                    ],

                    'Event_Effective_Date' => "{$date}",

                    'Person_Contact_Information_Data' => [
                        'Person_Email_Information_Data' => [
                            'Email_Information_Data' => [
                                'Delete' => 'True',
                                'Email_Reference' => [
                                    'ID' => ['_' => "{$idrequest}",
                                            'type' => 'Email_ID'
                                    ]
                                ],
                            ]
                        ]
                    ]
                ]
            ]
        ];

Solution

  • Managed to figure out a solution and also fix an error I was getting. Ultimately, I could not nest the SOAP request within the same function. I ended up calling 'Get_Change_Work_Contact_Information', parsing the Array you get back for the Reference ID, and then calling 'Change_Work_Contact_Information' to get the deletion done.