- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 09:07 AM
Hello all,
I have created a flow with if statement and I got stuck on the condition.
Here are the condition:
- If user last login is more than 6 months
- If user last login is within 6 months
In flow designer, OOB has only After or Before but not Relative.
I would appreciate your help.
Regards,
Hong
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 08:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 05:32 AM
Hi @hongsok ,
Please find the Custom Flow Action Script along with screenshots below. This action takes User record as input and returns "true" if the user logged in in last six months other wise returns "false". If the user is never logged in it returns "never".
Step 1: Create a custom action
Step 2: Create inputs for the custom Action:
Step 3: Create Script Step
(function execute(inputs, outputs) {
var sixMonthsBack = new GlideDateTime();
sixMonthsBack.addMonths(-6);
var last_login = inputs.last_login + '';
if(last_login == 'null'){
outputs.login_duration = 'never';
}else{
var lastLoginGDT = new GlideDateTime(last_login);
if(lastLoginGDT > sixMonthsBack){
outputs.login_duration = 'true';
}else{
outputs.login_duration = 'false';
}
}
})(inputs, outputs);
Step 4 : Create the outputs and map
- Create Output variable
- Map script output to Action Output variable
Anvesh