community
cancel
Showing results for 
Search instead for 
Did you mean: 

Dev Space

Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!
SOLVED

Javascript Plugin Connector With AJAX Callback Not Being Run

Highlighted
Alteryx Partner

Hello,

 

I am currently developing an Javascript HTML plugin using the JavascriptPluginExample as my base.  It has been very helpful, however I am at a point where I cannot continue because when the user runs the workflow, I need to hit an API that is outside of Alteryx.  To do this I am currently using the Alteryx.Plugin.II_PushRecords function or the Alteryx.Plugin.PI_PushAllRecords if it is only an output.  I can see in fiddler that my Ajax call is made, and data is returned just fine from the API, but the callback inside the call is never called.  I have tested this code on another project, so I know my code should work as is.  Can someone please help me understand why the callback is not being called in the Engine file?  What I need to do to have these callbacks be called, ect...

 

I moved the code to the GUI file, and there it did hit the callback just fine.  However I do not see an event I can use to hook into when the user runs the workflow.  I only see before load and after load, which both run way before the user has entered all needed info and hit play.  I am fine with moving the ajax call to the GUI, if there is a proper event I can use for this.  Any help would be much appreciated.  I am pasting the code below...

 

GUI FILE....

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Javascript Plugin Example</title>
<script type="text/javascript">
// Include version 1 of the base GUI library.
document.write('<link rel="import" href="' + window.Alteryx.LibDir + '1/lib/alteryx/gui/includes.html">');
</script>
</head>
<body>
<form>
<!--
This file provides a comprehensive list of the GUI widgets available in the Alteryx plugin widget library.
-->
<fieldset>
<legend>Read Configuration</legend>
<label for="auth">Auth Key</label>
<alteryx-pluginwidget data-props='{type:"TextBox",id:"auth",debug:"true",dataName:"auth"}'></alteryx-pluginwidget>

<label for="dropDownList">Type</label>
<alteryx-pluginwidget data-props='{type:"DropDown",id:"dropDownList",dataName:"dropDownList",ignoremissingfields:"true"}'>
<alteryx-option id="default" default>Select a storage engine...</alteryx-option>
<alteryx-option id="sqlserver">MS SQL Server</alteryx-option>
<alteryx-option id="mysql">MySQL / AWS Aurora</alteryx-option>
<alteryx-option id="postgres">PostgreSQL / AWS Redshift</alteryx-option>
<alteryx-option id="oracle">Oracle</alteryx-option>
<alteryx-option id="snowflake">Snowflake</alteryx-option>
<alteryx-option id="documentdb">Azure Document DB</alteryx-option>
<alteryx-option id="mongodb">MongoDB</alteryx-option>
<alteryx-option id="azureblob">Azure Blob Storage</alteryx-option>
<alteryx-option id="s3">AWS S3</alteryx-option>
<alteryx-option id="http">HTTP</alteryx-option>
</alteryx-pluginwidget>
</fieldset>

<div id="content-placeholder"> </div>

<div id="log"></div>

</form>

<script src="../../RuntimeData/HtmlAssets/Workflows/js/engine_dialog_utils.js"></script>
<script type="text/javascript">

/**
* Specify actions that will take place before the tool's configuration is loaded into the manager.
*
* @param manager The data manager.
* @param AlteryxDataItems The data items in use on this page.
*/
Alteryx.Gui.BeforeLoad = function (manager, AlteryxDataItems) {
};

/**
* Set the tool's default annotation on the canvas.
*
* @param manager The data manager.
* @returns {string}
*/
Alteryx.Gui.Annotation = function (manager) {
return "Set Values of the Configuration Fields to Connect"
//manager.GetDataItem("dropDownList").value;
};



//function updateCodeEditorHintListFromTextBox() {
// var codeEditor = window.Alteryx.Gui.renderer.getReactComponentByDataName('FormulaFields2');
// codeEditor.editor.options.hintList = document.getElementById('csvCodeEditorHintListTextBox').value;
//}

//window.Alteryx.Gui.manager.AppendAlteryxTag({ dataname: 'dataName' + Math.random(), type: 'CheckBox', text: 'this is a dynamically added checkbox' })

