cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Query Pending Workflow Details via entity TodoV2 API

rezadwi
Active Participant
0 Likes
670

Hi Everyone,

Hope everyone doing fine.

I got requirement from customer to query all pending workflows in SF with all changed data old value and new value, and expecting to do action approve and reject via custom application.

So what we currently do is, we use ToDo V2 entity to get pending workflows where categoryId= '14' and '17' as per reference here 

This is how it looks like via posman.

{
    "d": {
        "results": [
            {
                "__metadata": {
                    "uri": "https://api44preview.sapsf.com/odata/v2/WfRequest(918L)",
                    "type": "SFOData.WfRequest"
                },
                "wfRequestId": "918",
                "lastModifiedDateTime": "/Date(1731983617000+0000)/",
                "lastModifiedBy": "61111467",
                "module": "HRIS",
                "reminderSentDate": null,
                "totalSteps": 9,
                "createdDateTime": "/Date(1731983617000+0000)/",
                "createdOn": "/Date(1731983617000)/",
                "url": null,
                "lastModifiedOn": "/Date(1731983617000)/",
                "parentWfRequestId": null,
                "createdBy": "61111467",
                "currentStepNum": 1,
                "status": "PENDING",
                "wfRequestUINav": {
                    "__deferred": {
                        "uri": "https://api44preview.sapsf.com/odata/v2/WfRequest(918L)/wfRequestUINav"
                    }
                },
                "parentWfRequestNav": {
                    "__deferred": {
                        "uri": "https://api44preview.sapsf.com/odata/v2/WfRequest(918L)/parentWfRequestNav"
                    }
                },
                "workflowAllowedActionListNav": {
                    "__deferred": {
                        "uri": "https://api44preview.sapsf.com/odata/v2/WfRequest(918L)/workflowAllowedActionListNav"
                    }
                },
                "empWfRequestNav": {
                    "__deferred": {
                        "uri": "https://api44preview.sapsf.com/odata/v2/WfRequest(918L)/empWfRequestNav"
                    }
                },
                "wfRequestParticipatorNav": {
                    "__deferred": {
                        "uri": "https://api44preview.sapsf.com/odata/v2/WfRequest(918L)/wfRequestParticipatorNav"
                    }
                },
                "wfRequestCommentsNav": {
                    "__deferred": {
                        "uri": "https://api44preview.sapsf.com/odata/v2/WfRequest(918L)/wfRequestCommentsNav"
                    }
                },
                "wfRequestStepNav": {
                    "__deferred": {
                        "uri": "https://api44preview.sapsf.com/odata/v2/WfRequest(918L)/wfRequestStepNav"
                    }
                }
            }
        ]
    }
}

 then, we navigate to wfrequestUINav, and it will be look like this.

{
    "d": {
        "__metadata": {
            "uri": "https://api44preview.sapsf.com/odata/v2/WfRequestUIData(918L)",
            "type": "SFOData.WfRequestUIData"
        },
        "wfRequestId": "918",
        "businessUnit": null,
        "isEffectiveDateType": true,
        "isObjectBase": false,
        "assigneeUserId": null,
        "operateUserName": "MUHAMAD IRFAN TAUFIQ",
        "assigneeUserName": null,
        "jobTitle": "OPERATOR TP(17100182)",
        "legalEntity": null,
        "objectType": null,
        "division": null,
        "receivedOn": null,
        "department": null,
        "costCenter": null,
        "deeplink": "https://hcm-ap20-preview.hr.cloud.sap/sf/hrisworkflowapprovelink?workflowRequestId=V4-0-a1-jeRuUg-UbT1cXjxSysAAPkZFfnfud_mgVo-nr1T1eQ&prevPage=HOME&company=ptpamapersT1&username=SFAPI",
        "todoSubjectLine": "MUTASI for ANTONIUS AGUNG TEGUH SURYADI",
        "operateType": "Initiated",
        "subjectUserId": "61102176",
        "changedData": null,
        "eventReason": "MUTASI",
        "actionType": null,
        "isAssigned": false,
        "operateUserId": "61111467",
        "objectName": null,
        "location": "BTSJ",
        "actions": "[{\"action\":\"approve\"}]",
        "operateDate": "November 19, 2024",
        "effectiveDate": "October 1, 2024",
        "subjectUserName": "ANTONIUS AGUNG TEGUH SURYADI"
    }
}

 and the client expectation is to get similar changed data old value and new value as picture below which is not populated in wfrequestUIData

rezasaputro_0-1736237253778.png

So my question is, is this expected behavior? we cannot fetched data via API as picture above? only use deeplink?

 

Thank you!
Reza Dwi

Accepted Solutions (0)

Answers (1)

Answers (1)

jenny_geipel
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi,

from API perspective "getWorkflowPendingData" could help.

This shows more or less the things you can see on the UI.

Depending on your use case you can also think about to use iframes to show the workflow request/details in a iframe.