AlteryxEngine API Example

Version:
2019.3
Last modified: March 20, 2020

The AlteryxEngine API is a collection of methods and callbacks that allow you to call into the AlteryxEngine. The following code is a sample usage of the AlteryxEngine API.

C++
  1. const int STATUS_Info = 1;
  2. const int STATUS_Warning = 2;
  3. const int STATUS_Error = 3; 
  4. const int STATUS_FieldConversionError = 5;
  5. const int STATUS_File_Input = 8; 
  6. const int STATUS_File_Output = 9; 
  7. const int STATUS_Flag_Transient = 0x40000000;  // in combination with Info, Warning or FieldConversionError
  8.  
  9. // Example RuntimeData struct
  10. struct RuntimeData
  11. {
  12.    int nWarnings;
  13.    int nFieldConversionErrors;
  14.    int nErrors;
  15.    std::wofstream logFile;
  16.    RuntimeData()
  17. 	: nWarnings(0)
  18. 	, nFieldConversionErrors(0)
  19. 	, nErrors(0)
  20.    {
  21.    }
  22. };
  23.  
  24.  
  25. long _stdcall ProgressMessage(__int64 userData, int nToolID, double dPercentProgress)
  26. {
  27.    // See TCallbackToolProgress for actions you can accomplish here....
  28.    return 0;
  29. }
  30.  
  31. long _stdcall CallbackMessage(__int64 userData, int nToolID, int nStatus, const wchar_t *pMessage)
  32. {
  33.    // See callback documentation for what you can do when you define your own callback message
  34.    switch (nStatus & ~STATUS_Flag_Transient)
  35.    {
  36.    case STATUS_Info:
  37.    case STATUS_File_Input:
  38.    case STATUS_File_Output:
  39. 	break;
  40.    case STATUS_Warning:
  41.      reinterpret_cast<RuntimeData *>(userData)->nWarnings++;
  42.      reinterpret_cast<RuntimeData *>(userData)->logFile << L"Warning - ";
  43. 	break;
  44.    case STATUS_Error:
  45.    reinterpret_cast<RuntimeData *>(userData)->nErrors++;
  46.    reinterpret_cast<RuntimeData *>(userData)->logFile << L"Error - ";
  47. 	break;
  48.    case STATUS_FieldConversionError:
  49.      reinterpret_cast<RuntimeData *>(userData)->nFieldConversionErrors++;
  50.      reinterpret_cast<RuntimeData *>(userData)->logFile << L"FieldConversionError - ";
  51. 	break;
  52.    default:
  53. 	return 0;
  54.    }
  55.  
  56.    if (nToolID<0)
  57.      reinterpret_cast<RuntimeData *>(userData)->logFile << L"Alteryx Engine";
  58.    else
  59.      reinterpret_cast<RuntimeData *>(userData)->logFile << L"ToolId " << nToolID;
  60.      reinterpret_cast<RuntimeData *>(userData)->logFile << L": " << pMessage << L"\n";
  61.      return 0;
  62. }
  63. //      Later in your API code...
  64. {
  65.    RuntimeData runtimeData;
  66.  
  67.    AlteryxRunModule2(L"<workflowPath>", L"",
  68. 	ProgressMessage, CallbackMessage,
  69. 	reinterpret_cast<__int64>(&runtimeData));
  70. }
Was This Helpful?

Running into problems or issues with your Alteryx product? Visit the Alteryx Community or contact support.