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

Using the List Item ID

I have found many helpful articles and questions, but none seem to get me exactly what I want. My process involves 3 lists:

License Requests

Names of Users

Names of Experts

 

A License Request form is filled out and the individuals are entered on a screen depending on their license type (user or expert).  Each license type screen (Add Users or Add Experts) has cascading dropdowns. Then I use the Patch function to write the users to the Names of Users list and the experts to the Names of Experts list. However, I need the list item ID from the License Request list so I can sew everything together.

 

I know how to get the ID (FormName.LastSubmit.ID), but I don't know what to do with it. I thought I could set a global variable and use that in the Patch function on the Add Users screen, but it doesn't seem to work. How can I use the List Item ID in other places within my app so I can write it to different lists?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Using the List Item ID

Hi @ACPBSCi ,

I cannot test this but you had one bracket in the wrong place - firstly try the below 

Set(varID,ItemID);
Set(
   AllItemsString,
   Concat(
      UserInfo.AllItems,
      Concatenate(
         UserItemNumber.Text,";",
         UserName.Text,";",
         UserEmail.Text,";",
         UserLicenseType.SelectedText.Value,";"
      ) & "|"
   )
);
Patch(
   'User List',
   Defaults('User List'),
   {
      ItemID:varID,
      Users:AllItemsString
   }
);
Notify(
   "User information saved successfully.",
   NotificationType.Success
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

6 REPLIES 6
Highlighted
Super User III
Super User III

Re: Using the List Item ID

Hi @ACPBSCi ,

Firstly YourFormName.LastSubmit.ID will get you the ID of the last record submitted in either Edit or New mode and you could set a Variable on the OnSuccess of the form

Set(
   vID,
   YourFormName.LastSubmit.ID
)

 and use vID as the Default of the numeric field in your next list you want to tie to it. I actually use this Variable on all forms, setting it when the item is selected from a gallery

Set(
   vID,
   ThisItem.ID
)

and then forms Item property can be 

Lookup(
   ListName,
   ID-vID
)

If you use the two together, you can return to the new record but setting the form mode to View on the OnSuccess of the new screen.

You should be able to either SubmitForm with the Default value or Patch as you have mentioned using this Variable value.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted
Microsoft
Microsoft

Re: Using the List Item ID

Hi@ACPBSCi,

Based on the issue that you mentioned, do you want to get a specific list Item then store that specific list item in a global variable?

Could you please share more about your scenario, is there any corresponding field in the screen for Add Users or Add Experts?

I agree almost with@WarrenBelz. Here is some addition.

Yes, absolutely you can store ID into the global variable, then bring the corresponding User/Expert to the specific screen.

Set the OnSelect property of the submit button as below.

 

Set(myVar,FormName.LastSubmit.ID)

 

Then in the edit screen, (Not sure if you're populating a gallery, form, or something else here) you could set a global variable when clicking your edit button as below

 

Set(myVar, Gallery1.Selected.ID)

 

At the same time, you can use Filter() function in your Items() property of your gallery/form to something like.

 

Filter(myDataSource, ID = myVar)

 

Best Regards,

Qi

Highlighted
Helper II
Helper II

Re: Using the List Item ID

Thank you! Now that I know how to get the variable in a reliable way, I need to take the next step, which is writing it back to the list.

When the input screen is submitted to the license list, it generates an item ID. I need that item ID to use in the next 2 screens, experts and users. I am successfully capturing the ID, so that's good news. However, I am not successful writing it back to the experts or users lists.

Set(varID,ItemID);Set(AllItemsString,Concat(UserInfo.AllItems,Concatenate(UserItemNumber.Text,";",UserName.Text,";",UserEmail.Text,";",UserLicenseType.SelectedText.Value,";","|")));Patch('User List',Defaults('User List'),{ItemID:varID,Users:AllItemsString});Notify("User information saved successfully.",NotificationType.Success)

My variable (varID) has the correct ID in it. I want to use that variable to populate a column I created in the users and experts list. When I tried writing it to the Title column, I got an error saying that I needed to implement IConvertible. So I created a number column and I get the same error.

What am I doing wrong?

Highlighted
Super User III
Super User III

Re: Using the List Item ID

Hi @ACPBSCi ,

I cannot test this but you had one bracket in the wrong place - firstly try the below 

Set(varID,ItemID);
Set(
   AllItemsString,
   Concat(
      UserInfo.AllItems,
      Concatenate(
         UserItemNumber.Text,";",
         UserName.Text,";",
         UserEmail.Text,";",
         UserLicenseType.SelectedText.Value,";"
      ) & "|"
   )
);
Patch(
   'User List',
   Defaults('User List'),
   {
      ItemID:varID,
      Users:AllItemsString
   }
);
Notify(
   "User information saved successfully.",
   NotificationType.Success
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Highlighted
Helper II
Helper II

Re: Using the List Item ID

That did the trick. And for writing it back to my other lists, I had to tweak my Patch formula just a bit:

{Title:Value(ItemID.Text)...

I kept getting an error saying that the column type didn't match. I got it working and I am so thrilled!

 

Highlighted
Super User III
Super User III

Re: Using the List Item ID

That's great @ACPBSCi ,

 

Please click Accept as solution  - this will help others find it more readily. It also closes the item.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,938)