
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2019 11:11 AM
Hello,
I am currently trying to build out a widget that when the Change Number is clicked on, in my widget, a modal window opens with the ticket information like so:
Right now it's only passing in the first Change requests sys_id and I know why, but I'm not sure how or what method to use to fix it. So basically no matter what number I select, the same change record info appears (CHG0000096) no matter which number I select.
Here is my code below:
HTML:
<div>
<div class="title">
CAB Workbench
</div>
<table class="table table-hover change">
<th>Number</th>
<th>Short Description</th>
<th>Type</th>
<th>Start Date</th>
<th>End Date</th>
<th>Configuration Item</th>
<th>Approval</th>
<tr ng-repeat="change in data.list | orderBy: '-number'">
<td value="{{change.sysID}}" id='copytext' ng-click="c.openChange(); reply_click(this.value)" class="fieldLink">{{change.number}}</td>
<td>{{change.shortdesc}}</td>
<td>{{change.intext}}</td>
<td>{{change.type}}</td>
<td>{{change.startdate}}</td>
<td>{{change.enddate}}</td>
<td>{{change.configItem}}</td>
<td>{{change.approval}}</td>
<td><button type="button" class="button" id="approve">Approve</button></td>
<td><button type="button" class="button" id="reject">Reject</button></td>
<td>
<div>
</div>
</td>
</tr>
</table>
</div>
<script>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Change Window</h4>
</div>
<div class="panel-body wrapper-xl">
<sp-model id="widget-form" form-model='data.formOptions'></sp-model>
</div>
<div class="panel-footer text-right">
<button class="btn btn-primary" ng-click="c.closeChange()">${Close}</button>
</div>
</div>
</script>
<script>
</script>
Client Script
function($uibModal, $scope) {
var c = this;
this.openChange = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'changeTemplate',
scope: $scope
});
}
c.closeChange = function() {
c.modalInstance.close();
}
}
Server Script
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var list = [];
var changeGr = new GlideRecord('change_request');
changeGr.addQuery('approval', 'requested')
//changeGr.addEncodedQuery('');
changeGr.query();
/* var approvalGR = new GlideRecord('sysapproval')
approvalGR.addEncodedQuery('group.assignment_group=b85d44954a3623120004689b2d5dd60a^state=requested');
approvalGR.query();*/
while (changeGr.next()) {
// var innerText = document.getElementById("copytext").innerText;
//var instanceURL = gs.getProperty('glide.servlet.uri');
//var numberLink = instanceURL + changeGr.getLink();
obj = {};
obj.number = changeGr.getDisplayValue('number');
obj.shortdesc = changeGr.getDisplayValue('short_description');
//obj.sysID = changeGr.getUniqueValue();
obj.type = changeGr.getDisplayValue('type');
obj.startdate = changeGr.getDisplayValue('start_date');
obj.enddate = changeGr.getDisplayValue('end_date');
obj.configItem = changeGr.getDisplayValue('cmdb_ci');
obj.approval = changeGr.getDisplayValue('approval');
list.push(obj);
data.list = list;
data.table='change_request';
data.sys_id= changeGr.sys_id;
//gs.addErrorMessage(sys);
data.query='';
data.view='default';
data.formOptions = $sp.getForm(data.table, data.sys_id, data.query, data.view);
gs.addInfoMessage(data.formOptions);
}
}
)();
Edit:
Part of the HTML isn't showing so here is a screenshot:
Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2019 07:26 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2019 11:37 AM
For your openChange function add the change object to the parms and use it to pass the correct sys_id to the model form so it opens the existing record.
So
<td value="" id='copytext' ng-click="c.openChange(change); reply_click(this.value)" class="fieldLink"></td>
I usually use this to open a modal window with a form in it.
$scope.openModal = function(ev, table, sysid, query, view){
_preventDefault(ev);
if(!sysid)
sysid = -1;
spUtil.get("widget-modal", {embeddedWidgetId: "widget-form",
embeddedWidgetOptions: {table: table,
sys_id: sysid,
view: view,
query: query,
disableUIActions: "true",
hideRelatedLists: true
}
}).then(function(widget){
var modalCtrl;
var unregister = $scope.$on('sp.form.record.updated', function(){
skipNextRecordWatchUpdate = true;
$scope.loadingIndicator = true;
spUtil.update($scope).then(function(){
$scope.loadingIndicator = false;
});
modalCtrl.close();
});
widget.options.afterClose = function(){
unregister();
$scope.data.modalInstance = null;
modalCtrl = null;
};
widget.options.afterOpen = function(ctrl){
modalCtrl = ctrl;
};
$scope.data.modalInstance = widget;
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2020 09:36 AM
Hi Drew,
can you please provide the client code for the above.
If possible, please provide the full code.
Thanks
Nagaraju

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2019 07:26 AM
I was able to reach out to a colleague and resolved the issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2020 06:57 AM
Hi Shelby, I know this post is old but I am interested in knowing how you go it working. I am trying to do the same thing for approvals and would like to know any tips you may have.
Thank you!
Yeny