- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 08:06 PM
I created Flow Designer Action which call REST Message via Script Includes to send an outbound REST web service request to external system.
but, I got the error below
No IntegrationHub plugin is available, external calls from the Flow Designer requires IntegrationHub subscription, <a target="_blank" href="https://docs.servicenow.com/?context=CSHelp:IntegrationHub-licensing-information">Read More</a>.
Although I know that it is impossible to call REST directly from the Flow Designer, I think that it was possible to go through Script Includes.
Could you tell me where the solution is?
Thanks
Solved! Go to Solution.
- Labels:
-
flow designer
-
IntegrationHub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 02:18 PM
From what i'm seeing if you are using Flow Designer there is no way around it. You will need IntegrationHub. If you aren't stuck on using Flow Designer you can use the normal Workflow Editor instead to call your Script Include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2022 05:40 AM
++ Attaching the 'Action script' code of 'copying the attachment' as well through REST message from flow designer-
(function execute(inputs, outputs) {
// ... code ...
try {
var encodedFile; //this will store the encoded version of the attachment.
var fileName;
var contentType;
//need to glide attachment table
var att = new GlideRecord('sys_attachment');
// we need to look for the attachment in sys_attachment table for current incident record
att.addQuery('table_name', inputs.tablename);
att.addQuery('table_sys_id',inputs.incident_sys_id); // table_sys_id is the sysID of current incident record
att.query();
//one attachment for now
if(att.next()){
gs.info("Kartik if");
var gSysAtt = GlideSysAttachmentInputStream(att.sys_id.toString()); //GlideSysAttachment accepts the parameter of sys_id
/* the byte arr output stream, for that we are using the package curl, this is the java file in backed which we donot have access to */
var byteos = new Packages.java.io.ByteArrayOutputStream();
//Now we will write these bytes into glideSysAttachmentInputStream
gSysAtt.writeTo(byteos, 0, 0); //two nodes
byteos.close();
//fetch the encoded file from there and store it
encodedFile = GlideStringUtil.base64Encode(byteos.toByteArray()); // function to fetch, encoding function base64
//get the file name from attachment table
fileName = att.file_name;
//content type of att
contentType = att.content_type;
}
var r = new sn_ws.RESTMessageV2('PIP_integration_to_instanceB', 'copy incident');
r.setStringParameterNoEscape('correlation_id', inputs.correlation_id);
r.setStringParameterNoEscape('short_description', inputs.short_description);
r.setStringParameterNoEscape('description', inputs.description);
r.setStringParameterNoEscape('impact', inputs.impact);
r.setStringParameterNoEscape('urgency', inputs.urgency);
r.setStringParameterNoEscape('assignment_group', inputs.assignment_group);
r.setStringParameterNoEscape('assigned_to', inputs.assigned_to);
r.setStringParameterNoEscape('encodedFile', encodedFile);
r.setStringParameterNoEscape('nameOfFile', fileName);
r.setStringParameterNoEscape('typeOfFile', contentType);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
outputs.responsebody = responseBody;
} catch (ex) {
var message = ex.message;
}})(inputs, outputs);
At Instance B, you have to attach the attachment in created/updated incident. For that , we need to receive the attachment type, attachment file name, attachment data, decode the attachment data and attach it to incident in instance B.
I have written 'onAfter' transform script for same. Do remember to create three variable in your 'Staging table' - Attachment file Type, Attachment file Data, Attachment file name. So that we can retrieve them from 'Source' object in 'onAfter' transform script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2022 05:44 AM
'OnAfter' script-
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if (gs.nil(source.u_attachment_data)) {
gs.log("Kartik TM if");
ignore = true;
} else {
var grIncident = new GlideRecord('incident');
grIncident.get(target.sys_id);
var sa = new GlideSysAttachment();
sa.write(target, source.u_attachment_name, source.u_attachment_type, source.u_attachment_data);
}
})(source, map, log, target);