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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Form cannot save to Az...
Power Apps
Unanswered

Form cannot save to Azure SQL Table with FOREIGN KEY SAME TABLE constraint

(0) ShareShare
ReportReport
Posted on by 313

Hi all, 

 

I have a table where I want to structure a parent-child relationship. 

 

The way I intend to do thisis by means of other columns in the same table referencing the primary key by means of a foreign key. 

 

the 3 columsn in question are: 

 

id - primary key, identity autoincrement

root_id - foreign key to id

parent_id - foreign key to id

 

I would use the root_id to fetch all child items of a root node, or the parent_id to fetch the immediate siblings.

 

foreign key columns are set to accept NULL values. 

 

When I try to save it though, I get the error: 

 

Invalid Solicitation.

Server Response: Microsoft SQL: The INSERT statement conflicted with the FOREIGN KEY SAME TABLE constraint "FK_process_item_process_item2".

 

Are FOREIGN KEY SAME TABLE simply unsupported, or there is some trick to saving to it? 

Categories:
I have the same question (0)
  • Verified answer
    v-xida-msft Profile Picture
    on at

    Hi @TiagoFreire ,

    Do you define Foreign keys within your SQL table?

     

    Currently, within PowerApps,  the FOREIGN KEY SAME TABLE constraint is not supported. If you want to insert records into a SQL Table which has defined FOREIGN KEY SAME TABLE within, the conflict error would show up.

     

    Actually, it is not necessary to define FOREIGN KEY SAME TABLE constraint within your SQL Table. Based on the needs that you mentioned, I think the Filter function in PowerApps could achieve your needs.

    If you want to fetch all child items of a root node, please take a try with the following formula:

    Filter(
     '[dbo].[YourSQLTable]',
     root_id = "A specific id value"
    )

    If you want to fetch the immediate siblings, please take a try with the following formula:

    Filter(
     '[dbo].[YourSQLTable]',
     parent_id = "A specific id value"
    )

    Please consider take a try to remove the FOREIGN KEY SAME TABLE constraints from your SQL Table, then re-create a new app based on your SQL table, take a try with above Filter formulas to retrieve proper records.

     

    More details about Filter function, please check the following article:

    Filter function

     

    Best regards,

  • Community Power Platform Member Profile Picture
    on at

    I'd like to make a note that this is helpful as that means any Azure SQL database connector means that cannot define any Foreign Key relationship and therefore there is a lot more manual maintenance of the database that which is to have PowerApps perform on it @v-xida-msft ? 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard