Implementing Attachment Picker in ServiceNow Portal
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2024 09:42 AM
Implementing Attachment Picker in ServiceNow Portal
Description: This article explains how to implement an attachment picker in a ServiceNow portal, allowing users to select files and upload them only when the Submit button is clicked. The logic ensures that attachments are handled and uploaded to the appropriate table and record in a controlled manner.
Steps to Implement:
- Set Up the Attachment Picker: Add the following HTML code to your portal widget to include an attachment picker and a Submit button.
<sp-attachment-picker on-file-pick="attachFile($files)" attachment-handler="attachmentHandler"> </sp-attachment-picker> <button ng-click="submitButton()">${Submit}</button>
- Configure the AngularJS Controller: Use the following code in the widget's client script.
(function($scope, nowAttachmentHandler) { // Initialize the attachment handler $scope.attachmentHandler = new nowAttachmentHandler(); $scope.attachmentHandler.setParams($scope.data.table, $scope.data.sys_id, 1024 * 1024 * $scope.data.maxAttachmentSize); var attachFiles = ''; // Bind file picker $scope.attachFile = function(files) { attachFiles = files; }; // Submit button logic $scope.submitButton = function() { // Add custom logic if needed spAttachmentUpload.uploadAttachments($scope.attachmentHandler, attachFiles); }; })(angular.scope, nowAttachmentHandler);
For ServiceNow Instance Standard and Workspace view :
If you have any questions or suggestions, feel free to share your feedback!
- 1,188 Views
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2024 04:32 AM
Great article, thank you.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2025 02:35 AM
Great article thank's