If I go directly to SQL database and execute DELETE statement
DELETE FROM [dbo].[List]
WHERE ListID = '25'
I am getting an error message
Msg 547, Level 16, State 0, Line 4
The DELETE statement conflicted with the REFERENCE constraint "FK_ListMember_List". The conflict occurred in database "AxysImp", table "dbo.ListMember", column 'ListId'.
Which is a proper behavior since there is a foreign key constraint on ListMember table and ListMember table contains rows with ListId=25.
When I try to delete the same record from the SharePoint gallery using the following ON SELECT command:
Remove(
'[dbo].[List]',
ListGallery.Selected
);
Notify(Text(IsEmpty(Errors('[dbo].[List]'))))
the record does not get deleted, but the Errors collection remains empty, which means i am not notified about the error.
Please help.
Solved! Go to Solution.
Try this
RemoveIf(
'[dbo].[List]',
ListID = ThisItem.ListID
)
);
Notify(
Text(
IsEmpty(
Errors(
'[dbo].[List]',
LookUp(
'[dbo].[List]',
ListID = ThisItem.ListID
)
)
)
)
)
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.
Is the remove botton inside the Gallery or Outside the Gallery. If Inside the Gallery, try:
Remove([dbo].[List],LookUp([dbo].[List],ID = ThisItem.ID))
------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
Yes, my button is within the gallery.
I have tried two versions:
Remove('[dbo].[List]',LookUp('[dbo].[List]',ListID = ThisItem.ListID));Notify(Text(IsEmpty(Errors('[dbo].[List]',LookUp('[dbo].[List]',ListID = ThisItem.ListID)))))
and
Remove('[dbo].[List]',LookUp('[dbo].[List]',ListID = ThisItem.ListID));Notify(Text(IsEmpty(Errors('[dbo].[List]'))))
Record does not get deleted (rightly so), but the Notify result is still true, which means no error was detected.
Try this
RemoveIf(
'[dbo].[List]',
ListID = ThisItem.ListID
)
);
Notify(
Text(
IsEmpty(
Errors(
'[dbo].[List]',
LookUp(
'[dbo].[List]',
ListID = ThisItem.ListID
)
)
)
)
)
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.
Hello Warren,
I give you a credit for solving this. I came to the same conclusion yesterday and was about to post my solution, which is essentially the same.
While there is a solution to the problem, the question remains, why Remove() does not handle errors properly and must be replaced with RemoveIf().
My solution:
RemoveIf(
'[dbo].[List]',
ListID = ThisItem.ListID
);
If(
!IsEmpty(
Errors(
'[dbo].[List]',
LookUp(
'[dbo].[List]',
ListID = ThisItem.ListID
)
)
),
Notify(
"Member items present, remove first",
NotificationType.Error
)
)
Thanks @ZStaniek ,
The post is also about other people finding it.
I always use RemoveIf as it always works - I guess I don't look for reasons why other things don't too much unless I need to use them.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
187 | |
53 | |
52 | |
38 | |
37 |
User | Count |
---|---|
282 | |
97 | |
86 | |
80 | |
77 |