Parent TASK closure(sc_task) check using client script

Abhishake1
Giga Contributor

Hi Developers,

We have a requirement in catalog task suppose i have one task which is getting generated via workflow and user can also generate manual task via new button,as per the requirement we need to check the parent task shouldnot get closed as soon as the child or manual tasks are open and we need to achieve this via onSubimt client script can anyone help me in getting the sample script or any approach so that we can achieve that functionality.

Thanks,

Abhishek

3 REPLIES 3

johnolivermendo
ServiceNow Employee
ServiceNow Employee

Hey Abhishek,



From what I'm reading, you want to have a way to check if a parent task has any child tasks that are still open and prevent parent task closure onSubmit. Let me know if that is correct. You can definitely use a client script with client side glide record calls to check this or you can more simply create a before update business rule that runs on your parent task table (sc_task) and performs the following check:



(I don't know which child catalog task table you're using, but for this example's sake I'll use the very broad 'task' table.)


Screen Shot 2017-04-13 at 2.18.21 PM.JPG


Screen Shot 2017-04-13 at 2.29.00 PM.JPG



or since they're all field checks on the child record refactor it to this:


Screen Shot 2017-04-13 at 2.33.21 PM.JPG


Abhishake1
Giga Contributor

Hi John,



Thanks for the help.Provided sample script worked for me.



Regards,


Abhishek


Hey Abhishek,



That's good to hear! Please mark the answer correct so that this thread can be closed.