- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 07:18 AM
I want to create a form for non-authenticated users in CSM and implement a feature to attach files there. Since it is impossible to achieve the file attachment feature for non-authenticated users with only CSM, I am considering a method to call an external API and store the files externally.
When calling an external API, I intend to call the API from the ServiceNow instance in order to restrict the source IP. If the user's file attachment window is implemented with client-side scripting, the source IP when calling the API will not be the instance's IP, so I want to avoid this.
Please tell me how to implement it so that non-authenticated users can select files from the file attachment window and call the API from the ServiceNow instance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 08:02 AM
this link has the solution
Allow Guest users to add attachments on Catalog Items/Record Producers
Note: It's not recommended to do this as lot of unauthenticated users can add files and flood the Attachment table
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 07:24 AM
Implementing the file attachment screen using client-side scripting is not mandatory. As long as you can attach files and call external APIs from the ServiceNow instance, please let me know any method that works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 07:53 AM
I am implementing the following code so that an unauthenticated user can attach a file in CSM and call an external API to store the file. However, I am having trouble retrieving the contents of the attached file obtained in the client script on the server script.
Could you provide advice on how to retrieve the contents of the attached file obtained in the client script on the server script?
Client Script
c.uploadAttachments2 = function() {
document.getElementById('fileToUpload').value = '';
$scope.files.forEach(function(file) {
$scope.fd = new FormData();
$scope.fd.append('files', file);
var fdEntries = $scope.fd.entries();
var fdEntry = fdEntries.next();
var entryVal = fdEntry.value;
c.server.get({
action: 'uploadFileServer',
caData: {
fileData: entryVal[1]
}
}).then(function(r) {
});
});
};
Server Script
if (input.action == "uploadFileServer") {
gs.info('0123===' + input.caData.fileData);
}
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://xxxxxx.service-now.com/api/now/attachment/file?table_name=incident&table_sys_id=xxxxx&file_name=a.txt');
request.setHttpMethod('POST');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 08:02 AM
this link has the solution
Allow Guest users to add attachments on Catalog Items/Record Producers
Note: It's not recommended to do this as lot of unauthenticated users can add files and flood the Attachment table
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 12:45 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader