Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Quick Question about Javascript wording in Launch Rules

Swanan_
Level 3
Level 3

Hey Community,

 

I would like to update one of my rules in Adobe Launch which is set with Custom Code.

 

The goal of the rule is to set my eVar8 value (Product Type) according to the value I'm getting in my eVar7.

 

Example :

if eVar7 = "ABC"

Then eVar8 = "ABC.com"

Else eVar8 = "Marketplace".

 

s.products = flatMap(orders, function(order){
    var shippingMethod = order.total.shippingMethod;
    var storeName = order.total.shippingMethodID === "9" ? order.profile.shippingAddress.name : "Autre livraison";
    return order.item.map(function(item){
      var availabilityID = item.attributes.availabilityID || "0";
      var attributes = item.attributes;
      var isMarketplace = attributes.sellerName === "ABC";
      var isDigital = attributes.nature === "digital";
      var prid = _satellite.getVar("Adobe Analytics - Helper - Product Identifier", item);
      var quantity = item.quantity || 1;
      
      return [
        // Category
        "",
        // Product name
        prid,
        // Quantity
        quantity,
        // Price
        item.price.priceWithTax * quantity,//total
        // Events
        "",
        // eVars 
        keyValues({
          evar7: attributes.sellerName,
          //evar8: isMarketplace ? "ABC.com" : "Marketplace",
          evar8: (isDigital && isMarketplace) ? "Dematerialise" : (isMarketplace ? "ABC.com" : "Marketplace"),
          evar9: Number(attributes.condition === "new"),
          evar23: storeName,
          evar24: shippingMethod,
        }),
      ].join(";");
    });
  }).join();

 

 

As you can see above, the var isMarketplace is set with the following method :

 

var isMarketplace = attributes.sellerName === "ABC";

 

 

All the code above has been implemented by another developer.

I would like to get your help to understand a bit more what means the var declaration isMarketplace ? I don't get how the value is set as we have the following code in the declaration.

 

attributes.sellerName === "ABC";

 

 

My final goal is to update my code as the following :

if eVar7 = "ABC" || "ClickAndCollectOnly",

Then eVar8 = "ABC.com"

Else eVar8 = "Marketplace".

 

I'm not sure if I need to modify the declaration of var isMarketplace line or if I need to modify the ternary operator present in the keyValues Object for eVar8

 

Thanks a lot for your help

1 Accepted Solution
amgup
Correct answer by
Level 7
Level 7

@Swanan_ 
Change to :- 

var isMarketplace = attributes.sellerName === "ABC" || attributes.sellerName==="ClickAndCollectOnly"; 

View solution in original post

6 Replies
amgup
Level 7
Level 7

@Swanan_ 

var isMarketplace = attributes.sellerName === "ABC";

 

Here, this variable isMarketplace will contain the boolean value. If attributes.sellerName is exactly "ABC" than true and the same will be assigned to the var isMarketplace. You may want to modify the implementation accordingly.


Swanan_
Level 3
Level 3

Hi @amgup,

 

Thanks a lot for your feedback.

So if I understand correctly your answer, I can modify the declaration from this:

 

var isMarketplace = attributes.sellerName === "ABC";

 

 

To this 

var isMarketplace = attributes.sellerName === "ABC" || "ClickAndCollectOnly";

And so now it should return true if the value is ABC or ClickAndCollectOnly, right ?

 

Thanks again for your help

 

amgup
Correct answer by
Level 7
Level 7

@Swanan_ 
Change to :- 

var isMarketplace = attributes.sellerName === "ABC" || attributes.sellerName==="ClickAndCollectOnly"; 

View solution in original post

Swanan_
Level 3
Level 3

@amgup 

I'll try it and let you know the result.

 

Thanks a lot for your help here

amgup
Level 7
Level 7

@Swanan_  Did the solution helped you ? If yes than can you please make the answer as correct ? If not than please let us know what error you are facing ?

Swanan_
Level 3
Level 3

Hi @amgup 

 

I didn't have time to try it yet. But I'll update this post in anycase once it's tested 😁

Swanan_
Level 3
Level 3

Hi @amgup 

 

The solution shared is working perfectly !

 

Thank you very much for your help !