cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gmcanally
Advocate II
Advocate II

Accessing Sharepoint List Item ID from Screen (instead of Form)

I have a custom Sharepoint PowerApps form that I've added some fields to within the Screen, but outside of the standard EditForm for the list. I'd like to access the Sharepoint List Item ID from the Screen level when editing an item from the list so that I can load pertinent information from a secondary list that uses the Item ID as a foreign key.

 

I've tried adding the ID field to the EditForm and then referenceing the field's content on the Screen's On Visible action, but think it might run that code before the ID field is assigned its value by the form.

 

I've also tried using the SharepointIntegration.SelectedItemID, but this isn't returning the value either.

 

Is this even possible?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

What if you have OnVisible start a timer for 1 second. Then when the timer is done do your collect. Maybe that way your ID will be ready to go by then? 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

View solution in original post

13 REPLIES 13

Yes. You didn't ask the question the way I expected so maybe I am confused but I don't think so.

 

Within the form you can reference ThisItem.ID to get the ID you are looking for. 

 

In this video PowerApps LookUp Column functionality I cover a lot of fun stuff which it sounds like you are digging into.

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Thanks for the reply. ThisItem appears to be within the scope of the Form, but not the Screen that the form is in.

 

I've attempted to refer to ThisItem at the Screen level, but it's not a recognized object,

Okay. That is correct sorry if I missed that the first time. 

 

Can't you put your dropdown on the form to avoid this issue? Just add a custom card and you can do whatever you would like. 🙂 Maybe a bit more context on what you are hoping to do?

 

Back to your more direct question. I put this in a Label outside of the form and it shows fine for me. 

 

SharePointIntegration.SelectedListItemID

 

That is slightly different than what you typed? Maybe a typo getting you?

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

On the Screen that contains the EditForm for SharepointList1 I have a Data Table (List2Data) that I need to populate with data from SharepointList2 when the Screen loads.

 

In the On Visible event I have the following as example code:

 

ForAll(Filter('SharepointList2',List1_ID = SharePointIntegration.SelectedListItemID),Collect(List2Data,{Id:ID,Description:Title,...}))

 

When assigning SharePointIntegration.SelectedListItemID to a random field to see what's returned I get only the number 1. There is not an item on the list with that ID number.

 

Interesting. I don't think the data table works here. I tried something similar with a gallery and it works fine. 😞 Not saying that is a final issue but I am walking out the door and that is where it ended. The Data Table doesn't work the Gallery does. 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

I'm a somewhat confused by this. I just tried a gallery and it made no difference. the code above relates to a collection that the Data Table (or Gallery) is associated with. The collection is empty because the Item ID appears to be inaccessible. What did you do with the gallery to make it work?

Ignore this one and look below. The problem is the text doesn't have a color. 

 

Long answer coming.

 

  1. SharePoint clicked customize form in PowerApps (or whatever it says)
  2. Resized SharePointForm1 so it took up less space
  3. Added a label on the screen and set the value to SharePointIntegration.SelectedListItemID
    1. It shows the correct ID 🙂 
  4. Added a data connection to the SharePoint list Employees
  5. Added a DataTable to the screen and set its Items to Filter(Employees, ID = SharePointIntegration.SelectedListItemID)
    1. Choose the Title column (all columns are blank but just to be sure)
    2. It is always blank 😞 
  6. Changed the DataTable to be Items = Filter(Employees, ID = 1)
    1. Hardcoded, still blank 😞 
  7. Added a gallery and set Items to Filter(Employees, ID = SharePointIntegration.SelectedListItemID)
    1. Changed the text label in the gallery to be ThisItem.Title  
      1. It shows one record like it should 🙂 

 

Does that help? The Gallery always works for me. The Data Table never does.

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Wait @gmcanally I figured it out. 

 

This is dumb. Basically, when you add a datatable all of the properties are blank. So it is showing you the items but it has no value for the color. Change Selected Color to Black and you will see your text. SIGH. 😞 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Ah, I see the disconnect. 

 

My data table isn't tied to a sharepoint list, but to a collection. I'm trying to load a filtered list into a collection. This is so the collection can be edited and only patch the entire list with all of the changes in the collection on form submit success rather than as the list items are changed.

 

The filtering on Item ID and Collect needs to be done when the Screen is launched, but the timing of the Screen's OnVisible action appears to have an issue such that SharePointIntegration.SelectedListItemID doesn't return the expected value.

 

It's when I'm referencing SharePointIntegration.SelectedListItemID that's the problem. I'm not sure where else I can do this filtering that will have the same effect.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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