Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
aaryan sri

# How to write IF condition on String value

Hi All,

Based on condition, value should store on sring. Present formula writtens below way

Presently  totalBusinessDistnece storing value of totalBusinessDistance- 2*totalCommutingMiles.  Now want to be if (totalBusinessDistance- 2*totalCommutingMiles) value comes below 0 then totalBusinessDistance store only 0 other wise it  should store (totalBusinessDistance- 2*totalCommutingMiles).

Amit Chaudhary 8

```totalBusinessDistance = String.valueOf((Decimal)ar.get('totalBusinessDistance')-(2*(Decimal)ar.get('totalCommutingMiles')));
{
}```

aaryan sri
Hi Amit,
As per your code checking totalBusinessDistance < 0 if it's yes making totalBusinessDistance=0 what about if condition false. What is the final value stores into totalBusinessDistance field .
Deepak Gulian
According to current formula totalBusinessDistance storing String value, so in IF condition we can't do comparison with integer
so the formula should be this

Store the output in Integer

if( ttlBusHr < 0 ) {