cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gmcanally
Level: Powered On

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
Super User
Super User

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

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
Super User
Super User

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

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
gmcanally
Level: Powered On

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

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,

Super User
Super User

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

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. Smiley Happy 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
gmcanally
Level: Powered On

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

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.

 

Super User
Super User

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

Interesting. I don't think the data table works here. I tried something similar with a gallery and it works fine. Smiley Sad 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
gmcanally
Level: Powered On

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

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?

Super User
Super User

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

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 Smiley Happy 
  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 Smiley Sad 
  6. Changed the DataTable to be Items = Filter(Employees, ID = 1)
    1. Hardcoded, still blank Smiley Sad 
  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 Smiley Happy 

 

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
Highlighted
Super User
Super User

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

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. Smiley Sad 

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
gmcanally
Level: Powered On

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

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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 52 members 3,282 guests
Please welcome our newest community members: