on 2021 Sep 24 12:11 PM
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>
Request clarification before answering.
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 + ", ": "")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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): '')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.