dynamic creation of checkbox
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2016 10:28 AM
Hi,
I want some value to be fetched from a table & display them as check-box in a catalog item.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2016 09:14 PM
Hi Lathesh,
You could do this using a UI macro and script include. You need to call the function in the script include from that ui macro using GlideAjax. This macro could then be referenced from catalog variable of type macro.
Function in script include :
getCheckboxes: function(){
var checkboxes = '' ;
var grTable = new GlideRecord('table_name');
grTable.query();
while(grTable .next()){
checkboxes += ','+grTable.fieldName ;
}
checkboxes = checkboxes.substring(1);
return checkboxes ;
},
UI Macro :
<table id="container" style="width:100%;">
</table>
<script>
var checkArray = [] ;
var gaChecks = new GlideAjax('Script_Include');
gaChecks.addParam('sysparm_name','getCheckboxes');
gaChecks.getXML(processResponse) ;
function processResponse(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
checkArray = answer.split(',');
var htmlString = '' ;
for(var i = 0; i<checkArray.length;i++){
var check = checkArray[i];
if((i+1)%4 == 1){ //this will provide 4 checks in a row
htmlString +='<tr>';
}
htmlString += '<td><input type="checkbox" class="iafCategories" value="'+check+'">'+check+'</input></td>';
}
if((i+1)%4 == 0){ //this will end row after 4 checks
htmlString +='</tr>';
}
document.getElementById("container").innerHTML = htmlString ;
}
</script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2016 11:51 AM
Hi gurpreet,
I have some problem in creating check-box in UI page. Check this link: Custom UI Page
Can I directly create check-box using any servicenow scripts. (Because unable to create check-box using HTML).
or
Can I directly get the check-box from form to UI page?
Any help would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2016 12:59 AM
Hi gurpreet,
I was testing this but doesnt work Ui macro doesnt display checkboxes, can you post a screenshot of how checkboxes are displayed ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2016 01:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2016 02:15 AM
Thanks Gurpreet. Have you tested this in geneva ?