Flow Designer - If statement condition

hongsok
Tera Contributor

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.

 

hongsok_0-1692720283888.png

I would appreciate your help.

 

Regards,

Hong

 

1 ACCEPTED SOLUTION

@hongsok Didn't have any handy.

 

I'll try one and let you know.

Thanks,
Anvesh

View solution in original post

5 REPLIES 5

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

AnveshKumarM_0-1692879894265.png

 

Step 2: Create inputs for the custom Action:

 

AnveshKumarM_1-1692879968444.png

 

Step 3: Create Script Step

 

AnveshKumarM_3-1692880050627.png

 

AnveshKumarM_4-1692880079629.png

(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);

 

AnveshKumarM_5-1692880107808.png

 

Step 4 : Create the outputs and map

 - Create Output variable

AnveshKumarM_8-1692880212336.png

- Map script output to Action Output variable

 

AnveshKumarM_7-1692880173384.png

 

 

 

 

 

 

Thanks,
Anvesh