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

Use currentUser.email as filter in Basic table with data adapter

M-K
Active Participant
0 Likes
412

Hello,

I'm doing the SAP CodeJam Tutorial, in Part 10: "Create Action Project to Post Data to CAP Service",  Step 8: "Build My Orders screen", I need to bind the condition for "customer" to a formula containing "systemVars.currentUser.email", however the screenshot there shows that the condition is directly bound to "System variable" -> "Currently logged in user.email"

When I bind it like in that screenshot I don't get any data displayed in the preview, because the filter is set to "currentUser.email" instead of the actual email-address.

MK_1-1742565921870.png

When I bind it via a formula it works as expected and the filter in the request is set to the correct email-address.

MK_2-1742566365848.png

I'd like to know if this is a normal behavior, a bug or I'm missing something here.

Thank you!

 

Accepted Solutions (0)

Answers (1)

Answers (1)

Sankara1
Product and Topic Expert
Product and Topic Expert
0 Likes

To use the current user's email as a filter in a basic table with a data adapter in SAP, you can follow these steps:

Steps

  1. Retrieve Current User's Email:

    • Use the sap.ushell.Container.getService("UserInfo").getEmail() method to get the current user's email address. This method returns the email of the logged-in user. javascript var userEmail = sap.ushell.Container.getService("UserInfo").getEmail();
  2. Apply Filter in Data Adapter:

    • Use the retrieved email to apply a filter in your data adapter. This can be done by setting the filter parameters in your table binding. javascript <Table id="idExternalFindingTable" updateFinished="onupdateFinished" inset="false" growing="true" growingThreshold="5" items="{ path: 'maindata>/Findings', parameters: { expand: 'assignedTeamUsers' }, filters: { path: 'user_userEmailId', operator: 'EQ', value1: userEmail }}"> </Table>

Example Code

Here is an example of how you can implement this in your SAP UI5 application:

// Retrieve the current user's email
var userEmail = sap.ushell.Container.getService("UserInfo").getEmail();

// Apply the filter in the table binding
<Table
  id="idExternalFindingTable"
  updateFinished="onupdateFinished"
  inset="false"
  growing="true"
  growingThreshold="5"
  items="{ path: 'maindata>/Findings',
           parameters: { expand: 'assignedTeamUsers' },
           filters: { path: 'user_userEmailId',
                      operator: 'EQ',
                      value1: userEmail }}">
</Table>
M-K
Active Participant
0 Likes
Thank you Sankara, but my question is releated to SAP Build, not SAPUI5.