This article demonstrates the mentioning of the values in JavaScrip code using NodeJs by Quickwork.
What you'll need:
Skill level: Expert
Time required: 6 minutes
- NodeJs action
- Skills for writing JavaScript code
- Proper usage of double-quotes to the values passed
What is NodeJs
NodeJs lets you execute small JavaScript code snippets to create responsive data that can be used by other configured journeys or actions. The JavaScript code can help you with activities such as data mining, form validations, data interpretations, search operations, etc., depending on the data you have and the business requirement that you need to fulfill.
Quickwork has made a provision for the users to execute a JavaScript code using the NodeJs app. Writing the code depends on your intellectual and business requirements. However, there are some ways to provide input values to the keys and identifiers written in the code that Quickwork strictly obeys. The two possible ways are:
- Specifying a value using the context object
- Passing data pills directly as a value
Specifying a value using the context object
Consider the following sample JavaScript code written in the Code field of the NodeJs app:
In this code, the context
keyword is appended with the .Email
string as a raw input. No data pill from the output of previous actions or a trigger is passed as a value to the context keyword.
So, it becomes mandatory to give meaning to the raw string input values passed. Upon scrolling down the NodeJs action, you'll get the Context object field containing Key and Value fields:
The .Email
keyword can be considered a key that is mapped with the respective data pill from the output of previous action(s) as shown in the above screenshot. This gives validation to the raw inputs specified in the code above:
Passing data pills directly as a value for the key
Now let’s consider the same example code with just one small change as shown in the screenshot below:
In this code, the email
data pill has been assigned a value by using a data pill from the output of a previous action directly. Thus, the usage of the context object is not required in this case. However, there is a golden rule to follow while passing values directly using data pills.
Data pills in string format must be mentioned in double-quotes.
Look at the prefixes of data pills in the Data Tree Output:
Prefix | Data type | Double-quotes required while passing as an input |
abc |
String | Yes |
object |
Object | No |
123 |
Integer | No |
array |
Array | No |
Comments
0 comments
Please sign in to leave a comment.