cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Backoffice label tag if statement

former_member923461
Discoverer
0 Kudos
393

Hello! I am facing an issue with my if statement in label tag. I am also new in SAP

If "promotedProduct" , "promotedLeasingCode" and "promotedLeasingPlan" are null, I display "@labelService.getObjectLabel(promotion)". If "promotedProduct" exists, I show its code, if "promotedLeasingCode", I show it, if "promotedLeasingPlan" exists I am showing its code.

Right now when exists value "promotedProduct", in backoffice I see wrong. See in the picture. But I need to see promotedProduct.code there. Can you help me with this?

<context type="PromotionBenefit" component="base">
 <y:base>
  <y:labels>
   <y:label>((promotedProduct != null ? promotedProduct.code + ", ": "")
    + (promotedLeasingCode != null ? promotedLeasingCode + ", ": "")
    + (promotedLeasingPlan != null ? promotedLeasingPlan.code + ", ": "")) == "" ?
    @labelService.getObjectLabel(promotion) : ""
   </y:label>
  </y:labels>
 </y:base>
</context>

Accepted Solutions (1)

Accepted Solutions (1)

former_member923461
Discoverer
0 Kudos

I added like this and is working as I expect

(promotedProduct == null AND promotedLeasingCode == null AND promotedLeasingPlan == null ? @labelService.getObjectLabel(promotion) : "")
					+ (promotedProduct != null ? promotedProduct.code + ", ": "")
					+ (promotedLeasingCode != null ? promotedLeasingCode + ", ": "")
					+ (promotedLeasingPlan != null ? promotedLeasingPlan.code + ", ": "")

Answers (1)

Answers (1)

former_member632827
Participant
0 Kudos

Hey,

Looks like your rendered syntax was wrong. You can try like below

(promotedProduct != null ? promotedProduct.code + ',' : '')
+ (promotedProduct != null && promotedLeasingCode != null ? promotedLeasingCode + ' ,': '') + (promotedProduct != null && promotedLeasingPlan != null ? promotedLeasingPlan.code + ' ,': '') + (promotedProduct == null ? @labelService.getObjectLabel(promotion): '')
former_member923461
Discoverer
0 Kudos

If promotedProduct exists, label renders nicely but for other values it's still ugly.