RITMs generated from HR workflow via an order guide, where a common hr_case_ref variable is in use on the RITMs and populated via the HR workflow (passed from order guide to child RITM)
HTML
___________________________
<title>Check RITMs for the HR Case</title>
<div class='container'>
<!-- your widget template -->
<table width="100px" border="0">
<tr><td>
<br/>
<label>Enter HR Case number here:</label>
<input value='HRM0000126' id='hr_case'/>
<br/>
</td></tr>
<tr><td>
<label>Enter order guide name here (optional):</label>
<input id='order_guide' ng-model="inputOG">
<button ng-click="blankOrderGuideField()" class="btn btn-danger action-btn pull-center">Blank</button>
<tr><td>
<br/><br/><br/><br/><br/>
<button ng-click="runtheoperation()" class="btn btn-danger action-btn pull-left">Click to check RITMs</button>
</td></tr>
<tr><td><br/><br/>
<label><b>Results:</b></label>
<br/><br/>
<textarea id='results_q' rows="10" cols="100">{{c.ritmsList}}</textarea>
</td></tr>
</table>
</div>
___________________________
CSS
___________________________
.container {
clear: both;
text-align:left;
align-content: left;
}
.container input {
width: 100px;
clear: both;
}
.container label {
width: 150px;
clear: both;
}
.container textarea {
color:black;
}
.container td {
text-align: left;
}
.container td2 {
width:20%;
}
.container table {
width:100%;
}
___________________________
client script
___________________________
function($scope) {
/* widget controller */
var c = this;
c.ritmsList='click to see results';
$scope.inputOG='Staff Joiner - ICT';
$scope.runtheoperation = function() {
//console.log("message", 'run the op');
if (angular.element($('#hr_case')).val()==''){
alert('missing hr case');
}else{
c.server.get({
action: "get_ritms",
msg : "Checking for RITMs...",
hrCase : angular.element($('#hr_case')).val(),
orderGuide : angular.element($('#order_guide')).val()
}).then(function(r){
var ritmsResult=r.data.ritmsList;
c.ritmsList=ritmsResult.join('\n');
});
}
};
___________________________
server script
___________________________
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.ritmsList=[];
//data.ritmsTotal=0;
if (input && input.action === "get_ritms"){
//gs.addInfoMessage(input.hrCase);
// gs.addInfoMessage(input.orderGuide);
data.ritmsList=(checkRitms(input.hrCase, input.orderGuide));
// gs.addInfoMessage(data.ritmsList.length);
}
function checkRitms(hrCase, orderGuide){
var ritmsArr=[];
var grvars=new GlideRecord('item_option_new');
//var sQuery='name=hr_case_ref';
var sQuery=gs.getProperty('sp.variablename.query');
grvars.addQuery(sQuery);
var ritmsURL='url:\n';
ritmsURL+=gs.getProperty('glide.servlet.uri');
ritmsURL+='nav_to.do?uri=sc_req_item_list.do?sysparm_query=numberIN';
grvars.query();
var sEncQuery='variables.';
var bLocated=false;
var iCounter=0;
while (grvars.next()){
var gr= new GlideRecord('sc_req_item');
gr.addQuery('variables.' + grvars.sys_id + 'LIKE' + hrCase);
if (!gs.nil(orderGuide)){
gr.addQuery('order_guide.name='+orderGuide);
}
gr.query();
if(gr.next()){
bLocated=true;
ritmsArr.push(gr.number + ': ' + gr.short_description + ' [orderGuide: ' + gr.order_guide.name + ']');
ritmsURL+=gr.number;
ritmsURL+=',';
iCounter++;
}
}
if (!bLocated){
ritmsArr.push('No RITMs as yet. Check the HR Case workflow has progressed?')
}else{
ritmsArr.push('Total records: ' + iCounter);
var ritmsURL=ritmsURL.slice(0, -1);//--remove the last ,
ritmsArr.push(ritmsURL);
}
return ritmsArr;
}
})();
HTML
___________________________
<title>Check RITMs for the HR Case</title>
<div class='container'>
<!-- your widget template -->
<table width="100px" border="0">
<tr><td>
<br/>
<label>Enter HR Case number here:</label>
<input value='HRM0000126' id='hr_case'/>
<br/>
</td></tr>
<tr><td>
<label>Enter order guide name here (optional):</label>
<input id='order_guide' ng-model="inputOG">
<button ng-click="blankOrderGuideField()" class="btn btn-danger action-btn pull-center">Blank</button>
<tr><td>
<br/><br/><br/><br/><br/>
<button ng-click="runtheoperation()" class="btn btn-danger action-btn pull-left">Click to check RITMs</button>
</td></tr>
<tr><td><br/><br/>
<label><b>Results:</b></label>
<br/><br/>
<textarea id='results_q' rows="10" cols="100">{{c.ritmsList}}</textarea>
</td></tr>
</table>
</div>
___________________________
CSS
___________________________
.container {
clear: both;
text-align:left;
align-content: left;
}
.container input {
width: 100px;
clear: both;
}
.container label {
width: 150px;
clear: both;
}
.container textarea {
color:black;
}
.container td {
text-align: left;
}
.container td2 {
width:20%;
}
.container table {
width:100%;
}
___________________________
client script
___________________________
function($scope) {
/* widget controller */
var c = this;
c.ritmsList='click to see results';
$scope.inputOG='Staff Joiner - ICT';
$scope.runtheoperation = function() {
//console.log("message", 'run the op');
if (angular.element($('#hr_case')).val()==''){
alert('missing hr case');
}else{
c.server.get({
action: "get_ritms",
msg : "Checking for RITMs...",
hrCase : angular.element($('#hr_case')).val(),
orderGuide : angular.element($('#order_guide')).val()
}).then(function(r){
var ritmsResult=r.data.ritmsList;
c.ritmsList=ritmsResult.join('\n');
});
}
};
___________________________
server script
___________________________
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.ritmsList=[];
//data.ritmsTotal=0;
if (input && input.action === "get_ritms"){
//gs.addInfoMessage(input.hrCase);
// gs.addInfoMessage(input.orderGuide);
data.ritmsList=(checkRitms(input.hrCase, input.orderGuide));
// gs.addInfoMessage(data.ritmsList.length);
}
function checkRitms(hrCase, orderGuide){
var ritmsArr=[];
var grvars=new GlideRecord('item_option_new');
//var sQuery='name=hr_case_ref';
var sQuery=gs.getProperty('sp.variablename.query');
grvars.addQuery(sQuery);
var ritmsURL='url:\n';
ritmsURL+=gs.getProperty('glide.servlet.uri');
ritmsURL+='nav_to.do?uri=sc_req_item_list.do?sysparm_query=numberIN';
grvars.query();
var sEncQuery='variables.';
var bLocated=false;
var iCounter=0;
while (grvars.next()){
var gr= new GlideRecord('sc_req_item');
gr.addQuery('variables.' + grvars.sys_id + 'LIKE' + hrCase);
if (!gs.nil(orderGuide)){
gr.addQuery('order_guide.name='+orderGuide);
}
gr.query();
if(gr.next()){
bLocated=true;
ritmsArr.push(gr.number + ': ' + gr.short_description + ' [orderGuide: ' + gr.order_guide.name + ']');
ritmsURL+=gr.number;
ritmsURL+=',';
iCounter++;
}
}
if (!bLocated){
ritmsArr.push('No RITMs as yet. Check the HR Case workflow has progressed?')
}else{
ritmsArr.push('Total records: ' + iCounter);
var ritmsURL=ritmsURL.slice(0, -1);//--remove the last ,
ritmsArr.push(ritmsURL);
}
return ritmsArr;
}
})();
Comments
Post a Comment