Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Unanswered

Fetching ID from Form using last submit function

Posted on 24 Nov 2024 16:05:02 by 37
Hello Everyone,
 
I am creating and Application in Canvas which sends data of Items purchase and Repair into SharePoint list.
 
Structure of Application:
 
I have Screen with Name Purchase Requisition and in that screen one Form is present which is connected to "Purchase requisition" SharePoint list and one table grid that is also Connected to SharePoint list called "List Items", created using blank vertical gallery 
Below is the Image of Screen 
 
 
First Issue is with Table Grid :
 
Requirement is Table Grid should be able to perform CRUD Operations so for that I am creating a Collection and sending the data into SharePoint list in one go. At first I was able to fetch data from SharePoint list into Collection using this formula :
Applied OnVisible property of Screen
 
ClearCollect(
    colLineItemsUpdates,
    ShowColumns(
        Table(Defaults('Line Items')),
        ID,
        Vendor,
        'Item ',
        Description,
        Quantity,
        Price
    )
);
 
but now its not fetching data from SharePoint list into Collection, My gallery is connected to collection and all the textInputs formula are also correct.
 
Second Issue in Table Grid:
 
Another problem in this At First try when I was able to fetch data into collection I perform some changes in the record of gallery like Delete and Edit on deleting any record in gallery it was deleted in collection but not in sharepoint list and also when editing any record in gallery and On patching it in sharepoint list duplicate entry created.
 
Formula on my delete button:
Remove(colLineItemsUpdates, varRecordToDelete); // Remove the record from the collection
Set(varDeleteButtonPressed, false); // Hide the pop-up after deletion
 
Formula on my Edit Icon :
 
UpdateContext({varGridEditable: true})
 
 
Third Issue : 
 
My form is connected SharePoint list "Purchase REquisition" the thing is when my form is submitted on button click of Submit button i want to fetch the ID from ID column of Purchase Requisition using last submit function and patch that ID into "PRID" column of SharePoint List "List Items" this process will also take place on submit button click.
 
Below is the image of SharePoint list "Purchase Requisition" And "List Items":
 
 
 
Please help me in resolving these issues.
  • ronaldwalcott Profile Picture
    ronaldwalcott 855 on 24 Nov 2024 at 18:10:44
    Fetching ID from Form using last submit function
    Is this a template that you are using?
    If you are using collections the code below would probably be associated with the OnSelect of the Add New button.
    The information that you have provided does not indicate how the list is navigated. That information is necessary in determining how the collection should be populated.
  • SR-02111122-0 Profile Picture
    SR-02111122-0 37 on 24 Nov 2024 at 17:25:59
    Fetching ID from Form using last submit function
    then how can I fetch data into collection?
  • ronaldwalcott Profile Picture
    ronaldwalcott 855 on 24 Nov 2024 at 17:20:15
    Fetching ID from Form using last submit function
    Therefore this option does not fetch data it only creates an empty record.
     
    ClearCollect(
        colLineItemsUpdates,
        ShowColumns(
            Table(Defaults('Line Items')),
            ID,
            Vendor,
            'Item ',
            Description,
            Quantity,
            Price
        )
    );
  • SR-02111122-0 Profile Picture
    SR-02111122-0 37 on 24 Nov 2024 at 17:07:08
    Fetching ID from Form using last submit function
    Table() : this function will create a table in collection,
     
    Defaults('Line Items') : The Defaults() function in PowerApps is used to retrieve the default record structure for a specific data source.
  • ronaldwalcott Profile Picture
    ronaldwalcott 855 on 24 Nov 2024 at 16:57:53
    Fetching ID from Form using last submit function
    What do you think that this function does?
     
    Table(Defaults('Line Items'))
     
     
     
  • SR-02111122-0 Profile Picture
    SR-02111122-0 37 on 24 Nov 2024 at 16:53:44
    Fetching ID from Form using last submit function
    yes
  • ronaldwalcott Profile Picture
    ronaldwalcott 855 on 24 Nov 2024 at 16:46:15
    Fetching ID from Form using last submit function
    First Issue
     
    Are you saying that this formula returns vales rather than create a default record?
     
    ClearCollect(
        colLineItemsUpdates,
        ShowColumns(
            Table(Defaults('Line Items')),
            ID,
            Vendor,
            'Item ',
            Description,
            Quantity,
            Price
        )
    );


    Second Issue
    If you remove the item from the collection how do you know which item to delete from the SharePoint list.

    Third Issue
    LastSubmit does not work if you are using Patch


    Why are you using collections? The information which you provided does not seem to indicate an advantage to this approach. 

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,246

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,884

Leaderboard