cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Remove() function not deleting first 9 records in sql table?

Hello!  Recently new to power apps and running into a unique issue with the remove() funciton. 

It occasionally does not work and fails to remove the ID in question... but it occasionally works. (with no changes)   

Below is a sample of the code.  I am checking two different drop downs in a nested If statement to determine how to handle the delete function.  The drop down assigns an entity id which is equal to the primary key of the table I want to remove the record from.   This is working correctly.  

I was able to do some trouble shooting - and I do not understand the error.  It looks like the command is failing to remove anything that has an ID less then 10.   The command works for ALL records that I've tried whose ID is greater than 9.   

It's almost like the SQL is reading the first few rows in the table as read only.  When I separated the code to its own stand alone statement (no if commands) it was generating the same issue with no populated errors.   

Any thoughts?   It is not a delegation issue as the total number of records in the table to be deleted is less than 500.  

Thank you for your help.  

 

If(d_Actions.SelectedText.Value = "delete", 
(

If(d_EntityName.SelectedText.Value = "unit name",   
Remove('[dbo].[DimUnit]',
LookUp('[dbo].[DimUnit]',ID = Entity_Id));
ClearCollect(
    UNIT,
    Sort(
        '[dbo].[DimUnit]',
        ENTITY_NAME,
        Ascending
    )
);

 

 

2 REPLIES 2
Highlighted
Super User III
Super User III

Re: Remove() function not deleting first 9 records in sql table?

@ax_gosser 

Try to adjust your formula to the following and see if you have the same results.

If(d_Actions.SelectedText.Value = "delete" && d_EntityName.SelectedText.Value = "unit name",   
   RemoveIf('[dbo].[DimUnit]', ID = Entity_Id);
   ClearCollect(UNIT,
      Sort('[dbo].[DimUnit]',
           ENTITY_NAME,
           Ascending
          )
  );

 

Also, wasn't sure on your outer logic on the If's because there was a closing parenthesis missing your posted formula - so I modified that slightly in this example.

 

If this is not working, then I would also check your Entity_Id to see that it is a numeric type and not something else that is needing conversion.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Community Support
Community Support

Re: Remove() function not deleting first 9 records in sql table?

Hi @ax_gosser :

Can you show me the definition of Entity_Id?

Can you tell me more details of your filter rule?

I have tested your code and it works ,so the structure of your code might be correct. The reason I can think of at the moment is that there might be a  problem with the variable  Entity_Id or something wrong with your filter rule.

Ive made a test for your reference:

(When the drop-down control selects "Delete" "Unit Name", delete the record whose "Id" field equals "Entity_Id")

Step1:data source( [dbo].[FB1]) 

database.PNG    

int(datatype:int) is the primary key of '[dbo].[FB1]'

char(datatype:varchar[50]) is a column name of '[dbo].[FB1]'

Step2:add a drop down control(d_Actions) and set it’s items property to :   

 

["delete","not delete"]

 

Step3: add a drop down control(d_EntityName) and set it’s items property to : 

 

["unit name","other choice"]

 

Step4: add a drop down control(Dropdown2) and set it’s items property to : 

 

[dbo].[FB1]

 

Set it’s onchange property to : 

 

Set(Entity_Id,Dropdown2.Selected.int)

 

Set it’s value property to : 

 

int

 

property.PNG

Setp5:add a button and set its OnSelect property to:

 

If(

    d_Actions.SelectedText.Value = "delete",

    ( If(

        d_EntityName.SelectedText.Value = "unit name",

        Remove(

            '[dbo].[FB1]',

            LookUp(

                '[dbo].[FB1]',

                int = Entity_Id

            )

        );

        ClearCollect(

            UNIT,

            Sort(

                '[dbo].[FB1]',

                char,

                Ascending

            )

        )

    ))

)

 

111.PNG222.PNG

Select “2 and Select the Button.

The record whose int field equals 2 has been deleted.

In my test, the records that id are smaller than 10 work good.

 

 

Beat Regards,

Bof

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

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 (5,095)