Data validation on action parameter query

Is there a way to have data entered in an action parameter query prompt validated at time of entry rather than within the action script?

I’m writing a task that updates the DNS servers on a target server and I have a regex to confirm the user’s input is a valid IP address, but I’d rather tell the user it is invalid at time of entry instead of at time of action execution.

One way to do this is to use the task’s description field.
You can put html elements in it, use javascript to validate and also call the take action.
Have a look at the fixlets in the BES support site that configure the REST API credentials for the BES Server plug-in for a basic example.

1 Like

Here is that code. I’ll see what I can do. thanks

<Description><![CDATA[
<TABLE><TBODY><TR><TD> <?hxlat Some Server Plugin applications running on the IEM Server require Master Operator credentials to access the REST API of the Server. Provide Master Operator credentials in the following form and then click Take Action to store them on Server.?> <form style="width:500px" onsubmit="_takeAction()"> <fieldset> <legend><strong><?hxlat REST API Configuration?></strong></legend> <div style="padding: 10px; padding-bottom: 20px"> <table> <tr> <td width="200" align="right" style="padding-right:5px"> <label for="RESTUsername"><?hxlat Master Operator User name:?></label> </td> <td align="left"> <input type="text" id="RESTUsername" name="RESTUsername" style="width:250px" /> </td> </tr> <tr> <td align="right"> <label for="RESTPassword" style="padding-right:5px"><?hxlat Master Operator Password:?></label> </td> <td align="left"> <input type="password" id="RESTPassword" name="RESTPassword" style="width:250px" /> </td> </tr> <tr> <td align="right"> <label for="RESTPassword2" style="padding-right:5px"><?hxlat Confirm Password:?></label> </td> <td align="left"> <input type="password" id="RESTPassword2" name="RESTPassword2" style="width:250px" /> </td> </tr> <tr> <td align="right"> <label for="RESTURL" style="padding-right:5px"><?hxlat REST API URL:?></label> </td> <td align="left"> <input type="text" id="RESTURL" name="RESTURL" style="width:250px" value="<?relevance concatenation "https://" of (substrings separated by "http://" of url of current bes server) ?>/api"/> </td> </tr> </table> </div> </fieldset> </form> <script> function _takeAction(){ var RESTUsername = document.getElementById("RESTUsername").value; var RESTPassword = document.getElementById("RESTPassword").value; var RESTPassword2 = document.getElementById("RESTPassword2").value; var RESTURL = document.getElementById("RESTURL").value; if(!RESTUsername){ alert("<?jxlat Fill in the Master Operator User name before taking action.?>"); return; } if(!RESTPassword){ alert("<?jxlat Fill in the Master Operator Password before taking action.?>"); return; } if(RESTPassword != RESTPassword2){ alert("<?jxlat Error: Passwords do not match.?>"); return; } if(!RESTURL){ alert("<?jxlat Fill in the REST API URL before taking action.?>"); return; } TakeSecureFixletAction(Relevance('id of current fixlet'), Relevance('id of current bes site'), "Action1", {}, { RESTUsername: RESTUsername, RESTPassword: RESTPassword, RESTURL: RESTURL }); } document.body.ontakeaction = function() { _takeAction(); return false; } </script></TD></TR></TBODY></TABLE>
]]></Description>

Also, when viewing the code by clicking on the Edit Script Element button when editing the task, here is that code:

 function _takeAction(){ var RESTUsername = document.getElementById("RESTUsername").value; var RESTPassword = document.getElementById("RESTPassword").value; var RESTPassword2 = document.getElementById("RESTPassword2").value; var RESTURL = document.getElementById("RESTURL").value; if(!RESTUsername){ alert("<?jxlat Fill in the Master Operator User name before taking action.?>"); return; } if(!RESTPassword){ alert("<?jxlat Fill in the Master Operator Password before taking action.?>"); return; } if(RESTPassword != RESTPassword2){ alert("<?jxlat Error: Passwords do not match.?>"); return; } if(!RESTURL){ alert("<?jxlat Fill in the REST API URL before taking action.?>"); return; } TakeSecureFixletAction(Relevance('id of current fixlet'), Relevance('id of current bes site'), "Action1", {}, { RESTUsername: RESTUsername, RESTPassword: RESTPassword, RESTURL: RESTURL }); } document.body.ontakeaction = function() { _takeAction(); return false; } 

Both seem pretty difficult to re-engineer for beginners.

The description is a html page with the function being javascript.
You can make that as simple as you like and you don’t need the jxlat stuff that’s part of our internal tags it works without them.

See this: Paramerterized Fixlets - Interactive scripting in BigFix Console Descriptions?

And this: https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli%20Endpoint%20Manager/page/Creating%20parameterized%20fixlets