Can a UI Action display a different label after being pressed once?

PaulShea
Kilo Explorer

I have a weird situation.
I have a client script UI Action 'Re-open Incident' visible for closed incidents.
When pressed, the user is prompted to enter a comment and a field message tells the user to 'Please enter a comment when reopening an Incident and then press 'Submit'.

Is it possible to relabel the UI 'Re-open Incident' to 'Submit' after the button is pressed so I don't need to introduce another UI?

7 REPLIES 7

david_legrand
Kilo Sage

As the displayed name of the UI action is the name of the UI action itself, I don't think that's possible

And as your form won't be reloaded, i don't think you could even have this behavior:
* Button re-open
* I wrote my comments
* Button submit

Regards,


poyntzj
Kilo Sage

I have done similar but with two UI Actions


The first is the "Request Reset" and the second is "Reset Approval"


Both UI Actions are visible, have the same order, but different ID's



I have a client script for on Load that has


// Reset approval button to be hidden
try {
var objra2 = document.getElementById('Reset_approval2');
objra2.style.display = 'none';
}
catch(err)
{}
// Request Reset to be visible
try {
var objra = document.getElementById('reset_approval');
objra.style.display = '';
}
catch(err2)
{}



This will hide the button I do not want to see on load while keeping the other visible



When the user presses the "Request Approval" and they have confirmed the answer then the following code is run


var objra2 = document.getElementById('Reset_approval2');


        objra2.style.display = '';



  var objra = document.getElementById('reset_approval');


        objra.style.display = 'none';



this gives the impression to the user that the button has just changed label and lets them do the next step



Cheers


Thank you!


poyntzj
Kilo Sage

Hi Paul.   I had another look at this today and saw that the button only disappeared from the title menu and not in the form.   After a chat with someone in serviceNOW, I have amended my code to be this


(the client script onload)


function onLoad() {


    //Type appropriate comment here, and begin script below



  var refs = document.getElementsByTagName("BUTTON");



  if (g_form.getValue('approval') == 'not requested')


  {




  // hide both "Request Reset" and "Reset Approval buttons"


   


  if (refs) {


  for (i=0; i < refs.length; i++)


  {


  ref = refs[i];


  inner = ref.innerHTML;


  //check for the 'Submit' value on the button


  if (inner == '<span>Request Reset</span>')


  {


  ref.style.display = 'none';


  }


  if (inner == '<span>Reset Approval</span>')


  {


  ref.style.display = 'none';


  }


  }


  }


  }


  else


  {


  // Hide Reset Approval and show Request Reset



  if (refs) {


  for (i=0; i < refs.length; i++)


  {


  ref = refs[i];


  inner = ref.innerHTML;


  //check for the 'Submit' value on the button


  if (inner == '<span>Request Reset</span>')


  {


  ref.style.display = '';


  }


  if (inner == '<span>Reset Approval</span>')


  {


  ref.style.display = 'none';


  }


  }


  }




  }




and the UI Action "Request Reset" now has this small entry


var refs = document.getElementsByTagName("BUTTON");
if (refs) {
for (i=0; i < refs.length; i++)
{
ref = refs[i];
inner = ref.innerHTML;
//check for the 'Submit' value on the button
if (inner == '<span>Request Reset</span>')
{
ref.style.display = 'none';
}
if (inner == '<span>Reset Approval</span>')
{
ref.style.display = '';
}

}




    It all works and both buttons do as I expect in both locations



Cheers


}