JavaScript Error with Bridge

I am using the API function to return a list of users as an array;
Then I am using the Javascript Module to filter those users whos status is "DEACTIVATED"
But I get the following error: "workflow execution failed: Plugin Error ERR_PROCESSING : failed to execute extension module : require is not defined"
Here is my Javascript code;
function filterDeactivated(users) {
return users
.filter(user => user.status === "DEACTIVATED")
.map(user => ({ name: user.name, status: user.status }));
}
Then my Key & Value is;
Where the value is the object array from the previous API call ({{states.startstate.call_api.make_api_call.response.data}})
Best Answer
-
Got it to work with the following code:
// Filter users with status 'DEACTIVATED'
const deactivatedUsers = users.filter(user => user.status === 'DEACTIVATED');// Map the desired properties (name and status) for each deactivated user
const result = deactivatedUsers.map(user => ({
name: user.name,
status: user.status
}));// Return the result as the output
return result;
Answers
-
I managed to get it to run, not sure what happened - deleted all scripts and rebuilt.. but it is returning nothing
-
Got it to work with the following code:
// Filter users with status 'DEACTIVATED'
const deactivatedUsers = users.filter(user => user.status === 'DEACTIVATED');// Map the desired properties (name and status) for each deactivated user
const result = deactivatedUsers.map(user => ({
name: user.name,
status: user.status
}));// Return the result as the output
return result; -
Need more information? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
@Ide AirTrunk glad you figured this out. was going to mention you have to return the function in your script body.
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 67.2K Get Help
- 452 Global Discussions
- 155 Industry Talk
- 505 Announcements
- 5.4K Ideas & Feature Requests
- 85 Brandfolder
- 156 Just for fun
- 81 Community Job Board
- 514 Show & Tell
- 34 Member Spotlight
- 2 SmartStories
- 308 Events
- 36 Webinars
- 7.3K Forum Archives