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

Returning Last item posted and filtering by User

I am trying to return a confirmation to the user to ensure that their sample request was posted successfully.  I am trying to show a label that has the following in the text property: 

 

CONCATENATE("Sample request for ", LastItemAdded.Nomenclature, " was successfully posted")

 

 

Now in my submit button I have the following:

 

Patch('Sample Request',
    Defaults('Sample Request'),
       {Supplier: SupplierDropDown.SelectedText.Value, 
        Branch: BranchDropDown.SelectedText.Value, 
        Customer: AccountDropDown.SelectedText.Value, 
        Nomenclature: ItemListBox.Selected.'Full Item Nomenclature', 
        Customer_Account_Number: AccountNumber.Text});

Refresh('Sample Request');

Set(LastAddedItem,First(SortByColumns(Filter('Sample Request', Created_By = Label4.Text),"ID",Descending)))

 

 The last line is what I am having an issue with.  I want to filter the list by the current user and return the most current item they posted.  

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resolver I
Resolver I

Re: Returning Last item posted and filtering by User

@rmanthey 

Im stupid:P
Patch allows you to capture the metadata also...
Try something similar:

Set(varResult,Patch(Custom,Defaults(Custom),{Title:"test"}))

 Or If you want to get specific property:

Set(varResult,Patch(Custom,Defaults(Custom),{Title:"test"}).ID)

 

Hope this will resolve your problem - if yes please mark the answer as solution.

View solution in original post

4 REPLIES 4
Highlighted
Resolver I
Resolver I

Re: Returning Last item posted and filtering by User

Hi @rmanthey 
Are you using SharePoint as the back-end?
If yes, it looks like you have issue here: 

Created_By = Label4.Text

You are comparing the complex Create-by with the string.

You can try to:

Filter(Custom,'Created By'.DisplayName=Label1.Text)

 

Or store current User in variable: set(varUser,User())

And apply filter:

Filter(Custom,'Created By'=varUser)

 

Yet, if this is not SharePoint there can be other issue like to short delay when you are creating new item = datasource refresh is to slow.

Highlighted
Resolver I
Resolver I

Re: Returning Last item posted and filtering by User

@rmanthey 

Im stupid:P
Patch allows you to capture the metadata also...
Try something similar:

Set(varResult,Patch(Custom,Defaults(Custom),{Title:"test"}))

 Or If you want to get specific property:

Set(varResult,Patch(Custom,Defaults(Custom),{Title:"test"}).ID)

 

Hope this will resolve your problem - if yes please mark the answer as solution.

View solution in original post

Highlighted
Super User
Super User

Re: Returning Last item posted and filtering by User

Hi @rmanthey 

 

Is the data source for this SharePoint?

If yes, then I would create a text column for the userEmail, and when you submit records then use that text field to filter by comparing User().Email to userEmail. Filtering by People columns (in SharePoint) can get complicated and you will likely run into delegation issues.

 

Set(
    LastAddedItem,
    First(
          SortByColumns(
                        Filter(
                               'Sample Request',
                               userEmail = User().Email
                        )
                        ,
                        "ID"
                        ,
                        Descending
          )
    )
)

 

If this is not SharePoint, then disregard the above, although generally filtering by text values is more performant,

 

Kind Regards,

Sancho


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Highlighted
Resolver I
Resolver I

Re: Returning Last item posted and filtering by User

@iAm_ManCat  agrees that the filtering text value will be much quicker think also there is problem with yes/no boolean and I'm changing the column to text instead.

@rmanthey not sure how important for you is filtering the User information as your key concern was around sending User confirmation of the item creation.
As per my previous post you can capture Patch into variable - after execution of Patch it will return properties of created item.
If you will remove the data refresh and filtering it will make your app faster and lighter from performance perspective.

 

@iAm_ManCat Is my thinking correct?

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,122)