Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Catalog Item Creating Either Request (RITM) or Incident - Attachment Issue

RushikeshB24337
Tera Contributor

Hi Everyone,

I have a issue where users can submit either a Request or an Incident from a single Service Catalog form.

Current Design

  1. User selects Type:

    • Request
    • Incident
  2. If Request is selected:

    • Standard Service Catalog submission occurs.
    • REQ, RITM, and Catalog Task records are created through Flow Designer.
  3. If Incident is selected:

    • No REQ/RITM should be created.
    • An Incident record is created directly using an onSubmit Catalog Client Script, GlideAjax, and Script Include.

Issue

The catalog item uses the standard Attachments control available on Service Catalog forms.

When the user selects Request, the attachments are copied correctly because the platform creates the REQ/RITM records.

However, when the user selects Incident, the Incident record is created successfully through GlideAjax, but the attachments uploaded on the catalog form are not copied to the Incident.

Question

Has anyone implemented a similar solution where a single catalog item can create either:

  • REQ/RITM (Request path)
  • Incident only (Incident path)

If so:

  1. What is the best practice for handling attachments uploaded on the catalog form?
  2. Can the catalog form attachments be copied to the Incident record after creation?
  3. Is there a recommended approach using:
    • GlideSysAttachment
    • Business Rule
    • Script Include
    • Flow Designer
  4. Is using a Catalog Item for Incident creation the right approach, or would a Record Producer be a better design?

Any suggestions or examples would be greatly appreciated.

Thanks!

2 REPLIES 2

Tanushree Maiti
Tera Patron

Hi @RushikeshB24337 

 

Whenever you use GlideAjax with a Script Include to create an Incident  using .insert() , after that once the Incident is created, you can copy the attachment to the Incident using GlideSysAttachment.copy().

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

musislam
Kilo Sage

@RushikeshB24337 the copy itself works, but the tricky part is where the attachments actually sit. On a catalog form they get saved to sys_attachment before submit, against the cart item (table_name sc_cart_item, table_sys_id = the form's unique value), not against any real record. On your Incident path nothing ever picks them up.

Quickest fix with your current design: pass g_form.getUniqueValue() in the GlideAjax call, then in the Script Include after the insert, copy the attachments from that source to the new incident.

Design-wise I'd lean toward a Record Producer on incident for the Incident path. Attachments carry over automatically and you don't need GlideAjax to create the record.

Couple of questions:
1. Portal or native UI?
2. After the GlideAjax call, are you returning false in onSubmit to stop the catalog submission?

If that works for you, mind marking it as the recommended solution? Helps me support these better for the community.

Macki | Deloitte AU | Engineer Lead