Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2026 01:09 PM
This is how my flow looks like. I left the image field blank, then i created the custom actions for the modify and add new device. I tested the catalog item. It didn't add the image to the table or modify it. I'm not sure where it went wrong.
Trigger: Service Catalog
Action:
1. Get Catalog Variables
2 If the request is modify the device
1. Modify name
OS
Model:
Type:
Image = Blank
Custom Action: action to set image
3. If the request is add new device
1. Add name
OS
Model:
Type:
Image = Blank
Custom Action: Add action to set image
This is my custom action looks like
(function execute(inputs, outputs) {
var sourceAttachmentId = inputs.attachment_sys_id;
var targetSysId = inputs.target_sys_id;
//gs.info('Attachment ID: ' + sourceAttachmentId);
//gs.info('Target Sys ID: ' + targetSysId);
var sourceAtt = new GlideRecord('sys_attachment');
if (!sourceAtt.get(sourceAttachmentId))
return;
// Validate that it is actually an image
if (!sourceAtt.getValue('content_type').startsWith('image/'))
return;
var target = new GlideRecord('u_am_device');
if (!target.get(targetSysId))
return;
var gsa = new GlideSysAttachment();
// Copy the actual binary content
var newAttachmentId = gsa.writeContentStream(
target,
'image',
sourceAtt.getValue('content_type'),
gsa.getContentStream(sourceAttachmentId)
);
// Convert the normal attachment into an Image-field attachment
var newAtt = new GlideRecord('sys_attachment');
if (newAtt.get(newAttachmentId)) {
newAtt.setValue('table_name', 'u_am_device');
newAtt.setValue('table_sys_id', targetSysId);
newAtt.setValue('file_name', 'image');
newAtt.update();
target.setValue('image', newAttachmentId);
target.update();
}
})(inputs, outputs);