如果条件为true,ServiceNow显示按钮

ServiceNow show button if condition is true

本文关键字:ServiceNow 显示 按钮 true 条件 如果      更新时间:2023-09-26

我正试图在ServiceNow-Geneva中构建一个客户端脚本(函数onChange),它执行以下操作:

->如果用户在空白字段中写入内容,则更改后应出现一个按钮;

这是我现在的代码,它不起作用->在表单上给我一个X:):

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  //Define the variable and the name of the button

  if (g_form.getValue('work_around') != ''){ 
  var items = $$('BUTTON').each(function(item){  
  if(item.innerHTML.indexOf('Publish Known Error')=== -1){  
      item.show();  
     }
  });
}
}

我建议使用onChange(<your field>) UI策略而不是客户端脚本。这可以通过设置字段不是NULL的条件或其他值检查来实现。

然后,UI策略可以使用.append函数将按钮绑定到您选择的元素。