function loadFields(e) {
var textToLoad = '';
$("#log").html(textToLoad);
switch (e) {
case "MySQL / AWS Aurora": {
delimiter = "MySQL.";
textToLoad = '<label for="MySQL.credentials.server">Host</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MySQL.credentials.server",debug:"true",dataName:"MySQL.credentials.server"}\'></alteryx-pluginwidget>'
+ '<label for="MySQL.credentials.port">Port</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MySQL.credentials.port",debug:"true",dataName:"MySQL.credentials.port"}\'></alteryx-pluginwidget>'
+ '<label for="MySQL.credentials.username">Username</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MySQL.credentials.username",debug:"true",dataName:"MySQL.credentials.username"}\'></alteryx-pluginwidget>'
+ '<label for="MySQL.credentials.password">Password</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MySQL.credentials.password",debug:"true",dataName:"MySQL.credentials.password"}\'></alteryx-pluginwidget>'
+ '<label for="MySQL.credentials.database">Database</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MySQL.credentials.database",debug:"true",dataName:"MySQL.credentials.database"}\'></alteryx-pluginwidget>'
+ '<label for="MySQL.tablename">Table</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MySQL.tablename",debug:"true",dataName:"MySQL.tablename"}\'></alteryx-pluginwidget>'
+ '<label for="MySQL.take">Limit Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MySQL.take",debug:"true",dataName:"MySQL.take"}\'></alteryx-pluginwidget>'
+ '<label for="MySQL.skip">Skip Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MySQL.skip",debug:"true",dataName:"MySQL.skip"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"CheckBox",id:"MySQL.truncate",dataName:"MySQL.truncate",text:"Truncate the table after copying?"}\'></alteryx-pluginwidget>';
break;
}
case "PostgreSQL / AWS Redshift": {
delimiter = "PostgreSQL.";
textToLoad = '<label for="PostgreSQL.credentials.server">Host</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"PostgreSQL.credentials.server",debug:"true",dataName:"PostgreSQL.credentials.server"}\'></alteryx-pluginwidget>'
+ '<label for="PostgreSQL.credentials.port">Port</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"PostgreSQL.credentials.port",debug:"true",dataName:"PostgreSQL.credentials.port"}\'></alteryx-pluginwidget>'
+ '<label for="PostgreSQL.credentials.username">Username</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"PostgreSQL.credentials.username",debug:"true",dataName:"PostgreSQL.credentials.username"}\'></alteryx-pluginwidget>'
+ '<label for="PostgreSQL.credentials.password">Password</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"PostgreSQL.credentials.password",debug:"true",dataName:"PostgreSQL.credentials.password"}\'></alteryx-pluginwidget>'
+ '<label for="PostgreSQL.credentials.database">Database</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"PostgreSQL.credentials.database",debug:"true",dataName:"PostgreSQL.credentials.database"}\'></alteryx-pluginwidget>'
+ '<label for="PostgreSQL.tablename">Table</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"PostgreSQL.tablename",debug:"true",dataName:"PostgreSQL.tablename"}\'></alteryx-pluginwidget>'
+ '<label for="PostgreSQL.take">Limit Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"PostgreSQL.take",debug:"true",dataName:"PostgreSQL.take"}\'></alteryx-pluginwidget>'
+ '<label for="PostgreSQL.skip">Skip Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"PostgreSQL.skip",debug:"true",dataName:"PostgreSQL.skip"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"CheckBox",id:"PostgreSQL.truncate",dataName:"PostgreSQL.truncate",text:"Truncate the table after copying?"}\'></alteryx-pluginwidget>';
break;
}
case "MongoDB": {
delimiter = "MongoDB.";
textToLoad = '<label for="MongoDB.credentials.server">Host</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MongoDB.credentials.server",debug:"true",dataName:"MongoDB.credentials.server"}\'></alteryx-pluginwidget>'
+ '<label for="MongoDB.credentials.port">Port</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MongoDB.credentials.port",debug:"true",dataName:"MongoDB.credentials.port"}\'></alteryx-pluginwidget>'
+ '<label for="MongoDB.credentials.username">Username</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MongoDB.credentials.username",debug:"true",dataName:"MongoDB.credentials.username"}\'></alteryx-pluginwidget>'
+ '<label for="MongoDB.credentials.password">Password</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MongoDB.credentials.password",debug:"true",dataName:"MongoDB.credentials.password"}\'></alteryx-pluginwidget>'
+ '<label for="MongoDB.credentials.database">Database</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MongoDB.credentials.database",debug:"true",dataName:"MongoDB.credentials.database"}\'></alteryx-pluginwidget>'
+ '<label for="MongoDB.tablename">Table</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MongoDB.tablename",debug:"true",dataName:"MongoDB.tablename"}\'></alteryx-pluginwidget>'
+ '<label for="MongoDB.take">Limit Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MongoDB.take",debug:"true",dataName:"MongoDB.take"}\'></alteryx-pluginwidget>'
+ '<label for="MongoDB.skip">Skip Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"MongoDB.skip",debug:"true",dataName:"MongoDB.skip"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"CheckBox",id:"MongoDB.truncate",dataName:"MongoDB.truncate",text:"Truncate the table after copying?"}\'></alteryx-pluginwidget>';
break;
}
case "MS SQL Server": {
delimiter = "SQL.";
textToLoad = '<label for="SQL.credentials.server">Host</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"SQL.credentials.server",debug:"true",dataName:"SQL.credentials.server"}\'></alteryx-pluginwidget>'
+ '<label for="SQL.credentials.port">Port</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"SQL.credentials.port",debug:"true",dataName:"SQL.credentials.port"}\'></alteryx-pluginwidget>'
+ '<label for="SQL.credentials.username">Username</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"SQL.credentials.username",debug:"true",dataName:"SQL.credentials.username"}\'></alteryx-pluginwidget>'
+ '<label for="SQL.credentials.password">Password</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"SQL.credentials.password",debug:"true",dataName:"SQL.credentials.password"}\'></alteryx-pluginwidget>'
+ '<label for="SQL.credentials.database">Database</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"SQL.credentials.database",debug:"true",dataName:"SQL.credentials.database"}\'></alteryx-pluginwidget>'
+ '<label for="SQL.tablename">Table</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"SQL.tablename",debug:"true",dataName:"SQL.tablename"}\'></alteryx-pluginwidget>'
+ '<label for="SQL.take">Limit Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"SQL.take",debug:"true",dataName:"SQL.take"}\'></alteryx-pluginwidget>'
+ '<label for="SQL.skip">Skip Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"SQL.skip",debug:"true",dataName:"SQL.skip"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"CheckBox",id:"SQL.truncate",dataName:"SQL.truncate",text:"Truncate the table after copying?"}\'></alteryx-pluginwidget>';
break;
}
case "Oracle": {
delimiter = "Oracle.";
textToLoad = '<label for="Oracle.credentials.server">Host</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Oracle.credentials.server",debug:"true",dataName:"Oracle.credentials.server"}\'></alteryx-pluginwidget>'
+ '<label for="Oracle.credentials.port">Port</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Oracle.credentials.port",debug:"true",dataName:"Oracle.credentials.port"}\'></alteryx-pluginwidget>'
+ '<label for="Oracle.credentials.username">Username</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Oracle.credentials.username",debug:"true",dataName:"Oracle.credentials.username"}\'></alteryx-pluginwidget>'
+ '<label for="Oracle.credentials.password">Password</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Oracle.credentials.password",debug:"true",dataName:"Oracle.credentials.password"}\'></alteryx-pluginwidget>'
+ '<label for="Oracle.credentials.database">SSID</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Oracle.credentials.database",debug:"true",dataName:"Oracle.credentials.database"}\'></alteryx-pluginwidget>'
+ '<label for="Oracle.tablename">Table</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Oracle.tablename",debug:"true",dataName:"Oracle.tablename"}\'></alteryx-pluginwidget>'
+ '<label for="Oracle.take">Limit Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Oracle.take",debug:"true",dataName:"Oracle.take"}\'></alteryx-pluginwidget>'
+ '<label for="Oracle.skip">Skip Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Oracle.skip",debug:"true",dataName:"Oracle.skip"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"CheckBox",id:"Oracle.truncate",dataName:"Oracle.truncate",text:"Truncate the table after copying?"}\'></alteryx-pluginwidget>';
break;
}
case "Snowflake": {
delimiter = "Snowflake.";
textToLoad = '<label for="Snowflake.credentials.server">Host</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Snowflake.credentials.server",debug:"true",dataName:"Snowflake.credentials.server"}\'></alteryx-pluginwidget>'
+ '<label for="Snowflake.credentials.port">Port</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Snowflake.credentials.port",debug:"true",dataName:"Snowflake.credentials.port"}\'></alteryx-pluginwidget>'
+ '<label for="Snowflake.credentials.username">Username</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Snowflake.credentials.username",debug:"true",dataName:"Snowflake.credentials.username"}\'></alteryx-pluginwidget>'
+ '<label for="Snowflake.credentials.password">Password</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Snowflake.credentials.password",debug:"true",dataName:"Snowflake.credentials.password"}\'></alteryx-pluginwidget>'
+ '<label for="Snowflake.credentials.warehouse">Warehouse</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Snowflake.credentials.warehouse",debug:"true",dataName:"Snowflake.credentials.warehouse"}\'></alteryx-pluginwidget>'
+ '<label for="Snowflake.credentials.schema">Schema</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Snowflake.credentials.schema",debug:"true",dataName:"Snowflake.credentials.schema"}\'></alteryx-pluginwidget>'
+ '<label for="Snowflake.credentials.database">Database</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Snowflake.credentials.database",debug:"true",dataName:"Snowflake.credentials.database"}\'></alteryx-pluginwidget>'
+ '<label for="Snowflake.credentials.role">Role</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Snowflake.credentials.role",debug:"true",dataName:"Snowflake.credentials.role"}\'></alteryx-pluginwidget>'
+ '<label for="Snowflake.tablename">Table</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Snowflake.tablename",debug:"true",dataName:"Snowflake.tablename"}\'></alteryx-pluginwidget>'
+ '<label for="Snowflake.take">Limit Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Snowflake.take",debug:"true",dataName:"Snowflake.take"}\'></alteryx-pluginwidget>'
+ '<label for="Snowflake.skip">Skip Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"Snowflake.skip",debug:"true",dataName:"Snowflake.skip"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"CheckBox",id:"Snowflake.truncate",dataName:"Snowflake.truncate",text:"Truncate the table after copying?"}\'></alteryx-pluginwidget>';
break;
}
case "Azure Document DB": {
delimiter = "DocumentDB.";
textToLoad = '<label for="DocumentDB.credentials.server">Host</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"DocumentDB.credentials.server",debug:"true",dataName:"DocumentDB.credentials.server"}\'></alteryx-pluginwidget>'
+ '<label for="DocumentDB.credentials.port">Port</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"DocumentDB.credentials.port",debug:"true",dataName:"DocumentDB.credentials.port"}\'></alteryx-pluginwidget>'
+ '<label for="DocumentDB.credentials.password">Access Key</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"DocumentDB.credentials.password",debug:"true",dataName:"DocumentDB.credentials.password"}\'></alteryx-pluginwidget>'
+ '<label for="DocumentDB.credentials.database">Database</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"DocumentDB.credentials.database",debug:"true",dataName:"DocumentDB.credentials.database"}\'></alteryx-pluginwidget>'
+ '<label for="DocumentDB.tablename">Table</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"DocumentDB.tablename",debug:"true",dataName:"DocumentDB.tablename"}\'></alteryx-pluginwidget>'
+ '<label for="DocumentDB.take">Limit Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"DocumentDB.take",debug:"true",dataName:"DocumentDB.take"}\'></alteryx-pluginwidget>'
+ '<label for="DocumentDB.skip">Skip Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"DocumentDB.skip",debug:"true",dataName:"DocumentDB.skip"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"CheckBox",id:"DocumentDB.truncate",dataName:"DocumentDB.truncate",text:"Truncate the table after copying?"}\'></alteryx-pluginwidget>';
break;
}
case "Azure Blob Storage": {
delimiter = "BlobStorage.";
textToLoad = '<label for="BlobStorage.credentials.server">Account Name</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"BlobStorage.credentials.server",debug:"true",dataName:"BlobStorage.credentials.server"}\'></alteryx-pluginwidget>'
+ '<label for="BlobStorage.credentials.password">Access Key</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"BlobStorage.credentials.password",debug:"true",dataName:"BlobStorage.credentials.password"}\'></alteryx-pluginwidget>'
+ '<label for="BlobStorage.credentials.database">Collection</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"BlobStorage.credentials.database",debug:"true",dataName:"BlobStorage.credentials.database"}\'></alteryx-pluginwidget>'
+ '<label for="BlobStorage.tablename">File Name</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"BlobStorage.tablename",debug:"true",dataName:"BlobStorage.tablename"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"DropDown",id:"BlobStorage.filtetype",dataName:"BlobStorage.filtetype",ignoremissingfields:"true"}\'><alteryx-option id="BlobStorage.json">json</alteryx-option><alteryx-option id="BlobStorage.xml">xml</alteryx-option><alteryx-option id="BlobStorage.csv">csv</alteryx-option></alteryx-pluginwidget>'
+ '<label for="BlobStorage.delimiter">Delimiter</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"BlobStorage.delimiter",debug:"true",dataName:"BlobStorage.delimiter"}\'></alteryx-pluginwidget>'
+ '<label for="BlobStorage.take">Limit Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"BlobStorage.take",debug:"true",dataName:"BlobStorage.take"}\'></alteryx-pluginwidget>'
+ '<label for="BlobStorage.skip">Skip Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"BlobStorage.skip",debug:"true",dataName:"BlobStorage.skip"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"CheckBox",id:"BlobStorage.truncate",dataName:"BlobStorage.truncate",text:"Truncate the table after copying?"}\'></alteryx-pluginwidget>';
break;
}
case "AWS S3": {
delimiter = "S3.";
textToLoad = '<label for="S3.credentials.username">Account Key</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"S3.credentials.username",debug:"true",dataName:"S3.credentials.username"}\'></alteryx-pluginwidget>'
+ '<label for="S3.credentials.password">Secret Key</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"S3.credentials.password",debug:"true",dataName:"S3.credentials.password"}\'></alteryx-pluginwidget>'
+ '<label for="S3.credentials.database">Bucket</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"S3.credentials.database",debug:"true",dataName:"S3.credentials.database"}\'></alteryx-pluginwidget>'
+ '<label for="S3.tablename">File Name</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"S3.tablename",debug:"true",dataName:"S3.tablename"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"DropDown",id:"S3.filtetype",dataName:"filtetype",ignoremissingfields:"true"}\'><alteryx-option id="S3.json">json</alteryx-option><alteryx-option id="S3.xml">xml</alteryx-option><alteryx-option id="S3.csv">csv</alteryx-option></alteryx-pluginwidget>'
+ '<label for="S3.delimiter">Delimiter</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"S3.delimiter",debug:"true",dataName:"S3.delimiter"}\'></alteryx-pluginwidget>'
+ '<label for="S3.take">Limit Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"S3.take",debug:"true",dataName:"S3.take"}\'></alteryx-pluginwidget>'
+ '<label for="S3.skip">Skip Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"S3.skip",debug:"true",dataName:"S3.skip"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"CheckBox",id:"S3.truncate",dataName:"S3.truncate",text:"Truncate the table after copying?"}\'></alteryx-pluginwidget>';
break;
}
case "HTTP": {
delimiter = "HTTP.";
textToLoad = '<label for="HTTP.credentials.server">Url</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"HTTP.credentials.server",debug:"true",dataName:"HTTP.credentials.server"}\'></alteryx-pluginwidget>'
+ '<label for="HTTP.credentials.headers">Headers</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"HTTP.credentials.headers",debug:"true",dataName:"HTTP.credentials.headers"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"DropDown",id:"HTTP.credentials.method",dataName:"HTTP.credentials.method",ignoremissingfields:"true"}\'><alteryx-option id="HTTP.GET">GET</alteryx-option><alteryx-option id="HTTP.POST">POST</alteryx-option><alteryx-option id="HTTP.PUT">PUT</alteryx-option><alteryx-option id="HTTP.DELETE">DELETE</alteryx-option></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"DropDown",id:"HTTP.filtetype",dataName:"HTTP.filtetype",ignoremissingfields:"true"}\'><alteryx-option id="HTTP.html">html</alteryx-option><alteryx-option id="HTTP.json">json</alteryx-option><alteryx-option id="HTTP.xml">xml</alteryx-option><alteryx-option id="HTTP.csv">csv/alteryx-option></alteryx-pluginwidget>'
+ '<label for="HTTP.delimiter">Delimiter</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"HTTP.delimiter",debug:"true",dataName:"HTTP.delimiter"}\'></alteryx-pluginwidget>'
+ '<label for="HTTP.path">CSS Selector</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"HTTP.path",debug:"true",dataName:"HTTP.path"}\'></alteryx-pluginwidget>'
+ '<label for="HTTP.take">Limit Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"HTTP.take",debug:"true",dataName:"HTTP.take"}\'></alteryx-pluginwidget>'
+ '<label for="HTTP.skip">Skip Rows</label><alteryx-pluginwidget data-props=\'{type:"TextBox",id:"HTTP.skip",debug:"true",dataName:"HTTP.skip"}\'></alteryx-pluginwidget>'
+ '<alteryx-pluginwidget data-props=\'{type:"CheckBox",id:"HTTP.truncate",dataName:"HTTP.truncate",text:"Truncate the table after copying?"}\'></alteryx-pluginwidget>';
break;
}
}
$("#content-placeholder").html(textToLoad);
}
</script>

</body>
</html>

 

 

ENGINE FILE....

 

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">

<!--including jquery here to use for ajax call, this can be changed later to use internal file if possible, or possibly use another method to call the api besides jquery-->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script>
// Include version 1 of the engine base library.
document.write('<link rel="import" href="' + window.Alteryx.LibDir + '1/lib/alteryx/engine/includes.html">');

</script>

<script>
/**
* This function defines our input and output connections.
* It must match the input and output connections defined in the GUI plugin's XML file.
*/
Alteryx.Plugin.DefineConnections = function () {
return {
IncomingConnections: [{
type: "Input1",
GroupInfo: {
count: 0,
grouping: "false"
}
}],
OutgoingConnections: [{
name: "Output"
}]
};
};

var auth = '';
var myData = {};
var configToSend = {
};

/**
* Called at the beginning of plugin lifetime with the plugin's configuration properties.
* This implementation contains example code that prints each configuration key/value pair as
* an engine output message.
*
* @params config The plugin's configuration.
*/
Alteryx.Plugin.PI_Init = function (config) {
//Builds out the object that I need to send to the READ API
Alteryx.Engine.SendMessage.Info("Config properties:");
var splitID = [];
for (var i in config.Configuration) {
Alteryx.Engine.SendMessage.Info(i + ": " + config.Configuration[i]);
if (config.Configuration[i]) {
if (i != "dropDownList" && i != "auth") {
splitID = String(i).split(".");
if (splitID.length > 2) {
configToSend.credentials[splitID[2]] = config.Configuration[i];
} else if (splitID.length == 2) {
configToSend[splitID[1]] = config.Configuration[i];
}
} else if (i == "dropDownList") {
if (configToSend["credentials"]) {
configToSend["credentials"]["type"] = connectionType(config.Configuration[i]);
} else {
configToSend["credentials"] = {};
configToSend["credentials"]["type"] = connectionType(config.Configuration[i]);
}
} else {
auth = config.Configuration[i];
}
}
}
//set the config property
Alteryx.Engine.SendMessage.Info(JSON.stringify(configToSend));
};

//takes in the string value of the dropdown connttion type and returns value used in backend
function connectionType(type) {
switch (type) {
case 'MS SQL Server': {
return 'sqlserver';
} case 'MySQL / AWS Aurora': {
return 'mysql';
}
case 'PostgreSQL / AWS Redshift': {
return 'postgres';
}
case 'Oracle': {
return 'oracle';
}
case 'Snowflake': {
return 'snowflake';
}
case 'Azure Document DB': {
return 'documentdb';
}
case 'MongoDB': {
return 'mongodb';
}
case 'Azure Blob Storage': {
return 'azureblob';
}
case 'AWS S3': {
return 's3';
}
case 'HTTP': {
return 'http';
}
}
}

/**
* Called once for each incoming connection with the connection's metainfo. When a per-connection init comes in,
* we would probably store off the incoming RecordInfo.
*
* @params metaInfo The meta-information for the current incoming connection.
*/
Alteryx.Plugin.II_Init = function (metaInfo) {
Alteryx.Engine.SendMessage.RecordInfo("Output", metaInfo.RecordInfo)
};

/**
* After II_Init has been called for each incoming connection, II_PushRecords is called for each non-empty
* incoming connection with that connection's records. This implementation contains example code that
* pushes out the same records it receives.
*
* @param data The incoming records.
*/
Alteryx.Plugin.II_PushRecords = function (data) {
Alteryx.Engine.SendMessage.Info("I AM IN PUSH RECORDS");
var myRecords = [];
var myRow = [];

configToSend["auth"] = auth;
configToSend["truncate"] = false;
// Alteryx.Engine.SendMessage.Info(JSON.stringify(configToSend));

var url = 'this is my url..com';


$.ajax({
url: url,
data: JSON.stringify(configToSend),
contentType: 'application/json',
type: 'POST',
context: document.body,
dataType: 'json'

}).done(function (data) {
myData = data;
Alteryx.Engine.SendMessage.Info("TELL ME I HIT DONE: ");
}).always(function () {
Alteryx.Engine.SendMessage.Info("TELL ME I HIT ALWAYS: ");
}).fail(function () {
Alteryx.Engine.SendMessage.Info("TELL ME I HIT FAIL: ");
})

//THis is alteryx demo code that I will probably need once my ajax calls hit the callbacks correctly
//for (var i = 0; i < data.Records.length; i++) {
// myRow = [];
// for (var j = 0; j < data.Records[i].length; j++) {
// myRow.push(data.Records[i][j]);
// }
// myRecords.push(myRow);
//}
Alteryx.Engine.SendMessage.PushRecords("Output", myData);
};

/**
* II_AllClosed is called with no arguments after all incoming connections have closed. This implementation
* sends a CloseOutput message with the name of the outgoing connection to close.
*
* All code paths must terminate with a call to Alteryx.Engine.SendMessage.Complete()
*/
Alteryx.Plugin.II_AllClosed = function () {
Alteryx.Engine.SendMessage.CloseOutput(Alteryx.Plugin.DefineConnections().OutgoingConnections[0].name);
Alteryx.Engine.SendMessage.Complete();
};

/**
* If the tool has no input:
* PI_PushAllRecords is called instead of the II functions.
* It is also called at configure time with a record limit of 0.
*
* If this function is implemented, all code paths must signal completion with a call to
* Alteryx.Engine.SendMessage.Complete()
*
* @param recordLimit The maximum number of records that this function should return.
*/

//For now, I have an input and an output, but once I remove the input, this is where the API call will need to live.
Alteryx.Plugin.PI_PushAllRecords = function (recordLimit) {
Alteryx.Engine.SendMessage.Error("This tool requires an input connection.");
Alteryx.Engine.SendMessage.Complete();
};

/**
* PI_Close is called with no arguments at the end of the plugin's lifetime.
* All code paths must terminate with a call to Alteryx.Engine.SendMessage.PI_Close()
*/
Alteryx.Plugin.PI_Close = function () {
Alteryx.Engine.SendMessage.PI_Close();
};

</script>
</head>
<body>
</body>
</html>

 

Alteryx Partner

Ok I figured out my own answer, thankfully.  For those of you that may be dealing with similar issue, what I found was the problem was Alteryx.Engine.SendMessage.Complete() was being called inside of PI_PushAllRecords, before the callback came back from the ajax call in II_PushRecords was called and run.  I was focusing on the II_PushRecords instead of the PI_PushAllRecords because I had an input in the connector.  It had an input because I could not figure out what to modify to remove the input and have it not timeout. I have since figured that out too, and thus moved the ajax call to the PushAllRecords, and moved the  Alteryx.Engine.SendMessage.Complete() inside of the callback. This totally fixed my issue and now I am getting proper data, and am able to load it into Alteryx. I still need to get the proper types and sizes, but for now, at least I am getting the data correctly and everything. The code now looks like below....

 

return $.ajax({
url: 'this is my url endpoint',
data: JSON.stringify(dataToSend),
contentType: 'application/json',
type: 'POST',
context: document.body,
dataType: 'json'
                }).success(function (myData) {
                if (myData.length) {
                     var mapFieldNames = [];
                     // Define the column metadata based on the first row returned
                     for (var field in myData[0]) {
                      // Add that new field's metainfo to the output
                          mapFieldNames.push({
                          name: field,
                           type: "V_WString",
                           size: 999999
                 });
           }
           // Tell alteryx the metadata for the fields
          Alteryx.Engine.SendMessage.RecordInfo("Output", { "Field": mapFieldNames });
          // Need to return the rows as an array of arrays
           Alteryx.Engine.SendMessage.PushRecords("Output", myData.map(function (row) {
           return mapFieldNames.map(function (col) {
           if (typeof row[col.name] != "undefined") {
                        return row[col.name];
                }
                  return null;
                      });
             }));
        }
        }).fail(function (e) {
             Alteryx.Engine.SendMessage.Error(JSON.stringify(e));
        }).always(function () {
             Alteryx.Engine.SendMessage.Complete();
 });