Hide buttons on mobile

Geeky
Kilo Guru

Hi All,

I have created two buttons (UI Actions - Mobile) on a custom table 'Start' and 'Next'. I have a requirement to hide the default 'Save' button and display only one button at a time, first 'Start' during the creation of a new record and 'Next' during the modification of the created record'

I tried below code but no luck

var items = $$('BUTTON').each(function(item){

    if(item.id != 'Start' && item.id != ''){

          item.hide();  

  1. var items = document.getElementsByTagName('button');    
  2. for(i=0;i<items.length;i++)    
  3. {    
  4.   if(items[i].innerHTML.indexOf('Cancel') > -1)    
  5.     {   // Cancel is the name of the UI action(not element)  
  6.     items[i].style.backgroundColor = "#f47121";    
  7.     }    
  8. }  

I do not want to completely hide the button all the time, so I cannot use ACL.

Is there any hide to hide the button on mobile interface?

Regards,

Srini

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You would have to hide the ui action using the condition field on the ui action. You can check current.isNewRecord() and gs.isMobile() in both of your buttons.


View solution in original post

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You would have to hide the ui action using the condition field on the ui action. You can check current.isNewRecord() and gs.isMobile() in both of your buttons.


ok, I will try that option.



What about the default 'Save' button ? How can I remove it?



Screenshot_2016-11-11-15-09-49.png


Brad Tilton
ServiceNow Employee
ServiceNow Employee

You should be able to override it by using the same action name for your custom ui action.


Thanks Brad, that worked