Is there any way to make a UI Action Form Button show up based on an onChange Client Script?

aessling
Mega Expert

I want to make a UI action show up when certain fields are filled in without having to hit save. Hence using a onChange Client script. I've tried the below but no luck. Any help would be appreciated.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

    if (isLoading || newValue === '') {

          return;

    }

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

    if(item.innerHTML.indexOf('Create JIRA') > -1){

          item.show();

    }

    });

}

1 ACCEPTED SOLUTION

aessling
Mega Expert

I was wrong, the above works if you do it correctly. But now I'm having another problem. When I change the value of one of the fields back to -None- it isn't taking the button away. Any ideas?



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }


  var issType = g_form.getValue('u_issue_type');


  var jPri = g_form.getValue('u_jira_priority');


  var jProj = g_form.getValue('u_jira_project');


  if (issType != '' && jPri != '' && jProj != ''){


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


  if(item.innerHTML.indexOf('Create JIRA') > -1){


  item.show();


  }


  });


  }


  else {


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


  if(item.innerHTML.indexOf('Create JIRA') > -1){


  item.hide();


  }


  });


  }


}


View solution in original post

5 REPLIES 5

veena_kvkk88
Mega Guru

Check it out. This might help!



Hide UI ACTION form button on field change?


aessling
Mega Expert

I was wrong, the above works if you do it correctly. But now I'm having another problem. When I change the value of one of the fields back to -None- it isn't taking the button away. Any ideas?



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }


  var issType = g_form.getValue('u_issue_type');


  var jPri = g_form.getValue('u_jira_priority');


  var jProj = g_form.getValue('u_jira_project');


  if (issType != '' && jPri != '' && jProj != ''){


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


  if(item.innerHTML.indexOf('Create JIRA') > -1){


  item.show();


  }


  });


  }


  else {


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


  if(item.innerHTML.indexOf('Create JIRA') > -1){


  item.hide();


  }


  });


  }


}


Based on your script, what it does is: UI action shows up only when all three fields are filled. Also, this is an onChange script, so which field are you firing this off? This will be triggered only when that particular field changes.



So, when you change one of your values to None, first thing is: if its not the field the script is based on, then it wont be triggered. And even if its triggered, since the other fields are filled in, the UI action is still displayed.


find_real_file.png

 

I want to hide the assign to me without saving the form when assignment group changes but it give me error