【问题标题】:Get output from Alteryx API Query从 Alteryx API 查询获取输出
【发布时间】:2020-01-30 13:21:47
【问题描述】:

我一直在尝试设置一个 javascrip 应用程序,该应用程序能够运行并显示托管在我的服务器上的 Alteryx 分析应用程序的输出。然后的想法是将其嵌入到 Tableau 服务器中。

我已经设置了一些东西,它能够从用户输入运行应用程序并显示其状态。 但是获取作业的输出有点棘手,我无法理解它。 看来我应该使用 getOutputFileURL() 函数来获得我想要的东西,但我真的不确定我应该如何设置它。 我尝试在第 54 行构建一个函数 getOutputs(),但它没有给我任何东西。

任何有类似经历的人会介意在这里帮助我吗? 谢谢

'''`// Importing the modules & the keys
// polyfilling the extensions browser
import "babel-polyfill";
import keys from "./keys";
import Gallery from "alteryx-subscription-api";
import tableauJS from "./tableau";

// Grab the Run Button
const btn = document.getElementById("btn");
// Grab the input box
const input = document.getElementById("peopleSearch");
// Grab the message box
const inputValue = document.getElementById("message");
// Grab the spinner gif
const loading = document.getElementById("spinner");
// Grab the status paragraph
const statusInfo = document.getElementById("status");
// Grab the output div
const dataPrint = document.getElementById("dataOutput");

// load into the gallery based on the values specified in the keys file
const createGallery = () => {
  const gallery = new Gallery(keys.apilocation, keys.apikey, keys.apisecret);
  return gallery;
};

async function jobs(jobId) {
  const response = await createGallery().getJob(jobId);
  const data = await response.json();

  if (data.status !== "Completed") {
    // if workflow hasn't been completed, keep checking the jobID for its status
    jobs(jobId);
    if (inputValue.style.display == "block") {
      inputValue.style.display = "none";
    }
    loading.style.display = "inline";
    // if error please report
  } else if (data.status === "Error") {
    console.error(data.status);
    const status = data.status;
    statusInfo.innerHTML = status;
  } else {
    // if finished display completed message
    loading.style.display = "none";
    const status = data.status;
    statusInfo.innerHTML = status;
    statusInfo.style.display = "inline";
    // after 4 seconds remove the input and refresh the DS
    removeElement();
  }
}

// gets output from the job
async function getOutputs(jobId) {
  const response = await createGallery().getJob(jobId);
  const data = await response.json();
  console.log(data);
  for (var i = 0; i < data.length; i++) {
    var url = galleryOutput.getOutputFileURL(jobId, data.id, "Raw");
    dataPrint.innerHTML == url;
    dataPrint.style.display = "inline";
  }
  }

// on click of buton run the workflow/app specified in the keys file
async function runWorkflow(appId, dataArray) {
  const response = await createGallery().executeWorkflow(appId, dataArray);
  const data = await response.json();
  console.log(data);
  // check if the job is running and if finished
  jobs(data.id);
  getOutputs(data.id);
}


// If you click run, first check if search input has been specified, then it grabs the appID from the keys file
btn.addEventListener("click", () => {
  const peopleSearch = input.value;
  const appId = keys.appId;
  if (!peopleSearch) {
    inputValue.style.display = "block";
  } else {
    inputValue.style.display = "none";
    statusInfo.style.display = "none";
    const dataArray = [
      {
        name: "Text Box (414)",
        value: peopleSearch
      }
    ];
    runWorkflow(appId, dataArray);
  }
});

//removes the messages and the search input after 4 seconds and refresh the data source
function removeElement() {
  setTimeout(() => {
    if ((statusInfo.style.display = "inline")) {
      statusInfo.style.display = "none";
      input.value = "";
      tableauJS.refreshDS();
    }
  }, 6000);
}
`

【问题讨论】:

标签: javascript api alteryx


【解决方案1】:

更有效的过程是使用 Alteryx 中的输出工具写入数据库或 .TDE 表格数据文件,然后正确摄取到 Tableau 中。

【讨论】:

    猜你喜欢
    • 2016-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-06
    • 2021-07-24
    • 2020-03-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多