This article covers pre-requisite of using Odata v2 API to retrieve rating from performance forms and provides example how-to and uri for certain scenarios.
RBP permission for API query as an admin user
Make sure the admin user has the permission: Manage Documents > Admin Access to Forms OData API permission.
Note
1. If you have the form OData admin permissions, you will be allowed to query the form data, but you will not be able to edit, add, or delete form data. You can only access the folders and forms, whose owner is in your target population.
**Edit via API: Users who have "Admin access to OData API" permission can access all the forms which are not in their folders, but they cannot edit it. Edit action is permitted only for the forms which are in the API users’ own inbox.
2. When using FormHeader entity to query data, if you want to fetch the deleted forms, select “Include Deleted forms in Forms ODATA API”.
3. “Admin Access to Forms OData API” permission allows you to query forms of all users, but this might be restricted by the specific form template permissions.
**What does “Form template permission” mean: section permission and field permission configured in form template.
For example, the admin user wants to query data in summary section, but hidden permission is configured for all roles in all steps for the section:
Then, when querying summary section, the result would return “null”:
This logic also applies to field permission:
If manual overall rating is enabled for summary section, but none permission is configured for “Manual Overall Rating” field for all roles in all route steps, when admin user queries form's final official rating (overallFormRating) in summary section, the API returns “null”:
Authentication
Please refer to the guide here for more information on authentication: Authentication
API server list
List of SAP SuccessFactors API Servers
Query options
1.You can query with key predicate, for example,
https://<API-Server>/odata/v2/FormHeader('12345')
*the number in the single quotation mark is form id (formDataId).
With this uri, you query the data for one form only.
2. Or, you can also query with system query options, for example,
https://<api server>/odata/v2/FormHeader?$format=json&$filter=formSubjectId eq 'sfadmin' and formDataStatus eq 3&$orderby=formDataId desc
*formDataStatus: 3 stands for form in completed stage. Please refer to the guide here formDataStatus for more details.
With this uri, you query data for forms whose subject is sfadmin, whose form data status is completed and ordering the returned result by descending order of form id.
More details on system query options: System Query Options
Basic Scenario 1: get the final rating of a performance form
In below example form, in summary section the manual overall rating is 5 and calculated form rating is 1.38.
Uri:
https://<api server>/odata/v2/FormHeader?$format=json&$filter=formSubjectId eq 'xxxxx' and formDataId eq XXXXX&$expand=formLastContent/pmReviewContentDetail/summarySection/overallFormRating,formLastContent/pmReviewContentDetail/summarySection/calculatedFormRating&$select=formLastContent/pmReviewContentDetail/summarySection/overallFormRating/rating,formLastContent/pmReviewContentDetail/summarySection/calculatedFormRating/rating
**Replace subject id and form data id in the uri
Query result:
Note
1.To get the latest rating info, start expanding from formLastContent.
2.To get calculated form rating, make sure that
(1) in form template xml, in fm-meta section, display-calculated-rating is set to "true", regardless of scale adjusted calculation is enabled or not. For example:
<scale-adjusted-calculation enable="false" display-calculated-rating="true">
</scale-adjusted-calculation>
(2) no field permission configured on the “calculated-overall-rating” field that restricts the API user from accessing it.
Basic Scenario 2: Not sure which navigation entity leads the rating you want to query
In this scenario, you can expand the hierarchy level by level to get to the rating you want.
Take the above form as an example,
1. Expand to summary section first: $expand=formLastContent/pmReviewContentDetail/summarySection
2. Notice that there are several navigation properties inside summaySection:
3. Then, try expand further the related entities from the navigation properties to check the result. For example,
$expand=formLastContent/pmReviewContentDetail/summarySection/calculatedFormRating,
formLastContent/pmReviewContentDetail/summarySection/overallFormRating
4. The example form has manual overall rating 5 and calculated form rating 1.38 on form. In the returned API result, check which rating value matches the one you want to query on form.
You can see that rating 1.38 is under “calculatedFormRating”:
rating 5 appears under “overallFormRating”:
Advanced Scenario: query official rating given in every route step
In ad hoc report or story report, it is not possible to retrieve official rating submitted in every route step. You can only fetch the final rating.
But it is possible with API. As a new form content is generated for every step routed in performance forms, we can fetch the rating from every generated form content via formAuditTrails/formContent.
* Different to formLastContent, which only returns the latest form content.
Uri:
https://<api server>/odata/v2/FormHeader?$select=formAuditTrails/formContent/pmReviewContentDetail/summarySection/overallFormRating/rating,formAuditTrails/formContentAssociatedStepId,formAuditTrails/formContentId,formDataId&$expand=formAuditTrails/formContent/pmReviewContentDetail/summarySection/overallFormRating&$filter=formTemplateId eq xxxx&$format=json
Note
1. Please note that it is not possible to get the rating for all forms in the instance in one go. Please consider use formTemplateId as filter so you can query the results by template.
**You can get form template id by
2. if the returned data is too large, you may encounter timeout issue. In such case, you can customize the page size by setting a different number with parameter: Custom Page Size
What you need to provide to support for API case troubleshooting
Kba and guide reference
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
24 | |
6 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 |