Not able to append the dataset in Workflow

I was able to pass the value, my workflow is showing status as completed. But not able to see the new records in the dataset. I have created my own code engine. Below mentioned is the link. Using version. 1.0.2.

https://bareinternational.domo.com/codeengine/761fcf57-8592-45c6-9f37-1adf5b795473

Tagged:

Answers

  • DanHendriksen
    DanHendriksen Domo Employee

    Pravin, nobody can see your codeEngine package without having access to your Domo instance.

    You can paste your code here and I'd be happy to take a look. Is there a reason you're not using the existing Domo published function for appending a row to a dataset?

  • Actually I am trying to upload multiple rows in the dataset through WF. I am not able to configure current code engine due its output format. Here you go with my code. Kindly note that, just now I observed that, its not accepting the special characters while saving to the target dataset via this code. So it would be good, if you help me in that case.




    const codeengine = require('codeengine');

    const DATASOURCE = {
    v2: 'api/data/v2/datasources',
    v3: 'api/data/v3/datasources',
    };
    const DATASET_URL = ${DATASOURCE.v3}/:id;
    const UPLOADS_URL = ${DATASET_URL}/uploads;
    const UPLOADS_PARTS_URL = ${UPLOADS_URL}/:uploadId/parts/1;
    const UPLOADS_COMMIT_URL = ${UPLOADS_URL}/:uploadId/commit;

    async function appendToDataset(dataset, values) {
    const uploadsUrl = UPLOADS_URL.replace(':id', dataset);
    const uploadsBody = {
    action: 'APPEND',
    message: 'Uploading',
    appendId: 'latest',
    };

    try {
    const uploadsResponse = await codeengine.sendRequest(
    'post',
    uploadsUrl,
    uploadsBody,
    );
    const partsUrl = UPLOADS_PARTS_URL.replace(':id', dataset).replace(
    ':uploadId',
    uploadsResponse.uploadId,
    );

    await codeengine.sendRequest('put', partsUrl, values, null, 'text/plain');
    
    const commitUrl = UPLOADS_COMMIT_URL.replace(':id', dataset).replace(
      ':uploadId',
      uploadsResponse.uploadId,
    );
    const commitBody = {
      index: true,
      appendId: 'latest',
      message: 'it worked',
    };
    
    return await codeengine.sendRequest(
      'put',
      commitUrl,
      commitBody,
      null,
      'application/json',
    );
    

    } catch (error) {
    console.error(error);
    }
    }