Adding Attachments in a Pop-up Modal and Saving Only When Submit is Clicked( Workspace &standard UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2024 08:32 AM
Adding Attachments in a Pop-up Modal and Saving Only When Submit is Clicked
This article explains how to add attachments in a pop-up modal, with a focus on ensuring that the attachments are saved only when the Submit button is clicked. The attachments are not automatically saved during the form interaction; instead, they are stored only when the user clicks Submit or Save inside the modal. This approach provides users with control over when data is saved, allowing them to finalize the form submission and ensure attachments are included at that point.
Steps:
1. UI Page:
- In the HTML field (lines 170-180), add the form body.
2. Client Script Field:
- In the onSubmit function (line 786), you can handle the fields you added in the HTML field and perform any required logic.
function onsubmit(){ // attachmentParentSysId -> record sys_id // attachmentParentTable -> table name // document.getElementById('field name').value;
// var ga = new GlideAjax('name')
}
3. Call Pop-up by UI Action:
For Workspace:
g_modal.showFrame({ url: "/attachmentForm?target_table=table_name&target_sys_id=" + g_form.getUniqueValue() +"&sysparm_workspace=true", title: getMessage('Title'), size: 's', height: 500, callback: function(ret, data) { g_form.save(); } });
For Standard UI:
function onclick() { var gm = new GlideDialogWindow('attachmentForm'); gm.setTitle('Show title'); gm.setPreference('target_table', "table_name"); gm.setPreference('target_sys_id', g_form.getUniqueValue()); gm.setPreference('sysparm_workspace', 'false'); gm.setWidth(550); gm.render(); }
- 1,991 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2024 04:34 AM
Very helpful, thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2024 01:54 AM
thanks for your effort, it was very helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2024 05:04 AM
Hi @amrfahmy ,
Can same be implemented for list view of the table and not for the form?
Thanks,
Nisha Kumari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2024 10:25 AM
Yes, you will follow the same steps with the new UI action.