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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to insert items in...
Power Apps
Unanswered

How to insert items into SP List without User input or Displaying item?

(0) ShareShare
ReportReport
Posted on by 15

Hi All, 

In my App I am providing the user with the ability to Add an item. Where I am getting stuck is at adding the current logged in user's email and name to a SP List to an newly created record,  I get the following result: 

UserNotGettingAdded.png

 As you can see, as soon as I Submit my form everything gets created EXCEPT the User email & User's Name (First Row with ID 66 is how it SHOULD be, from 74-77 is how it's not working) .

 

I have the following code in my OnStart that checks if a user exists or not and adds the user if they do not exist: 

 

 

// 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);
);

 

 This works fine at the start but IF an existing user needs to add another record, I have no idea how to auto-insert their Email / user name. As always, I appreciate any help! 

Categories:
  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    I am not sure if I understood your problem but you can always try to use a LookUp to fill the Email / UserName

     

    Since they are already created, I think it should not be a problem

     

    If you need additional help please tag me in your reply and please like my reply.
    If my reply provided you with a solution, pleased mark it as a solution ✔️!

    Best regards,
    Gonçalo Nogueira

    Check my LinkedIn!

    Check my User Group (pt-PT)!

    Last Post on Community

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @Ali1 

     

    Looks like you are discussing 2 issues here. Please forgive us if we understood incorrectly.

     

    1. No User Fullname and Email for New record

    2. Update Fullname or Email for Existing record

     

    With this assumption, providing code here

    // 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(wUserRecord),
     With(
     {wUserRecord:
     Patch(
     LSS_TRACKER,
     Defaults(LSS_TRACKER),
     {
     LSSPersonName: CurrentUserFullName,
     LSSPersonEmail: varLoggedInUser.Email, 
     Uzer: {
     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);
     ),
     //Existing User
     With(
     {wUserRecord:
     Patch(
     LSS_TRACKER,
     Defaults(LSS_TRACKER),
     {
     LSSPersonName: CurrentUserFullName,
     LSSPersonEmail: varLoggedInUser.Email, 
     
     }
     )
     },
     Set(varUser, wUserRecord.FullName);
     Set(varRole, wUserRecord.LSSRole.Value);
     Navigate(AdminView,ScreenTransition.Fade);
     ) 
    );

     

    Note: LSSPersonEmail column name to be updated if it's different 


    Thanks,
    Stalin - Learn To Illuminate

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard