cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
msgeorge
Regular Visitor

Check SharePoint list when a user first uses app and write new record if user doesn't exist in list.

I'm trying to develop a training track app and can't quite figure out a step. When a user opens the app I want it to check if the user has a record in a SharePoint list. If the user if opening the app for the first time and does no have a record I want the app to create a new record in the SharePoint list. 

 

The SharePoint list has a Name field and an User E-mail field, it also has fields for score that will be set to 0 on record creation. 

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User II
Super User II

Hi @msgeorge 

In the OnStart property of the app

 

Set(
    useremail,
    User().Email
);
If(
    IsBlank(
        LookUp(
            SPlist,
            email = useremail
        )
    ),
    Navigate(
        ScrNewUser,
        None
    ),
    Navigate(
        ScrFirst,
        None
    )
)

 

I prefer to use Email because names can sometimes be the same. In the formula on start, the app checks whether the user's email is in the list and if not, it goes to the screen for entering a new user. This screen will probably contain a Form set with its default mode as New 

If a match to the lookup is found, (ie, its not blank), then it navigates to the standard opening screen for established users.

View solution in original post

6 REPLIES 6
Drrickryp
Super User II
Super User II

Hi @msgeorge 

In the OnStart property of the app

 

Set(
    useremail,
    User().Email
);
If(
    IsBlank(
        LookUp(
            SPlist,
            email = useremail
        )
    ),
    Navigate(
        ScrNewUser,
        None
    ),
    Navigate(
        ScrFirst,
        None
    )
)

 

I prefer to use Email because names can sometimes be the same. In the formula on start, the app checks whether the user's email is in the list and if not, it goes to the screen for entering a new user. This screen will probably contain a Form set with its default mode as New 

If a match to the lookup is found, (ie, its not blank), then it navigates to the standard opening screen for established users.

View solution in original post

Thank you for your answer. That all makes sense.

 

In your code SPlist is a variable? And then in the variable I define the location of the the SharePoint List?

 

How would I go about making it creating a new record automatically instead of going to the new user screen?

 

 

@msgeorge 

SPlist a shorthand for the actual name of your SharePoint list that contains the names, email addresses and other demographic information about your users. FYI, PowerApps is built around screens that contain the controls used for viewing, editing and creating new records that are stored in the back end of your App, usually SharePoint lists, Excel tables, etc. The typical way of creating a new record is to use an EditForm that is a control on a screen. 

@Drrickryp 

To make sure understand I would connect data. And then where SPlist is I would enter TrainingUsers for example?

 

I was hoping I could build it more automated but if I built a screen and had the new user validate some basic data to have it built the new record that work. 

Drrickryp
Super User II
Super User II

Exactly so!  However, if you want PowerApps to do the work of setting up your screens and controls, I suggest that you save the URL for your SharePoint list then go to make.powerapps.com and select + Create on the left side of the screen and follow the instructions.  It will create a very nice 3 screen app from your list that you can look at and see how the various controls and functions are built in. No need to reinvent the wheel!_1.png

Thank you very much for your help! 

I'll have to try the start from SharePoint option.  

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,396)