Welcome to the Make community!
Yes, that is possible. I highly recommend using the CustomJS integration for this to save on operations.
You’ll need a minimum of one “Execute Inline JavaScript Code” module:
Example Input/Output
Module Export
You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.
-
Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
-
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.
-
Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.
Click to Expand Module Export Code
JSON - Copy and Paste this directly in the scenario editor
{
"subflows": [
{
"flow": [
{
"id": 190,
"module": "custom-js:inlineexecutev2",
"version": 1,
"parameters": {
"__IMTCONN__": 2457341,
"jscode": "function calcSumOfDigits(text) {\n let res = text.split('').reduce((a, c) => {\n const num = Number(c);\n return isNaN(num) ? a : a + num;\n }, 0).toString();\n return res.length > 1 ? calcSumOfDigits(res) : Number(res);\n}\nreturn calcSumOfDigits(input);",
"returnValueType": "text"
},
"mapper": {
"input": "{{216.date}}"
},
"metadata": {
"designer": {
"x": 3275,
"y": -3969
},
"restore": {
"parameters": {
"__IMTCONN__": {
"label": "My CustomJS V2 connection",
"data": {
"scoped": "true",
"connection": "custom-js2"
}
},
"returnValueType": {
"label": "Text"
}
}
},
"parameters": [
{
"name": "__IMTCONN__",
"type": "account:custom-js2",
"label": "Connection",
"required": true
},
{
"name": "jscode",
"type": "text",
"label": "JavaScript Code",
"required": true
},
{
"name": "returnValueType",
"type": "select",
"label": "Return Type",
"required": true,
"validate": {
"enum": [
"text",
"collection",
"array",
"binary"
]
}
}
],
"expect": [
{
"name": "input",
"type": "text",
"label": "Input"
}
],
"interface": [
{
"name": "output",
"type": "text",
"label": "Output"
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}
Hope this helps! Let me know if there are any further questions or issues.
— @samliew