How to add property in IF Condition?

sruthig
Tera Expert

How to add property in IF Condition?

I have tried below and not working.

var days = gs.getProperty('Property_name');

var today = new GlideDate();

today = today.getByFormat("MM-dd-yyyy");
var due_date = current.due_date;
var duration = GlideDateTime.subtract(new GlideDateTime(due_date), new GlideDateTime(today));

if (duration.getDayPart() > days && (gs.getProperty('propert_name1) != 'true')){
current.setValue('state', 'canceled');
} else {
current.setAbortAction(true);
}

Please let me know syntax which i used is correct or not?

Regards,

Sruthi

 

16 REPLIES 16

Sukraj Raikhraj
Kilo Sage

Using Ankur code,

1) why not declaring another variable for propert_name1? var name1 = ....

2) I would log the value of propert_name1 to validate what values to check for.

 

Regards,

Hi Sukraj,

Can you please modify the above business rule and share here.

I have tried the above code and not working. I'm storing 4 metric type sys ID's in the value field of the property which is mentioned in the If condition "property_name1".

Business Rule Condition

state changes to Cancelled

Condition 1

Actually My requirement is the state should not change to cancel for the metric type which is mentioned in the property_name1 if the condition duration.getDayPart() > days is true also.(abort action)

Condition 2

If Metric Type is other than this 4 metric type which is mentioned in the property (property_name1) and duration.getDayPart() > days is true then state should change to cancel.

Condition 3

If Metric Type is other than this 4 metric type which is mentioned in the property (property_name1) and duration.getDayPart() > days is false then state should not change to cancel(abort action)