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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Debugging Adobe Campaign Javascript

akshayk23775697
Level 2
Level 2

Being new to Campaign I am having trouble debugging JS code In Campaign..

I have a general question on the debugging aspect of the Code ( javascript )

  1. How to see the XML that is being returned . I tried doing logInfo( response ) in the below code, but nothing is shown

var query = xtk.queryDef.create( 
  <queryDef schema="nms:recipient" operation="get">   
    <select>     
      <node expr="@firstName"/>     
      <node expr="@lastName"/>     
      <node expr="@email"/>   
    </select>       
  </queryDef>)

var response = query.ExecuteQuery()
lofInfo( response.recipient ); =>  shows nothing

2. What are the tips/guidelines  for debugging the javascirpt code  in Campaign ?  how do the experts do it   🙂

cheers

akshay

1 Accepted Solution
Jyoti_Y
Correct answer by
Community Advisor
Community Advisor

Hi,

Use below syntax:

var query = xtk.queryDef.create(
  <queryDef schema="nms:recipient" operation="get">  
    <select>    
      <node expr="@firstName"/>    
      <node expr="@lastName"/>    
      <node expr="@email"/>  
    </select>      
  </queryDef>)

var response = query.ExecuteQuery()

logInfo("response: "+ response.toXMLString());

Also if your output has more than one row then use for each loop.

for each( var res in response){

logInfo("response: "+ response.toXMLString());

}

Thanks.

View solution in original post

4 Replies
Raj_bounteous
Community Advisor
Community Advisor

hi,

logInfo( response.@firstName) will give log or for that matter any attribute you used in select node

2. What are the tips/guidelines for debugging the javascript code in the Campaign ?  how do the experts do it   🙂

use external debugger tools for the syntax and campaign does not have Linting to identify potential errors

Jyoti_Y
Correct answer by
Community Advisor
Community Advisor

Hi,

Use below syntax:

var query = xtk.queryDef.create(
  <queryDef schema="nms:recipient" operation="get">  
    <select>    
      <node expr="@firstName"/>    
      <node expr="@lastName"/>    
      <node expr="@email"/>  
    </select>      
  </queryDef>)

var response = query.ExecuteQuery()

logInfo("response: "+ response.toXMLString());

Also if your output has more than one row then use for each loop.

for each( var res in response){

logInfo("response: "+ response.toXMLString());

}

Thanks.

View solution in original post

MarcelSzimonisz
Community Advisor
Community Advisor

Hello,

You need to display res.toXMLString()  instead of response or directly res.@firstName res.@lastName or res.@email

Marcel

akshayk23775697
Level 2
Level 2

thanks a lot @jyotij .. I owe you a beer