cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Verify that DisplayName does not exist in datasource

I am back...

 

I have ran into an issue and can not seem to find the correct answer. I have a PowerApps that is linked to 4 SharePoint Lists as datasources.

 

The main issue is the Employess list and Badge list. 

 

I have a patch command that updates the Employees list if the the Employee is new with Name, email, etc... And this works great, except for when I am attempting to update the employee record and not add a new one. The PowerApps goes through and does an approval process with Status going from "Submitted", "Approved" and "Completed". I need to modify the patch to say if approved and the user exists, update the badge column. If the employee does not exist my current code works.

 

Currently the code keeps making duplicate records for employees when they are Approved and Completed. I just want it to update if the user exists..

 

I hope this makes sense. I tried with IsMatch, but it did not work. And using the <> (not equal) operator does not seem to want to work with DisplayName in 2 different Lists

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

I forgot to add Employees Datasource in Lookup

Patch(
                        'Employees',
                        LookUp(
                            'Employees',
                            EmployeeName.DisplayName = DataCardValue74.Selected.DisplayName
                        ),

 

Thanks to everyone for your input. It was a  face palm moment..

 

View solution in original post

5 REPLIES 5
Highlighted
Resolver I
Resolver I

Hi!

 

You can try to get the record you want to update from SP List, then Patch it with new values.

 

Can you share us the formula of the "commit" event? to see more details.

 

Tnks

Highlighted

I am wondering if I set it the below to say if EmployeeName =  DataCardValue74.Selected.DisplayName then just update the BadgeNumber, IssuedDate and ExpirationDate.

 

 

If(
        varGallery = "BadgeRequests" && DataCardValue76.Selected.Value = "New Resident",
        Concurrent(
            Patch(
                'Employees',
                {
                    EmployeeName: {
                        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUsers",
                        Claims: "i:0#.f|membership|" & DataCardValue74.Selected.DisplayName,
                        Department: "",
                        DisplayName: DataCardValue74.Selected.DisplayName,
                        Email: DataCardValue74.Selected.Email,
                        JobTitle: "",
                        Picture: ""
                    },
                    EmployeeEmail: DataCardValue74.Selected.Email,
                    EmployeeID: DataCardValue77.Text,
                    BadgeNumber: DataCardValue79.Text,
                    IssuedDate: DataCardValue80.SelectedDate,
                    ExpirationDate: DataCardValue81.SelectedDate
                }
                
            ),
            Patch(
                    'Badges',
                    LookUp(
                        'Badges',
                        BadgeNumber = DataCardValue85.Selected.Value
                    ),
                    {
                        Status: {
                            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                            Value: "Assigned"
                        },
                        CurrentlyAssignedTo: DataCardValue74.Selected.DisplayName
                    }
                    
                ),
            SubmitForm(BadgeRequestForm) && UpdateContext({varView: false}) && ResetForm(BadgeRequestForm)
        )
    )
)
Highlighted

Hi!

 

I think that you always adding a new employee with that formula.

 

You need to verify first if user exists with an ID or something, if exists get its record from the sharepoint, and use it as a second parameter of Patch Function.

 

Tell me if it works.

Regards!

Highlighted

You are correct, I did realize this weekend that I was always adding a new record. I am getting an "Name isn't valid. This identifier isn't recognized" when I try to validate if user exists

Patch(
                        'Employees',
                        LookUp(
                            EmployeeName = DataCardValue74.Selected.DisplayName

Why is not recognized? EmployeeName is a people picker in SharePoint. Is there a different syntax when validating people picker fields? 

Highlighted

I forgot to add Employees Datasource in Lookup

Patch(
                        'Employees',
                        LookUp(
                            'Employees',
                            EmployeeName.DisplayName = DataCardValue74.Selected.DisplayName
                        ),

 

Thanks to everyone for your input. It was a  face palm moment..

 

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,981)