Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
How to set a default image on an image field (not knowledge) - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • How to set a default image on an image field (not knowledge)
KB0720062

How to set a default image on an image field (not knowledge)


3721 Views Last updated : Apr 7, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

Description


This article explains how to set a default value for Image fields on a new form.

There isn't any OOTB way of setting a default value for the Image type field on a form. The default value in the field dictionary's doesn't set the default image for the record. However, a Before insert  Business Rule can be written to populate the field. 

The images are stored in the sys_attachment table. In the sys_attachment table, the "File name" is the name of the field, and "Table name" is ZZ_YY plus the name of the table (e.g., ZZ_YYincident). "Table sys ID" is the sys_id of the original record.

You need to create a before query Business Rule using the following API method:

GlideSysAttachment.copy(String sourceTable, String sourceID, String targetTable, String targetID)

Copies attachments from the source record to the target record.

Parameter(s):
NameTypeDescription
sourceTableStringName of the table with the attachments to be copied.
sourceIDStringThe source table's sysID.
targetTableStringName of the table to have the attachments added.
targetIDStringThe target table's sysID.

Example:

If you want to populate the image field on a new Incident form, use the following format.

GlideSysAttachment.copy("ZZ_YYincident", "<Table sys ID>", "ZZ_YYincident", current.sys_id);

Procedure


  1. If there is already an image added on an existing record (e.g., Incident), ignore step 2
  2. Add an image to the image field on the form
  3. Go to sys_attachment.LIST
  4. Find the recent record for the field (record of the image that you want to use as a default)
  5. Copy the sys ID from "Table sys ID" column
  6. Create a Before Insert Business Rule on the Table as follows:

    When: before - Insert
    Active : <checked>
    Advanced: <checked>
    **script:
    GlideSysAttachment.copy("ZZ_YYincident", "<Table sys ID>", "ZZ_YYincident", current.sys_id);

  7. Result: Image field will be auto-populated when a new record is created in the table.

    Note: The steps provided above are for Incident table. You can use the steps for other tables as well.

Applicable Versions


All releases

Additional Information


API Documentation

Product Documentation

Community article


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.