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
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3.8K Transform
- 659 Datasets
- 116 SQL DataFlows
- 2.2K Magic ETL
- 816 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 82 App Studio
- 45 Variables
- 776 Automate
- 190 Apps
- 481 APIs & Domo Developer
- 82 Workflows
- 23 Code Engine
- 40 AI and Machine Learning
- 20 AI Chat
- 1 AI Playground
- 1 AI Projects and Models
- 18 Jupyter Workspaces
- 410 Distribute
- 120 Domo Everywhere
- 280 Scheduled Reports
- 10 Software Integrations
- 144 Manage
- 140 Governance & Security
- 8 Domo Community Gallery
- 48 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive