Complete button should be visible on request only if all the child table is close

Nisha Mishra23
Tera Contributor

I want complete button visible on request only if all the child task is complete or close where are under that parent request

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Nisha Mishra23 

A request gets automatically closed when the SC task is closed, so I’m not sure what your exact requirement is. Please provide some more details so we can understand and guide you better.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Actually it is a custom table 

JackieZhang
Tera Contributor

create checkAttachments function in script include and call this function in condition in UI action complete.

Ankur Bawiskar
Tera Patron
Tera Patron

@Nisha Mishra23 

is this a OOTB UI action or custom one?

You can use UI action condition field and call script include and that function will check and return true/false

something like this

var RequestUtils = Class.create();
RequestUtils.prototype = {

  initialize: function() {},

  areAllChildTasksCompleteOrClosed: function(requestSysId) {
    var taskGR = new GLideRecord('sc_task');
    taskGR.addQuery('request', requestSysId);
    taskGR.addQuery('stage', '!=', 'Complete');
    taskGR.addQuery('stage', '!=', 'Closed');
    taskGR.query();
    return !taskGR.hasNext(); // true means all child tasks are Complete or Closed
  },

  type: 'RequestUtils'
};

UI Action condition:

new RequestUtils().areAllChildTasksCompleteOrClosed(current.sys_id)

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader