Hey,
Wondering if anyone can help me.
I have a custom integration, where I am using the inbuilt functionality for pulling between Sandbox and Production.
I have a step in a flow which requires submitting the Celigo Listener endpoint as a URL in the post to the 3rd party HTTP request.
I have setup an alias of the ‘export’ listener, but how can i surface the URL for the listener in my flow to be able to use the URL in my step…
This is a screenshot of where I need to put the listeners URL in my HTTP step.
I have created an alias of the export in the integration’s alias’.
Tried to follow this guide: Reference resource aliases in hooks, custom forms, and connection routes – Celigo Help Center, but isn’t very helpful in getting to a solution for what I need.
Any help really appreciated.
Aliases are only used for the integrator.io javascript runtime objects (like running a virtual export). You could theoretically write a script that runs an export to get the alias id, but that seems overkill to me.
My preferred way of saving settings/ids that change between sandbox and prod is to define them as a custom setting on the integration, and setting ILM to ignore those settings. Then update it after deploying to prod the first time. This seems a bit less nice than an alias but is a lot easier to setup/
Not the most intuitive way, but you could use a preSave script: https://docs.celigo.com/hc/en-us/articles/27359514088859-Pre-save-script#pre-save-script-0.
The script would be:
function preSave (options) {
var r = options.newResource;
if (!r.settings) r.settings = {};
if (!r.settings.aliases) r.settings.aliases = {};
var out = { exports: {}, imports: {}, flows: {}, connections: {} };
var a = r.aliases || [];
for (var i = 0; i < a.length; i++) {
var item = a[i];
if (!item || !item.alias) continue;
if (item._exportId) out.exports[item.alias] = item._exportId;
else if (item._importId) out.imports[item.alias] = item._importId;
else if (item._flowId) out.flows[item.alias] = item._flowId;
else if (item._connectionId) out.connections[item.alias] = item._connectionId;
}
r.settings.aliases = out;
return r;
}
Essentially, this duplicates the aliases to the settings field anytime aliases are updated or created. The settings can then be referenced with handlebar expressions like:
{{{settings.integration.aliases.exports.aliasName}}}
{{{settings.integration.aliases.imports.aliasName}}}
{{{settings.integration.aliases.connections.aliasName}}}
{{{settings.integration.aliases.flows.aliasName}}}
Or you could use a preSavePage script on your flow to add it to your record data and then reference it later. You do need an integrator.io connection and its ID referenced in the script.
import { exports } from 'integrator-api';
var ioConnectionId = "replaceMe";
function preSavePage (options) {
var integrationDetails = getIntegration(ioConnectionId, options._integrationId);
var aliases = (integrationDetails && integrationDetails.aliases) ? integrationDetails.aliases : [];
var out = {
flows: {},
exports: {},
imports: {},
connections: {}
};
for (var i = 0; i < aliases.length; i++) {
var item = aliases[i];
if (!item || !item.alias) continue;
if (item._flowId) out.flows[item.alias] = item._flowId;
else if (item._exportId) out.exports[item.alias] = item._exportId;
else if (item._importId) out.imports[item.alias] = item._importId;
else if (item._connectionId) out.connections[item.alias] = item._connectionId;
}
for (var j = 0; j < options.data.length; j++) {
options.data[j].aliases = out;
}
return {
data: options.data,
errors: options.errors,
abort: false,
newErrorsAndRetryData: []
};
}
function getIntegration (ioConnectionId, integration_id) {
return exports.runVirtual({
export: {
_connectionId: ioConnectionId,
http: {
relativeURI: "/v1/integrations/" + integration_id,
method: "GET"
}
}
}).data[0];
}