1. Go to UI Action, create a new UI Action, with action name: InfraCloseCompleteTask

2. Check on "Form Button", this will create an Form Button on the form we pick from table, the table we pick is "Task". 

UI Action Infra Close and Complete

Scripts: Do remember to replace <customField> with the file you want it to be.

//Client-side 'onclick' function
function infraCloseTask(){
   if(g_form.getValue('task.u_<customField>') == ''){
	 //  alert(g_form.getValue('task.number'));
      //Remove any existing field message, set comments mandatory, and show a new field message
	 
      g_form.setMandatory('task.u_<customField>', true);
      g_form.showFieldMsg('task.u_<customField>','<customField> is mandatory when close a task','error');
      return false;  //Abort submission
   }
   //Call the UI Action and skip the 'onclick' function
	 g_form.setValue('state',3);
   gsftSubmit(null, g_form.getFormElement(), 'InfraCloseCompleteTask'); //MUST call the 'Action name' set in this UI Action
}

//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if(typeof window == 'undefined')
   infracloseAndCompleteTask();

function infracloseAndCompleteTask(){
   //Set the 'State' to 'Close'.
   current.state = 3;
   current.update();
  // gs.addInfoMessage('Task ' + current.number + ' closed and completed.');
   action.setRedirectURL(current);
}

 

 

About Lei

I am an IT specialist with over 10 year experience - years on Automation, on-Premise or Azure.

I am happy to develop however never want be a full time developer. Only do what I have to do. If it has to be PowerShell,HTML, PHP, CSS, C#, VBS or JS, front end or backend, so be it, doesn't matter!

Spent years with Windows, SCCM, SharePoint, SQL and Exchange servers. For last several years, I have been actively working under On Premise > Azure environment.

THERE IS NO WAY BACK!!!

Current Certificates:
    Microsoft® Certified-
  • -Enterprise Administrator
  • -Database Administrator
  • -SharePoint Administrator
  • -Administering and Deploying SCCM 2012
Red Hat Certified Technician
ITIL V3 Foundation - Practitioner

Working on Azure Certificates now and hopefully they can stop upgrading their questions one day! GIVE ME A BREAK!

Contact Lei

Name *
Email *
Comments *

Traffic since 10/08/2016

Today47
Yesterday83
This week671
This month1967
Total416327

Visitor Info

  • IP: 54.227.51.103
  • Browser: Unknown
  • Browser Version:
  • Operating System: Unknown

Who Is Online

1
Online

2017-12-17

Login