Mobile App: Delete Button

Mobile App: Delete Button

  

Hello,


I am trying to add a delete button to my app. The delete button is to delete a record from a database and then update a list where it was presented. I only want an admin role to be able to do this. 


I can't figure it out?

Hi Jamie,

You can use the actions to check Roles

And only continue if the user has the correct role. After that you just need to delete the records and refresh the list.

Regards,

Marcelo

Marcelo Ferreira wrote:

Hi Jamie,

You can use the actions to check Roles

And only continue if the user has the correct role. After that you just need to delete the records and refresh the list.

Regards,

Marcelo

Hi Marcleo, How do i refresh the list?


Hi Jamie,

You have a List widget on the screen to display the list. This widget has a source. You just need to change this source to the new list that you get from the database. In mobile when you change this source the refresh will be done automatically.

Regards,

Marcelo

Marcelo Ferreira wrote:

Hi Jamie,

You have a List widget on the screen to display the list. This widget has a source. You just need to change this source to the new list that you get from the database. In mobile when you change this source the refresh will be done automatically.

Regards,

Marcelo


I still don't seem to be able to get it to work?

Here's everything i have...

Solution

You can also pass the index of the record into the delete action and use the ListRemove action to instantly remove the element from the list without doing a data refresh every time:

This would be the action signature, and the content would look something like this:

Solution

Can you share the module so I can look better into it?

Marcelo Ferreira wrote:

Can you share the module so I can look better into it?

I'm not going to share the module, mainly because i don't know how too. 

From the delete button i have created, i have made an OnClick Client action called "DeleteOnClick" this is what is i have made inside that client action: 

This is more than likely wrong but i am very new to outsystems. The first server action that is ran is called "DeleteJobSheetWrapper", inside that action is this:

When I create a new item in the list it is displayed on the correct list however, when i delete the item using the delete button i have created it displays the message "Job Deleted" like i have programmed however it does not remove the item from the list. 


The items in a list and where the list is created are 2 separate screens. Im not sure if that will affect it?

Hi Jamie,

The module in attachment is working. You just need to add the role check.

Regards,

Marcelo

Its not working though marcelo? Im using the app and when i click delete on one of the list items using the button it does not remove it from the list.

Grayson Udstrand wrote:

You can also pass the index of the record into the delete action and use the ListRemove action to instantly remove the element from the list without doing a data refresh every time:

This would be the action signature, and the content would look something like this:

I  can not insert a ListRemove action? its give me a grey error circle and not placing it..


Hi Jamie,

First check whether you are passing proper job sheet identifier to DeleteJobSheet  action. 

You have placed delete button in the jobsheet_create page. So I assume you are using the same page to edit or delete a created jobsheet . So the delete button should only be enabled when you are editing a created jobsheet. It should be disabled when you are creating new jobsheet

Also, UpdateJobsheet action is not necessary if you just want to delete the jobsheet . 

In the end of the action, you should redirect to jobs_list page . That page will run its preparation and you should be able to see refreshed list with the deleted item gone.

 I have attached a .oml file. You wont be able to publish it, but you can see how the actions are made. 

What does the 'UpdateJobSheet' (in DeleteJobSheetWrapper after the delete) do? 

Might be the cause the whole piece of 'code' doesn't work and the transaction (with the delete in it) rolls back.


Thanks for the good news, easy to read, easy to understand.

?????????mega888

Hi Jamie,

Did you check the module I shared? For you is not working? Which is the behaviour that you get? You get any error? How are you testing it? I only tested it on outsystems Now. There it works for you?

Regards,

Marcelo

Marcelo Ferreira wrote:

Hi Jamie,

Did you check the module I shared? For you is not working? Which is the behaviour that you get? You get any error? How are you testing it? I only tested it on outsystems Now. There it works for you?

Regards,

Marcelo

Grayson solved my issue but thanks for the help.