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.
Best 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;
}1
Answers
-
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.
1 -
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;
}1 -
Thank you, I will give this a try
1 -
@sstorm183 - how did you get on? You in good shape?
0 -
Dan,
Your solution worked exactly like I needed it to.
Thank you.0 -
Perfect, thank you!
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 731 Beast Mode
- 55 App Studio
- 40 Variables
- 682 Automate
- 175 Apps
- 451 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 122 Manage
- 119 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 107 Community Announcements
- 4.8K Archive