Delete Demand Tasks

Shasia Anees
Tera Contributor

My story requirement is :

 

Implemented successfully if the open demand tasks for the demand are deleted when the demand is resetted to draft, deferred or closed.

 

All related demand tasks should be deleted when the demand state changes to draft, deferred or completed.

 

How can i do this with UI Actions?

4 REPLIES 4

AnveshKumar M
Tera Sage
Tera Sage

Hi @Shasia Anees ,

You want to delete them automatically upon state changed to draft, deferred or completed OR you want to delete them on clicking an UI Action button or link?

 

 

Thanks,
Anvesh

Hi @AnveshKumar M i want to delete them automatically.

 

Thanks for your reply.

Shasia

Hi @anveshKumar, Can you help me with this task? 

Hi,

I would not like to delete tasks, but make then inactive or in cancelled state. But if you want to delete then here you go:

 

You can write a business rule that runs as below

AnuragTripathi_0-1697196154428.png

 

 

 

AnuragTripathi_1-1697196300864.png

 

 

    var delTsk = new GlideRecord('dmn_demand_task');
    delTsk.addQuery('parent', current.sys_id); 
    delTsk.query();
    while (delTsk.next()) {
        delTsk.deleteMultiple();
    }

 

 

 

PS. Make sure you test this well in dev before moving it to higher instances. Also it might be good to at least add a work note on demand that X number of tasks were deleted because state was changed.

-Anurag