如何通过WQL或SOAP请求获取Workday外部学习用户账户
一、使用WQL筛选
复制「All Workday Accounts」报表后,可通过修改WQL查询,只返回关联External Learning User的账户,有两种常用写法:
写法1:通过账户ID类型筛选
筛选包含External_Learning_User_ID类型ID的Workday账户:
SELECT Workday_Account.ID, Workday_Account.User_Name, Workday_Account.Email_Address, Workday_Account.ID[type='External_Learning_User_ID'] AS External_Learning_User_ID FROM Workday_Account WHERE EXISTS (Workday_Account.ID[type='External_Learning_User_ID'])
写法2:关联External_Learning_User对象查询
直接关联外部学习用户对象,获取绑定的Workday账户:
SELECT wa.ID AS Workday_Account_ID, wa.User_Name, elu.External_Learning_User_ID, elu.External_Learning_User_Name FROM Workday_Account wa JOIN External_Learning_User elu ON wa.Workday_Account_ID = elu.Workday_Account_ID
将上述WQL替换原报表的查询语句,即可得到仅包含External Learning User Account的结果。
二、修复SOAP请求错误并获取账户
你之前的Get_Workday_Account_Request报错,原因是**Workday_Account_Reference不支持External_Learning_User_ID作为ID类型**——该ID类型属于External_Learning_User对象,而非Workday_Account。以下是两种正确的解决方案:
方案1:用Request_Criteria替代Request_References
通过Request_Criteria中的ID_Match_Criteria指定External_Learning_User_ID来筛选账户,示例请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bsvc="urn:com.workday/bsvc"> <soapenv:Body> <bsvc:Get_Workday_Account_Request> <bsvc:Request_Criteria> <bsvc:ID_Match_Criteria> <bsvc:ID bsvc:type="External_Learning_User_ID">EXTERNAL_LEARNING_USER-6-5</bsvc:ID> </bsvc:ID_Match_Criteria> </bsvc:Request_Criteria> <bsvc:Response_Filter> <bsvc:As_Of_Effective_Date>2024-05-20</bsvc:As_Of_Effective_Date> <bsvc:As_Of_Entry_DateTime>2024-05-20T12:00:00</bsvc:As_Of_Entry_DateTime> </bsvc:Response_Filter> <bsvc:Response_Group> <bsvc:Include_Reference/> <bsvc:Include_Account_Details/> </bsvc:Response_Group> </bsvc:Get_Workday_Account_Request> </soapenv:Body> </soapenv:Envelope>
方案2:先获取External Learning User再关联账户
先调用Get_External_Learning_Users_Request获取用户信息及绑定的Workday账户引用,再用该引用查询账户详情:
第一步:获取External Learning User信息
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bsvc="urn:com.workday/bsvc"> <soapenv:Body> <bsvc:Get_External_Learning_Users_Request> <bsvc:Request_References> <bsvc:External_Learning_User_Reference> <bsvc:ID bsvc:type="External_Learning_User_ID">EXTERNAL_LEARNING_USER-6-5</bsvc:ID> </bsvc:External_Learning_User_Reference> </bsvc:Request_References> <bsvc:Response_Group> <bsvc:Include_Workday_Account/> </bsvc:Response_Group> </bsvc:Get_External_Learning_Users_Request> </soapenv:Body> </soapenv:Envelope>
第二步:用返回的Workday_Account_Reference查询账户
从上述响应中提取Workday_Account_Reference,替换到Get_Workday_Account_Request中:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bsvc="urn:com.workday/bsvc"> <soapenv:Body> <bsvc:Get_Workday_Account_Request> <bsvc:Request_References> <bsvc:Workday_Account_Reference bsvc:Descriptor="外部学习用户账户描述"> <bsvc:ID bsvc:type="Workday_Account_ID">WORKDAY_ACCOUNT-XXX-XXX</bsvc:ID> </bsvc:Workday_Account_Reference> </bsvc:Request_References> <bsvc:Response_Group> <bsvc:Include_Account_Details/> </bsvc:Response_Group> </bsvc:Get_Workday_Account_Request> </soapenv:Body> </soapenv:Envelope>
获取所有External Learning User Accounts
如果要批量获取所有这类账户,可省略Request_References,直接调用Get_External_Learning_Users_Request并开启Include_Workday_Account,即可一次性获取所有外部学习用户及其绑定的Workday账户信息。
内容的提问来源于stack exchange,提问作者Anand Dhage

