Developer forum

Forum » PIM » Concat with If Statement

Concat with If Statement

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

I have a concat field as such

{Product_MSRP} per {Product_UoMForMSRP}

 

  • Product_MSRP is an int field
  • Product_UoMForMSRP is a string

 

The problem we're having is that when "Product_MSRP" is empty, this is the result if the fields are empty (notice the "0 per")

Image

 

Is there a way I can control this in the concat field to to not render anything if the field is null or empty or some value (i.e. 0)?

 

Best Regards,

Nuno Aguiar


Replies

 
Michael Knudsen
Reply

Hello Nuno,

- currently you can't 'conditionally' control if a field in a concat should be shown or not, but you can use the brackets [] around a field to include some additionel text, if the field is null or empty eg. 

[{Product_MSRP} per ]{Product_UoMForMSRP}

If Product_MSRP is null or empty, the result should be: Product_UoMForMSRP

However, it could be handy, if you could write something like: {{Product_MSRP} > 0; {Product_MSRP}; ""}

Br. Michael Knudsen

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Michael,

 

I was excited to see a potential solution with the square breackets, but it does not work as expected as far as I can tell.

 

Here's what I am seeing https://www.screencast.com/t/xeLUzAae02. It seems like a bug though, that it does not process the placeholders outside of the square brackets.

 

Best Regards,

Nuno Aguiar

 
Søren Jensen Dynamicweb Employee
Søren Jensen
Reply

Hi Nuno,

Look at my two examples below ..

 

Example-1: 

<ul>
[<li><b>Brand</b>: {brand}</li>]
[<li><b>Material</b>: {material}</li>]
[<li><b>Weight</b>: {ProductWeight}</li>]
[<li><b>Season</b>: {Season}</li>]
</ul>

Example-2: 

Product price:  [<b>{ProductPrice}</b><BR />]
Product Listbox: [<b>{Color}</b><BR />]
ProductVariantId: [<b>{ProductVariantId}</b><BR />]
ProductLanguageId: [<b>{ProductLanguageId}</b><BR />]
Number of gear:  [<b>{ProductCategory|equipment|Gear}</b><BR />]
[<b>Field1</b>{ProductCategory|equipment|Gear} <BR />]
[<b>Field2</b>{ProductCategory|equipment|Frame} <BR />]
[<b>Field3</b>{ProductCategory|equipment|Fork} <BR />]

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Soren,

 

I see, so it just looks like we cannot use placeholders outside of the square brackets in the same line (which is what I was trying to do.

 

I guess that for my need, I really have to customize, since I need to display 2 values in the same line, depending if one is empty or bigger than 0

 

Best Regards,

Nuno Aguiar

 
Søren Jensen Dynamicweb Employee
Søren Jensen
Reply

Hi Nuno,

We do only check for, if the Field are empty, and then remove the content inside these brackets "[ ... ]"

Please make a Feature request, if we should extend it with somthing like "if ... then ... else ..."

/Søren

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Sounds good Soren.

Done https://doc.dynamicweb.com/forum?ThreadID=84487&PID=1605

 

You must be logged in to post in the forum