Leiste mit Community-Erfolgen erweitern.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.

GELÖST

JavaScript with OR statement syntax

Avatar

Level 2

I am trying to setup some code that will look at a value in one field, and based on the result it finds determine what translated. I can get this to work when I have a single entry (for example "AB"), but when I try to expand this with an OR statement I no longer can get it work. It seems to just take the first entry, and stop there. I have tried different variations, and I have not been able to get it to go. I also tried to options with Formcalc. Does anyone happen to know what is incorrect in the syntax. If you have another suggestion with Formcalc I am OK with that as well.

 

if ( $record.PAGE.FIELD.value == "AB" || "CD" || "EF" || "GH" || "IJ")

        {

        this.rawValue = (data.PRINTLANG.rawValue == "EN") ? "Product" : "Produkt";              

        }else{

        this.rawValue = (data.PRINTLANG.rawValue == "EN") ? "Service" : "Dienstleistung";

        }

Thanks,

Andrew

1 Akzeptierte Lösung

Avatar

Korrekte Antwort von
Level 7

I would modify to be:

if ($record.PAGE.FIELD.value == "AB" || $record.PAGE.FIELD.value == "CD" || $record.PAGE.FIELD.value == "EF" || $record.PAGE.FIELD.value == "GH" || $record.PAGE.FIELD.value == "IJ")

You could simplify it to be:

var a = $record.PAGE.FIELD.value

if (a == "AB" || a == "CD" || a == "EF" || a == "GH" || a == "IJ"){

Lösung in ursprünglichem Beitrag anzeigen

2 Antworten

Avatar

Korrekte Antwort von
Level 7

I would modify to be:

if ($record.PAGE.FIELD.value == "AB" || $record.PAGE.FIELD.value == "CD" || $record.PAGE.FIELD.value == "EF" || $record.PAGE.FIELD.value == "GH" || $record.PAGE.FIELD.value == "IJ")

You could simplify it to be:

var a = $record.PAGE.FIELD.value

if (a == "AB" || a == "CD" || a == "EF" || a == "GH" || a == "IJ"){

Avatar

Level 2

I used your formatting, and adjusted the first line of my code to the following,

if (( $record.PAGE.FIELD.value == "AB") || ($record.PAGE.FIELD.value "CD") ||

($record.PAGE.FIELD.value "EF") || ($record.PAGE.FIELD.value "GH") || ($record.PAGE.FIELD.value "IJ"))

This made it work. I appreciate the help.