Attachments from Draft Record Producers

Published Categorized as ServiceNow Tagged , , ,

The Washington release introduced a wealth of new features to ServiceNow, including the highly anticipated ‘Save as Draft’ functionality for portal forms. This feature allows users to save incomplete forms as drafts and return later to finish and submit them.

However, the feature was accompanied by a bug. In this article, we will explore the nature of this bug, outline the steps to reproduce it, provide both a temporary workaround and a permanent solution.

Bug

Attachments don’t get copied to target records if the draft function is used on record producers.

Steps to reproduce

  • Navigate to Employee Center (ESC) Portal
  • Open any record producer form and fill it out
  • Add an attachment to the form
  • Click on ‘Save as Draft’
  • Navigate to saved drafts by clicking on ‘View Drafts’ or ‘My Requests’
  • Open the draft and click on ‘Submit’
  • Navigate to the target record in the backend
  • Verify that the attachment did not get added to the record

Temporary workaround

Upon further investigation, it was noted that the attachment exists in the Attachment [sys_attachment] table while the record is in draft status but gets deleted once the draft is submitted. Interestingly, when in draft status, the table_sys_id column for the attachment in the Attachment table contained the sys_id of the record that was yet to be created by the record producer.

So to fix the issue, we just had to prevent the auto-deletion of the added attachment if the delete operation is happening immediately after the target record is inserted.

Business rule configuration

  1. Navigate to Business Rules table and proceed to create a new rule.
  2. Set the values as follows –
    • Name – anything
    • Table – Attachment [sys_attachment]
    • Advanced – true
    • When – before
    • Delete – true
  1. Under the ‘Advanced’ tab, the script should look like the below.
  1. Try to reproduce the issue and notice that the added attachments do not vanish anymore.

Permanent solution

ServiceNow support has commented that this bug will be fixed as part of the Xanadu release, and that there are multiple Problem records open for it. One of them being PRB1763735.

Next steps

If Washington is the version you are using for a few more months, better to have this workaround in place than vanishing attachments. Implement it and share among your peers.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses User Verification plugin to reduce spam. See how your comment data is processed.