- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2023 06:30 PM
I have a custom widget where I'm asking for input from user table. As soon as agent input user id, tool should cross check, if any active incident is raised with CI=Standard Laptop for this userid or not. If active incident exist then it should not allow to proceed further and make this input field blank/clear.
I'm new in portal script, can anyone help here.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2023 01:38 AM
HTML Template:
<sn-record-picker field="user"
table="'sys_user'"
display-field="'name'"
value-field="'sys_id'"
search-fields="'name'"
page-size="100"></sn-record-picker>
Client Script:
api.controller=function($scope, spUtil) {
/* widget controller */
var c = this;
$scope.user = {displayValue: "",
value: "",
name: 'user'};
$scope.$on("field.change", function(evt, parms) {
if (parms.field.name == 'user') {
c.server.get({"action":"verify", //action is only required if you will be doing additional different call backs
"id":$scope.user.value}).then(function(_response){
if (_response.data.actIncExists) {
$scope.user.displayValue = "";
$scope.user.value = "";
spUtil.addInfoMessage("Incident exists")
}
})
}
});
};
Server Script:
(function() {
var stdLapId = 'b4fd7c8437201000deeabfc8bcbe5dc1'; //move this to a script include used to hold constants.
if (input && input.action == 'verify') {
var grsInc = new GlideRecordSecure('incident');
grsInc.addQuery('caller_id', input.id);
grsInc.addActiveQuery();
grsInc.addQuery('cmdb_ci', stdLapId);
grsInc.query();
data.actIncExists = grsInc.hasNext() || false;
}
})();
More Info:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2023 01:38 AM
HTML Template:
<sn-record-picker field="user"
table="'sys_user'"
display-field="'name'"
value-field="'sys_id'"
search-fields="'name'"
page-size="100"></sn-record-picker>
Client Script:
api.controller=function($scope, spUtil) {
/* widget controller */
var c = this;
$scope.user = {displayValue: "",
value: "",
name: 'user'};
$scope.$on("field.change", function(evt, parms) {
if (parms.field.name == 'user') {
c.server.get({"action":"verify", //action is only required if you will be doing additional different call backs
"id":$scope.user.value}).then(function(_response){
if (_response.data.actIncExists) {
$scope.user.displayValue = "";
$scope.user.value = "";
spUtil.addInfoMessage("Incident exists")
}
})
}
});
};
Server Script:
(function() {
var stdLapId = 'b4fd7c8437201000deeabfc8bcbe5dc1'; //move this to a script include used to hold constants.
if (input && input.action == 'verify') {
var grsInc = new GlideRecordSecure('incident');
grsInc.addQuery('caller_id', input.id);
grsInc.addActiveQuery();
grsInc.addQuery('cmdb_ci', stdLapId);
grsInc.query();
data.actIncExists = grsInc.hasNext() || false;
}
})();
More Info:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2023 07:08 PM
If I want to show user name and his email in alert what change I need to make?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2023 10:38 PM
On the server side, open the incident glide record and store the caller_id's email on data object.
On the client side add the email string directly into popup by referencing the email from the _response.data object.