Catalog Item Creating Either Request (RITM) or Incident - Attachment Issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Everyone,
I have a issue where users can submit either a Request or an Incident from a single Service Catalog form.
Current Design
User selects Type:
- Request
- Incident
If Request is selected:
- Standard Service Catalog submission occurs.
- REQ, RITM, and Catalog Task records are created through Flow Designer.
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:
- What is the best practice for handling attachments uploaded on the catalog form?
- Can the catalog form attachments be copied to the Incident record after creation?
- Is there a recommended approach using:
- GlideSysAttachment
- Business Rule
- Script Include
- Flow Designer
- 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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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().
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@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.
