Adding a message when attachment changes on record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2023 10:48 AM
Hey Everyone,
I'm not sure if this is possible or not. But I want to create a onChange client script for a catalog item. When the attachment changes from empty to not empty.
I'm using the standard OOB attachment for the catalog item. I don't know DOM very well.
Any suggestions?
I found this, which works for onSubmit, but how can I get it to work for onChange. I want to create a onChange client script for a catalog item. When the attachment changes from empty to not empty.
function onSubmit() { if (this.document.getElementsByClassName('get-attachment').length == 0) { var getName = g_user.getFullName(); g_form.addErrorMessage('The User ' + getName + ' attachment for this request is mandatory.'); return false; } }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2023 11:33 AM
Have you investigated the use of the attachment variable instead of using the paperclip?
That way, you can use a g_form.getValue() at any point, and evaluate what is there. If there is no attachment, then the value will be null, but if there is, then the value will be the sys_id of the document record on the attachment table.
I tested an onChange with this variable, and it did register as a change when I attached something. However, removing something did not seem to trigger the onChange (but in your case, the onSubmit would catch anyone who added an attachment then removed it).
Also, you can make the attachment mandatory just like any other variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2023 12:51 PM
I was overthinking it. I just added a rich text label variable instead. It displays right next to the attachment icon on the portal.
Thank you for your help!!!