how to delete items based on scheduled workflow


Badge +9

Hello,

I have two lists List A and List B

Users put in an item to delete request in List A and I go in and deleted the item that needs to get deleted in List B and also remove the request  from List A.

I created a workflow that will delete the item in List B based on the request made in List A however I want to schedule the workflow to run at midnight to delete all items automatically in both List A and B daily.

I am assuming I should be using start workflow action? If so how do I specify daily at midnight?

 

Thanks

Rency


17 replies

Badge +9

scheduleworkflow.png
This is how I have it configured however I keep getting an error.

Userlevel 5
Badge +12

Hi Rency,

Why not create a Site workflow and use the scheduler to accomplish this.  In 2013 : click the Gear > Nintex Workflow 2013 > Schedule site workflows

Inside of your site workflow, use two delete multiple item actions pointing to their respective lists.

Thanks

Badge +9

Hi

Thank you for the reply. I started building out my site workflow however when I reference List A by using the delete multiple items function I click on insert reference option and unable to choose the ItemID. I don't see an ItemProperties option since it is being built on the entire site.

The filter should be ItemID is equal to ItemID. I was able to set that up when the workflow was list level.

reference.JPG

Userlevel 5
Badge +12

Hi Rency,

I thought you wanted a workflow that would run on a schedule to clear out List A and List B entirely - separate from the one that was launched on List A to target specific List B items.

Is this true?

OR  Do you want a workflow that runs on the schedule that looks at items in List A and then based on that deletes the items in List B (as well as the associated item in List A)?

Thanks

Userlevel 3
Badge +9

When doing a site level workflow, you'd need to add an extra step of querying the list first to get the item ID, and storing that in a variable.  Then you can add that variable in your filter. 

Userlevel 5
Badge +12

If it is the "OR" option then:

Use Query List action to get all the ID's that link List A to List B and store them in a collection.   You could then loop through this collection with a  foreach, and delete each item from List B where the current ID is matched.   Once you are done clearing out List B, you could then go ahead an clear out List A by deleting all items using the delete multiple items action without a filter.

This way you'd still have the items in List B that did not have a request in List A when this process fired.

Badge +9

Hi,

Thank you for the reply.

I am sorry I should've written it in more detail. List A has a column called ItemId. List A is where users request items to get deleted in ListB.

This same column ItemId exists in List B.

In list A I have a workflow created and a delete Item action that is set to delete based on the ItemID column. This is saved in a collection variable and I am using the ForEach loop, then I have this variable referencing List B ItemID column and deleting the item in List B. That piece work beautifully.

The issue is, I want the workflow to start at midnight everyday.

So if the user creates a request in List A, then the workflow only deletes the item at 12am.

I hope that makes sense.

Badge +9

pause until.JPG

Will this work? Does the date automatically change per day? Or do I have to go into the workflow and change it daily?

Userlevel 5
Badge +12

No problem, - Sounds like you are doing pretty close to what I described above.  I would move this out to a site workflow and schedule it there.  Use the Query List action to get all IDs needed in List A.  Loop through collection to delete in List B.  When done, delete all from List A.

Pause Until will not be dynamic - you'd have to change it each time, or use a variable instead of a selected date.  I'd recommend the approach above.

Badge +9

Got it thank you!!

Badge +9

I had one last question for the schedule start time do I have to specify the date every day? Or will this change based on the new item that the user puts in ListA. For example if the user creates an item in ListA will the date change to tomorrow's date?schedulestarttime.JPG

Badge +9

dateforsitewf.JPG

I think I set it up correctly. I am assuming that this will repeat everyday at 12am without me having to change the date.

Sorry for all the questions I am still learning happy.png

Userlevel 5
Badge +12

From what I see it looks like you set it to run next at 10/28/2014 at 12:00 AM.   As long as you have "indefinite" selected, it'll continue to repeat until you tell it otherwise. happy.png

Badge +9

So I can take out the date and just leave the time will that still work?

Thank you so much!!

Userlevel 5
Badge +12

The start date will be the date when the workflow first runs - and since you have it set to indefinite it will run forever after indefinitely.   In other words, it won't care if the item in list A was created 1 minute or 10 hours before it was scheduled to run, as it'll treat all items equally with the way you have it setup.   You could add additional logic inside the workflow (to the Query List action) to change the behavior if needed.

Hope that helps!

Badge +9

Hi Mike!!

Thank you so much for your help! The wf is working beautifully and deleting items at midnight!!!! You are the best.

Rency

Badge +9

Thank you Brendan

Reply