Converting Variables to pass to AppDb

@GrantSmith I have a feeling you will know the answer to this.

I have a new workflow that will be used by multiple custom apps to create new tasks in a 3rd party system. The workflow is triggered by the submit button on the custom app which then is able to pass everything that will be needed to make the API call and all the required items for it to be logged and then have the email notifications go out. The issue I am having is getting the variables into a format that I can pass to AppDB. If anyone has any suggestions, I welcome all the help you have to offer.

Tagged:

Best Answer

  • DanHendriksen
    DanHendriksen Domo Employee
    edited August 1 Answer ✓

    So, this example is likely unnecessarily complex, but you can see that it takes all your variables as arguments and assembles an object that it returns:

    function createCodeEngineRequest(requestType,functionName,functionDescription,functionCode,functionInputs,functionOutput,functionPackage,functionLanguage,packageLanguage,packageName,packageDescription,packageCode,submittorNotes,submittedBy) {
    var requestTypeText;
    switch (requestType) {
    case 'newFunction':
    requestTypeText = 'Create New Function';
    break;
    case 'addFunction':
    requestTypeText = 'Add Created Function to Existing Package';
    break;
    case 'addPackage':
    requestTypeText = 'Add Created Package to Global Packages';
    break;
    default:
    requestTypeText = 'Unknown Request Type';
    break;
    }
    var submittedDate = new Date();
    var collectionDocument = {
    "content": {
    "requestType": requestTypeText,
    "functionName": functionName,
    "functionDescription": functionDescription,
    "functionLanguage": functionLanguage,
    "functionCode": functionCode,
    "functionInputs": functionInputs,
    "functionOutput": functionOutput,
    "functionPackage": functionPackage,
    "packageLanguage": packageLanguage,
    "packageName": packageName,
    "packageDescription": packageDescription,
    "packageCode": packageCode,
    "submittorNotes": submittorNotes,
    "submittedBy": submittedBy,
    "nextActionBy":"Jason Hodges",
    "status":"Pending Approval",
    "submittedDate": submittedDate
    }
    };
    return collectionDocument;
    }

Answers

  • DanHendriksen
    DanHendriksen Domo Employee

    So, you need to create an object with an object inside of it.

    { content: {

    key: value,

    key2: value2,

    key3: value3 }

    }

    Let me find some code I use for that real quick.

  • DanHendriksen
    DanHendriksen Domo Employee
    edited August 1 Answer ✓

    So, this example is likely unnecessarily complex, but you can see that it takes all your variables as arguments and assembles an object that it returns:

    function createCodeEngineRequest(requestType,functionName,functionDescription,functionCode,functionInputs,functionOutput,functionPackage,functionLanguage,packageLanguage,packageName,packageDescription,packageCode,submittorNotes,submittedBy) {
    var requestTypeText;
    switch (requestType) {
    case 'newFunction':
    requestTypeText = 'Create New Function';
    break;
    case 'addFunction':
    requestTypeText = 'Add Created Function to Existing Package';
    break;
    case 'addPackage':
    requestTypeText = 'Add Created Package to Global Packages';
    break;
    default:
    requestTypeText = 'Unknown Request Type';
    break;
    }
    var submittedDate = new Date();
    var collectionDocument = {
    "content": {
    "requestType": requestTypeText,
    "functionName": functionName,
    "functionDescription": functionDescription,
    "functionLanguage": functionLanguage,
    "functionCode": functionCode,
    "functionInputs": functionInputs,
    "functionOutput": functionOutput,
    "functionPackage": functionPackage,
    "packageLanguage": packageLanguage,
    "packageName": packageName,
    "packageDescription": packageDescription,
    "packageCode": packageCode,
    "submittorNotes": submittorNotes,
    "submittedBy": submittedBy,
    "nextActionBy":"Jason Hodges",
    "status":"Pending Approval",
    "submittedDate": submittedDate
    }
    };
    return collectionDocument;
    }

  • Thank you, I will give this a try

  • sstorm183
    sstorm183 Member
    edited August 9

    Dan,

    Your solution worked exactly like I needed it to.

    Thank you.