If
The If action is used to add conditions.
Here's a sample code snippet that uses the If action chain and follows this logic: if the user ID contains '007', get the user's location; otherwise, show an error notification.
define([
'vb/action/actionChain',
'vb/action/actions',
'vb/action/actionUtils',
], (
ActionChain,
Actions,
ActionUtils
) => {
'use strict';
class test extends ActionChain {
/**
* @param {Object} context
*/
async run(context) {
const { $flow, $application, $constants, $variables } = context;
if (($application.user.userId.includes('007'))) {
const location = await Actions.geolocation(context, {
});
} else if ((!$application.user.userId.includes('007'))) {
await Actions.fireNotificationEvent(context, {
summary: 'error',
});
}
}
}
return test;
});