How to write the script for attached the file in workspace in popup window in sow workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I want to write the workspace client script ( pop up window ) for upload new version behavior it is just like the attachment functionalities as shown in screen shot in sow workspace . Could you please help me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
hey @reenak446674965
In Workspace, we cannot use classic client scripts or GlideDialogWindow. To achieve Upload New Version behavior similar to the attachment popup, we need to use a Workspace UI Action with a client script and open a Now Modal.
Steps
Create a Workspace UI Action on the required table and set it as Client = true.
UI Action Client Script
function onClick() {
var modal = new nowModal({
title: 'Import a Word File',
size: 'md'
});
modal.render(`
<div style="padding:16px">
<input type="file" id="ws_file" accept=".doc,.docx" />
<br><br>
<button class="btn btn-primary" onclick="uploadNewVersion()">Import</button>
</div>
`);
window.uploadNewVersion = function () {
var fileInput = document.getElementById('ws_file');
if (!fileInput || !fileInput.files.length) {
alert('Please select a file');
return;
}
var file = fileInput.files[0];
var attachmentHandler = new nowAttachmentHandler({
tableName: g_form.getTableName(),
tableSysId: g_form.getUniqueValue()
});
attachmentHandler.uploadAttachment(file).then(function () {
modal.close();
g_form.refresh();
});
};
}
*************************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @vaishali231
I tried in PDI , It is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@reenak446674965
please share screenshot , add log in code show me error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
it would be nice if you could share screenshots for your solution
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I added the alert in the code , only first alert is working .
