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.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 101 SQL DataFlows
- 622 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 748 Beast Mode
- 59 App Studio
- 41 Variables
- 686 Automate
- 176 Apps
- 453 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 396 Distribute
- 113 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 125 Manage
- 122 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 109 Community Announcements
- 4.8K Archive