diff --git a/Client-Side Components/Catalog Client Script/Multi-User Collaboration/Readme.md b/Client-Side Components/Catalog Client Script/Multi-User Collaboration/Readme.md new file mode 100644 index 0000000000..e524d91907 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Multi-User Collaboration/Readme.md @@ -0,0 +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. diff --git a/Client-Side Components/Catalog Client Script/Multi-User Collaboration/Script include.JS b/Client-Side Components/Catalog Client Script/Multi-User Collaboration/Script include.JS new file mode 100644 index 0000000000..637bce5fdf --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Multi-User Collaboration/Script include.JS @@ -0,0 +1,18 @@ +var CollaboratorHandler = Class.create(); +CollaboratorHandler.prototype = Object.extendsObject(AbstractAjaxProcessor, { + addCollaborators: function() { + var requestId = this.getParameter('sysparm_request_id'); + var users = this.getParameter('sysparm_users').split(','); + + users.forEach(function(userId) { + var gr = new GlideRecord('x_your_scope_collaborators'); + gr.initialize(); + gr.request = requestId; + gr.collaborator = userId; + gr.status = 'Pending'; + gr.insert(); + }); + + return 'Collaborators added successfully'; + } +}); diff --git a/Client-Side Components/Catalog Client Script/Multi-User Collaboration/client script.JS b/Client-Side Components/Catalog Client Script/Multi-User Collaboration/client script.JS new file mode 100644 index 0000000000..6365d4e9dc --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Multi-User Collaboration/client script.JS @@ -0,0 +1,13 @@ +function onSubmit() { + var collaborators = g_form.getValue('collaborators'); // Multi-user reference field + if (collaborators) { + var ga = new GlideAjax('CollaboratorHandler'); + ga.addParam('sysparm_name', 'addCollaborators'); + ga.addParam('sysparm_request_id', g_form.getUniqueValue()); + ga.addParam('sysparm_users', collaborators); + ga.getXMLAnswer(function(response) { + alert('Collaborators added: ' + response); + }); + } + return true; +} diff --git a/Client-Side Components/Catalog Client Script/Multi-User Collaboration/widget client controller.JS b/Client-Side Components/Catalog Client Script/Multi-User Collaboration/widget client controller.JS new file mode 100644 index 0000000000..0273b282bd --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Multi-User Collaboration/widget client controller.JS @@ -0,0 +1,19 @@ +function($scope, $http) { + $scope.approve = function(sysId) { + $http.post('/api/x_your_scope/collab_action', { + action: 'approve', + sys_id: sysId + }).then(function(response) { + $scope.server.update(); + }); + }; + + $scope.reject = function(sysId) { + $http.post('/api/x_your_scope/collab_action', { + action: 'reject', + sys_id: sysId + }).then(function(response) { + $scope.server.update(); + }); + }; +} diff --git a/Client-Side Components/Catalog Client Script/Multi-User Collaboration/widget server script.JS b/Client-Side Components/Catalog Client Script/Multi-User Collaboration/widget server script.JS new file mode 100644 index 0000000000..7ca090d60e --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Multi-User Collaboration/widget server script.JS @@ -0,0 +1,15 @@ +(function() { + var collabs = []; + var gr = new GlideRecord('x_your_scope_collaborators'); + gr.addQuery('request', $sp.getParameter('request_id')); + gr.query(); + while (gr.next()) { + collabs.push({ + sys_id: gr.getUniqueValue(), + name: gr.collaborator.name.toString(), + status: gr.status.toString(), + comments: gr.comments.toString() + }); + } + data.collaborators = collabs; +})();