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

Switching from Div id

Avatar

Level 2

Hi all, 

 

I am trying to create a script in Campaign that will let me switch from one div id to another based on the language the recipient picked. The languages are English or French. I have a script I create below but now my page is blank. 

 

<script>
  
  var query = xtk.queryDef.create(

  <queryDef schema="nms:recipient" operation="getIfExists">
  
  <select>
  
  <node expr="@language"/>
  
  </select>
  
  </queryDef>
  
  var language=@language
  var english=document.getElementById("engThanks")
  var french=document.getElementById("frThanks")



  if(language == ENG){
  english.style.display = "block";

  }else ){
  english.style.display = "none";
  french.style.display = "block";

}
  
  
  
  
  
  </script>

 

 

 

 

2 Replies

Avatar

Level 2

Hello,

 

Please check following points.

 

  1. Can you first check what is the value of language enumeration? In my case, it is like below.

             Go to Platform -> Enumeration.

 

               Parvesh_Parmar_0-1651656918719.png

 

 

2. If you want to check only for one recipient then you need to give some condition in the queryDef. In the below example I added Id.

 

                var query = xtk.queryDef.create(

                                            <queryDef schema="nms:recipient" operation="getIfExists">

                                                  <select>

                                                             <node expr="@language"/>

                                                   </select>

                                                           <where>

                                                                 <condition expr="@id = 1" />

                                                             </where>

                                                           </queryDef>

 

  // Run the query.

   var res = query.ExecuteQuery();

                                 

     if ( res.@language =='E' )

     {

    

                 // Add code to show english div

    

     }

       else {

      

       // Add the code to show French div

      

       }

 

 

Thanks.

Parvesh.

 

Avatar

Administrator

Hi @StrawHatM23,

Was the given solution helpful to resolve your query or do you still need more help here? Do let us know.

Thanks!