Import Set from UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2013 12:38 PM
I have a requirement to allow the help desk administrator to upload a spreadsheet and import it into a specific table using a UI action. Basically, they click on a button called "Batch Add" and an attachment pop up appears, when they click attach and close, the file is uploaded. Has anyone else done something similar with a UI action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2013 11:34 PM
Hi Aron,
As one data source cant have 2 attachments as the source,Only one attachment can be processed at a time.
So,I have added delay the 2nd user request when one user request is in progress.If Service Desk user is not loading more than 500 records of data then it will working fine as it takes only 4 or 5 seconds to process.
Regards,
Vamsi Kommireddi,
Certified System Administrator.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2017 12:43 PM
Hi Blari,
Have you implemented this solution?..
I am trying to do but I got stuck at creation of the Ui action.
Can you please share the code(UI action) if you have implemented it( I know this is a long back post but just a try).
Thanks..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 07:53 AM
This is what we did:
if (!current.hasAttachments()) {
gs.addErrorMessage('No attachments found.');
action.setRedirectURL(current);
//current.setAbortAction(true);
} else {
var batch_add = gs.getProperty('batch.add.data.source.id');
// Delete all attachments from data source
deleteAllAttachments("sys_data_source", batch_add);
// Delete all attachments except the last uploaded one from the flash message record
deleteAllAttachmentsExceptLast("u_flash_message", current.sys_id);
//Check to see if the Package call alternate is available and use that if possible. Else, use the package call.
if (typeof GlideSysAttachment != 'undefined'){
GlideSysAttachment.copy("u_flash_message", current.sys_id, "sys_data_source", batch_add);
}else{
GlideSysAttachment.copy("u_flash_message", current.sys_id, "sys_data_source", batch_add);
}
//Execute a scheduled script job
var rec = new GlideRecord('scheduled_import_set');
rec.get('name', 'Import Flash Messages');
if (typeof SncTriggerSynchronizer != 'undefined'){
SncTriggerSynchronizer.executeNow(rec);
action.setRedirectURL(current);
//action.setReturnURL(current);
gs.sleep(2000);
gs.eventQueue('bulk_load_complete', current, gs.getUserID(), gs.getUserName());
gs.addInfoMessage("All users contained in the spreadsheet have been added to the appropriate flash message.");
}else{
SncTriggerSynchronizer.executeNow(rec);
//action.setRedirectURL(current);
gs.sleep(2000);
gs.eventQueue('bulk_load_complete', current, gs.getUserID(), gs.getUserName());
gs.addInfoMessage("All users contained in the spreadsheet have been added to the appropriate flash message.");
action.setReturnURL(current);
}
}
function deleteAllAttachmentsExceptLast(table_name, sys_id){
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", table_name);
gr.addQuery("table_sys_id", sys_id);
gr.orderBy("sys_created_on");
gr.query();
var N = gr.getRowCount();
var counter = 0;
while (gr.next()){
if( counter == N - 1 )
break;
gr.deleteRecord();
counter++;
}
}
function deleteAllAttachments(table_name, sys_id){
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", table_name);
gr.addQuery("table_sys_id", sys_id);
gr.deleteMultiple();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2018 01:10 AM
Breinhart,
We have the similar requirement to allow the help desk administrator to upload a spreadsheet and import it into a specific table using a UI action.
How attachment pop up appears when user click on a button. Can you please share the code if you have implemented it, Also what would be the best way to implement this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2020 06:41 AM
Hello
We have the similar requirement to allow the help desk administrator to upload a spreadsheet and import it into a specific table using a UI action.
How attachment pop up appears when user click on a button. Can you please share the code if you have implemented it, Also what would be the best way to implement this?