cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Error() is not raised after Remove()

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.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Error() is not raised after Remove()

@ZStaniek ,

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.

View solution in original post

5 REPLIES 5
Highlighted
Super User III
Super User III

Re: Error() is not raised after Remove()

 

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.

 

Highlighted
Regular Visitor

Re: Error() is not raised after Remove()

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.

 

 

 

Highlighted
Super User III
Super User III

Re: Error() is not raised after Remove()

@ZStaniek ,

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.

View solution in original post

Highlighted
Regular Visitor

Re: Error() is not raised after Remove()

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
)
)

Highlighted
Super User III
Super User III

Re: Error() is not raised after Remove()

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.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

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

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

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