Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

davilu
Mega Sage

Hey, did you ever figure out how to get this to work correctly?  Our team is trying to do something very similar, where we want a button to show up only after all the mandatory fields have been filled out.  Would love to get your suggestions on how to accomplish this cleanly.  Thanks!