Introduction

The purpose of this task is to remove all tokens from the token repository of a specific product (optionally, token deletion can be further restricted to tokens that have been assigned to users).

The task can be found by navigating to "Administration | Tasks", then scrolling down to the task "Delete tokens by product";

Task Parameters

The "Delete tokens by product" task uses the following parameters;








Specifies the Product Code of the tokens to be deleted.





Specifies if only tokens that have been assigned to users are to be deleted when the task is run.




The task parameters are used by the task script to determine which tokens are to be deleted and are edited by left clicking on the context menu of the task and selecting "Parameters"

A new window titled "Task Parameters" will now open that lists the parameters making them available for editing.

Editing and Scheduling the TaskI

Viewing and Editing the task

The task can be edited by left clicking on the context menu of the task and selecting "Edit";

A new window will now open titled "Task - Edit";







Enter the name to be assigned to the task within the management console.





Enter a description of what the task will do.





The version number of the task.





This field is used to specify when the task is scheduled to execute.





This field will determine if the task schedule is enabled (if enabled the task will execute at the scheduled time).





Specifies how many times the task should be repeated after the task is executed.






import com.deepnet.das.token.*
import com.deepnet.das.exception.ProductNotFoundException
import com.deepnet.das.licence.LicenceManager

def prod = Product.findById(product as long)
if(!prod)
throw new ProductNotFoundException()

def tokens = Token.findAllByProductAndIsDeleted(prod, false)
def total = tokens.size()
def deleted = 0
tokens.each{ token->
if(removeAssignedTokens)
token.forceDelete()
else if(token.tokenAssignments)
    return; // don't delete token if it is assigned to user
else
token.softDelete()
++deleted
onProgress(deleted, " token deleted:  " + deleted + " / " + total)
}

def msg =  deleted + " tokens deleted, (total " + total + ")"
LicenceManager.triggerStatistics()
setEndMessage(msg)





Scheduling the Task

Select the "Enable Schedule" checkbox to ensure the task schedule is activated, then use the pencil icon ("")  to specify the time and frequency settings for automated task execution.

A new window headed "Execute Task" will now open allowing you to edit the task parameters prior to running the task;


To execute the task click  the  button.

Manual Task Execution

The task can be run manually from the management console by left click on the context menu of the task, then selecting "Run";

A new window will open titled "Execute Task" will then open (the window will be populated with the default task property values);






Provide a brief description that will be used to describe the purpose of the task in the audit log.





If specified, this property will restrict token deletion to tokens that have the specified Product Code.




If selected on tokens that are inactive and meet the other criteria will be deleted.




To execute the task click  the  button.