web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Retrieve ProjectId fro...
Power Apps
Answered

Retrieve ProjectId from ProjectName

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have the following:

P1.png

 

 

 

 

 

When I press Add my Project table gets patched and the an Id is automatically assigned by the SQL server.

That works smoothly.

Now I want to collect the Id of the project into a variable so:
As the last 2 lines in the Add button I have the following:

ClearCollect(Projects,'[PowerApp].[ProjectBoard]'.Id, '[PowerApp].[ProjectBoard]'.ProjectName);
Set(varProjectID, Filter(Projects.Id, Projects.ProjectName = TextInput3.Text));

But the last line fails with this error:

Incompatible type. We can't evaluate your formula because the context variable types are incompatible with types of vaules used in other places in your app.

Does anybody know why?
Or is there another way of getting the Id?

Categories:
I have the same question (0)
  • timl Profile Picture
    37,283 Super User 2026 Season 2 on at

    @Anonymous 

    The reason for this error is because the filter function returns a table, and I suspect that varProjectID is a variable that you've used to store an integer value in other places in your app.

    Rather than make a call to look up the project record that you added by project name, the correct way to do this is to retrieve the return value from patch. This will give you the ID of the record that was created.

    Here's an example of the syntax you would use.

    https://powerusers.microsoft.com/t5/Building-Power-Apps/How-to-get-created-record-id-from-patch-function/m-p/263771

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks, but...how do I get that single Id value into a variable?
    Can I use Set(VarName, CollectionName) ?
    Won't the variable be angry and say that you are trying to put a table into a variable?

  • Verified answer
    timl Profile Picture
    37,283 Super User 2026 Season 2 on at

    Hi @Anonymous 

    I don't understand what exactly you want to do here. It isn't necessary to collect the project details into a collection. If you want to collect only the ID and projectname columns of all rows into a collection, this is the syntax that you use.

    ClearCollect(Projects, ShowColumns('[PowerApp].[ProjectBoard]', "Id","ProjectName"))


    You would then use the following formula to retrieve the ID of the record by project name.

    Set(varProjectID, LookUp(Projects, ProjectName = TextInput3.Text).Id)

     

    I recommend that you directly retrieve the ID from the return value from patch as I mentioned earlier.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    All I want is to get the Id from the created record into a variable.
    This formula works for me: 

    Set(
    varProjectID,
    LookUp(
    '[PowerApp].[ProjectBoard]',
    ProjectName = TextInput3.Text
    ).Id
    )

    I don't understand the other method that you propose, of getting it directly from a ClearCollect

    Maybe you have more formula examples?
    Thanks

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 421 Most Valuable Professional

#2
11manish Profile Picture

11manish 153 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 116 Super User 2026 Season 2

Last 30 days Overall leaderboard