Studio - 'if' function syntax

Hi all,

I'm running into an issue with the 'if' statements on Template Studio that is unintuitive to me. I input the following expression: 

if([LocationDetails.CoordinateDisplay] = 'Lat/Long',

     textStyle('Latitude: ', '700', 'Normal', '000000') + fixed([LocationDetails.LatitudeNumeric], 6, true), '')

When I tried previewing the results of this expression, I noticed that the entirety of the expression does not print if [LocationDetails.LatitudeNumeric] does not contain data. In my head, textStyle('Latitude: ', '700', 'Normal', '000000') should still print Latitude: so long as [LocationDetails.CoordinateDisplay] = 'Lat/Long' even if [LocationDetails.LatitudeNumeric] is empty. 

In the photos attached, you can see that the expression works if I remove [LocationDetails.LatitudeNumeric] from the expression.

  • Hi Martyn, 

    Thanks for your response! 

    Yes, CoordinateDisplay is a custom field. It's just a pick list with two options 1). Lat/Long and 2). Northing/Easting

    I've tried all iterations of the fields by themselves and they work. The issue is only when they're placed in an if statement together, and [LocationDetails.LatitudeNumeric] retrieves an empty cell. 

    I have resolved this issue by nesting if statements, the bug only occurs within the if statement that returns an empty data cell. See below: 

    if([LocationDetails.CoordinateDisplay] = 'Lat/Long',
    textStyle('Latitude: ', '700', 'Normal', '000000') + if(isblank([LocationDetails.Latitude]), '', fixed([LocationDetails.Latitude], 3, true)),
    '')

    Cheers,

    Answer Verified By: Joseph Ang 

  • Hi Joseph,

    Im not familiar with CoordinateDisplay, is that a custom field? 

    You can try breaking it down and make sure each bit works on its own. Try:

    if([LocationDetails.CoordinateDisplay] = 'Lat/Long','T'. 'F')

    If the above doesnt work then the issue will be with the first bit. 

    You can also try these bits as well:

     textStyle('Latitude: ', '700', 'Normal', '000000') 

    and 

    fixed([LocationDetails.LatitudeNumeric], 6, true), '')

    If the fields are valid fields, I think they will work. 

    Martyn