The CreatorCon Call for Content is officially open! Get started here.

UI Action to check a checkbox when click "Close Task" button on banner.

Mohammad10
Tera Contributor

I need to check one "checkbox" below before fulfiller click "close task" from banner to close the task.   

find_real_file.png

 

find_real_file.png

 

When I change task state, OnSubmit script works fine but when task is closed from banner, OnSubmit script do not work.

Please help 

 

Thanks

Mohammad

 

1 ACCEPTED SOLUTION

Hi,

2 approaches

1) make that variable as Mandatory for Catalog Task

OR

2) update the OOB UI action as below

Note: give the catalog item sys_id for whose Task you want to run this for

function closeTask(){

var catItemSysId = g_form.getReference('request_item').cat_item;

if(catItemSysId == 'Your Catalog Item Sys ID'){


    var variableValue = g_form.getValue('checkbox_variableName');
    if(variableValue == ''){
        alert('Please select the checkbox before closing the task');
        return;
    }

}

    g_form.setValue('state', 3);
    //Call the UI Action and skip the 'onclick' function
    gsftSubmit(null, g_form.getFormElement(), 'close_sc_task');
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
    updateTask();

function updateTask(){
    current.state = 3;
    current.update();
}

Regards
Ankur

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

View solution in original post

19 REPLIES 19

yes "Close Task" is on table sc_task only.

 

Hi,

Did you create another Close Task button on sc_task or update the OOB one?

Regards
Ankur

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

yes I created another one.

If I need to update existing one, I need to enable client script will that be ok? 

Hi,

since you created new one on sc_task it is showing 2 buttons.

Ideally you could have updated the existing one

Please update existing UI action and inactivate the newly created

Regards
Ankur

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

Hi Mohammad,

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

If not, please let us know if you need some more assistance.

Regards
Ankur

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