- Marketing Nation
- :
- Products
- :
- Product Discussions
- :
- Velocity - Display specific value

Your Achievements

Next /

Sign inSign in to Community to gain points, level up, and earn exciting badges like the new Applaud 5 BadgeLearn more!

View All BadgesSign in to view all badges
SOLVED
#
Velocity - Display specific value

Go to solution

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

02-26-2020
10:24 AM

02-26-2020
10:24 AM

So I have this code:

```
#if( $lead.autoPreApprovalNewRate.toString().equals("") )
#set( $lead.autoPreApprovalNewRate = 0 )
$number.number( $math.sub($lead.autoPreApprovalNewRate, "1") )
#end
```

And when there is a value in the

`$lead.autoPreApprovalNewRate`

field, this works beautifully. The problem is if they don't have a value, the programing makes sure it's a 0, and the subtraction turns it into -1. I'm sure there is just another #if #else... I'm just not able to figure it out.

Thanks.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

02-26-2020
11:10 AM

02-26-2020
11:10 AM

Lot of confusing stuff here, and it’s just a few lines of code. 🙂

- autoPreApprovalNewRate must already be an empty String, so it doesn’t need toString()
- it can’t really be working beautifully, because everything is wrapped in the same condition
- the second argument to $math.sub should be a Number, you’re just lucky that it’s converting the constant “1" to 1
- $math.sub already converts the result to a Number instance

If your requirement is

*if*autoPreApprovalNewRate is the empty string, set the effective rate to 0*else*set the effective rate to (autoPreApprovalNewRate - 1)

then that's

```
#if( $lead.autoPreApprovalNewRate.equals("") )
#set( $outputRate = 0 )
#else
#set( $outputRate = $math.sub($lead.autoPreApprovalNewRate, 1) )
#end
${outputRate}
```

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

02-26-2020
11:10 AM

02-26-2020
11:10 AM

Lot of confusing stuff here, and it’s just a few lines of code. 🙂

- autoPreApprovalNewRate must already be an empty String, so it doesn’t need toString()
- it can’t really be working beautifully, because everything is wrapped in the same condition
- the second argument to $math.sub should be a Number, you’re just lucky that it’s converting the constant “1" to 1
- $math.sub already converts the result to a Number instance

If your requirement is

*if*autoPreApprovalNewRate is the empty string, set the effective rate to 0*else*set the effective rate to (autoPreApprovalNewRate - 1)

then that's

```
#if( $lead.autoPreApprovalNewRate.equals("") )
#set( $outputRate = 0 )
#else
#set( $outputRate = $math.sub($lead.autoPreApprovalNewRate, 1) )
#end
${outputRate}
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

02-27-2020
08:57 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

03-02-2020
09:52 AM

03-02-2020
09:52 AM

Re: Velocity - Display specific value

Thanks for your help. Sorry for the delayed response. I didn't get the notification that you had tagged me.