Skip to content

Commit b139057

Browse files
authored
Catalog Item with Multi-User Collaboration (#2617)
* Create Readme.md * Create client script.JS * Create Script include.JS * Create widget client controller.JS * Create widget server script.JS
1 parent 26c4d83 commit b139057

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This project introduces a collaboration feature for Service Catalog requests, allowing multiple users to contribute to a single request. It’s ideal for scenarios like team onboarding, shared resource provisioning, or cross-functional workflows.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var CollaboratorHandler = Class.create();
2+
CollaboratorHandler.prototype = Object.extendsObject(AbstractAjaxProcessor, {
3+
addCollaborators: function() {
4+
var requestId = this.getParameter('sysparm_request_id');
5+
var users = this.getParameter('sysparm_users').split(',');
6+
7+
users.forEach(function(userId) {
8+
var gr = new GlideRecord('x_your_scope_collaborators');
9+
gr.initialize();
10+
gr.request = requestId;
11+
gr.collaborator = userId;
12+
gr.status = 'Pending';
13+
gr.insert();
14+
});
15+
16+
return 'Collaborators added successfully';
17+
}
18+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function onSubmit() {
2+
var collaborators = g_form.getValue('collaborators'); // Multi-user reference field
3+
if (collaborators) {
4+
var ga = new GlideAjax('CollaboratorHandler');
5+
ga.addParam('sysparm_name', 'addCollaborators');
6+
ga.addParam('sysparm_request_id', g_form.getUniqueValue());
7+
ga.addParam('sysparm_users', collaborators);
8+
ga.getXMLAnswer(function(response) {
9+
alert('Collaborators added: ' + response);
10+
});
11+
}
12+
return true;
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function($scope, $http) {
2+
$scope.approve = function(sysId) {
3+
$http.post('/api/x_your_scope/collab_action', {
4+
action: 'approve',
5+
sys_id: sysId
6+
}).then(function(response) {
7+
$scope.server.update();
8+
});
9+
};
10+
11+
$scope.reject = function(sysId) {
12+
$http.post('/api/x_your_scope/collab_action', {
13+
action: 'reject',
14+
sys_id: sysId
15+
}).then(function(response) {
16+
$scope.server.update();
17+
});
18+
};
19+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(function() {
2+
var collabs = [];
3+
var gr = new GlideRecord('x_your_scope_collaborators');
4+
gr.addQuery('request', $sp.getParameter('request_id'));
5+
gr.query();
6+
while (gr.next()) {
7+
collabs.push({
8+
sys_id: gr.getUniqueValue(),
9+
name: gr.collaborator.name.toString(),
10+
status: gr.status.toString(),
11+
comments: gr.comments.toString()
12+
});
13+
}
14+
data.collaborators = collabs;
15+
})();

0 commit comments

Comments
 (0)