web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / No Items to Display er...
Power Apps
Unanswered

No Items to Display error OR New Item created when not needed

(0) ShareShare
ReportReport
Posted on by 15

Hi all, I seem to be running into what seems to be a simple issue but I cannot figure out the fix. All data is being saved to a Sharepoint List. Let me begin by sharing my code (added to the OnStart section for the App):

 

```

// Obtain username and email of the logged-in user

Set(varLoggedInUser, User());



// Find the user with a matching email in the App Users list

With(

{wUserRecord: LookUp(LSS_TRACKER, Uzer.Email=varLoggedInUser.Email)},

Set(varUser, wUserRecord.FullName);

Set(varRole, wUserRecord.LSSRole.Value);

Set (varID, wUserRecord.ID);

Set(CurrentUserFirstName, Office365Users.MyProfile().GivenName);

Set(CurrentUserFullName, Office365Users.MyProfile().GivenName & " " & Office365Users.MyProfile().Surname)

);



// If matching user is not found, insert a new user into the list with the role User

If(IsBlank(varRole),

With(

{wUserRecord:

Patch(

LSS_TRACKER,

Defaults(LSS_TRACKER),

{

LSSPersonName: CurrentUserFullName,

Uzer: {

'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",

Claims:"i:0#.f|membership|"& varLoggedInUser.Email,

Department: "",

DisplayName: varLoggedInUser.FullName,

Email: varLoggedInUser.Email,

JobTitle: "",

Picture: ""

}



}

)

},

Set(varUser, wUserRecord.FullName);

Set(varRole, wUserRecord.LSSRole.Value);

Navigate(NewUser,ScreenTransition.Cover);

),

Navigate(AdminView,ScreenTransition.Fade);

);

 

What this does is:

1. Check if current user exists or not.

2. IF exists go to a certain Screen.

3. If does NOT exist then

4. Create the user (plus fill in a few additional fields on the SP List).

5. Go to another screen with another Form to complete additional user details to current item

 

The problem is in the last step for a User who does not exist. After creating the user it goes to the screen called `NewUser` which contains a form BUT if the form is set to Edit mode then I get a `No Items to Display` message

 

If Form is set to EditModeIf Form is set to EditMode

 

If I set the form to New then I can interact with the form but when its time to submit (There is a button with the code `SubmitForm(UserInputFields)`in the OnSelect section).

 

If Form Set to NewModeIf Form Set to NewMode

 

A New item is created, which is not what I need: 

 

IfFormSet_NewMode3.png

I need it to update the current item (in this example - the one with the ID 59) not create a new one, what am I doing wrong here?

Categories:
I have the same question (0)
  • vwyankee Profile Picture
    360 on at

    The form needs to be in edit mode with the "Item" Property looking up the ID of the new user SP item that was just created. Set a variable from your wUserRecord.ID to use in your form Item property as the lookup. If not clear, I can give an example.

  • Ali1 Profile Picture
    15 on at

    Hi @vwyankee , Thanks for replying and yes please an example would be really helpful! 

  • Verified answer
    v-xiaochen-msft Profile Picture
    on at

    Hi @Ali1 ,

     

    According to your description, I think you should use edit form instead of new form in the 5th step. The edit form shows 'no item to display' because the formula of the item attribute of your form is wrong .

     

    Please try this formula:

     

    // Obtain username and email of the logged-in user

    Set(varLoggedInUser, User());

     

    // Find the user with a matching email in the App Users list

    With(

    {wUserRecord: LookUp(LSS_TRACKER, Uzer.Email=varLoggedInUser.Email)},

    Set(varUser, wUserRecord.FullName);

    Set(varRole, wUserRecord.LSSRole.Value);

    Set (varID, wUserRecord.ID);

    Set(CurrentUserFirstName, Office365Users.MyProfile().GivenName);

    Set(CurrentUserFullName, Office365Users.MyProfile().GivenName & " " & Office365Users.MyProfile().Surname)

    );

     

    // If matching user is not found, insert a new user into the list with the role User

    If(IsBlank(varRole),

    With(

    {wUserRecord:

    Patch(

    LSS_TRACKER,

    Defaults(LSS_TRACKER),

    {

    LSSPersonName: CurrentUserFullName,

    Uzer: {

    '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",

    Claims:"i:0#.f|membership|"& varLoggedInUser.Email,

    Department: "",

    DisplayName: varLoggedInUser.FullName,

    Email: varLoggedInUser.Email,

    JobTitle: "",

    Picture: ""

    }

     

    }

    )

    },

    Set(varUser, wUserRecord.FullName);

    Set(varRole, wUserRecord.LSSRole.Value);

    Set(varID),wUserRecord.ID);
    Refresh(LSS_TRACKER);
    Navigate(NewUser,ScreenTransition.Cover);

    ),

    Navigate(AdminView,ScreenTransition.Fade);

    );

     

    Then you could set the Item property of your form control to :

    LookUp(LSS_TRACKER,ID=varID)

     

    Best Regards,

    Wearsky

  • Ali1 Profile Picture
    15 on at

    Thanks so Much @v-xiaochen-msft  I was trying out what @vwyankee  had recommended and had figured out the LookUp thing but the key was the Refresh command! That got the App to read and store the ID properly! Thanks a bunch!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard