Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!

How to access ctx value in Javascript code workflow

Avatar

Level 1

Hi,

 

I want to access adminSystem parameter in workflow using javaScript code. From value of adminsytem I want to split the templates. 

 

<ctx>
    <customerName>XYZ</customerName>
    <adminSystem>ABC</adminSystem>
</ctx>
 

Thank you in advance.

Best regards,

 
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

6 Replies

Avatar

Community Advisor

Hello @RiyaMa 

 

I am assuming you are working with webApp.

 

The code to get adminSystem is

ctx.vars.adminSystem

     Manoj
     Find me on LinkedIn

Avatar

Level 1

Thanks @Manoj_Kumar_  I am very new to Adobe Campaign  basically have workflow where In JavaScript code I have added below code 

 

var schemaName = vars.targetSchema.substring(vars.targetSchema.indexOf(":") + 1);
logInfo(schemaName);

var collection = <{schemaName + '-collection'} xtkschema={vars.targetSchema}/>
//logInfo("Collection" +collection);

var query = xtk.queryDef.create(
  <queryDef schema= {vars.targetSchema} operation="select" lineCount={vars.recCount}>
    <select>
      <node expr="[target/ctx]" alias="data"  />
      <node expr="@id" />
    </select>
  </queryDef>
)
var res = query.ExecuteQuery();
var result = res.toXMLString()

 I was thinking I will get ctx value from here and then will split templates on basis of ctx value.

 

Thanks,

Shubhada

Avatar

Employee

Hi @RiyaMa ,

 

Can you confirm if the ctx values comes from a query. If so, then you may not need javascript, you can direclty use a split activity to segregate the population based on the query data.

Avatar

Level 1

Not from query, It is coming from api and right now i am triggering from postman. 

Avatar

Community Advisor

Hi @RiyaMa 

 

Could you please log the variables res and result to see the structure.

If I am understanding you structure correctly then, you can access adminSystems by :-

var a = res.data;

var b=a.adminSystems.

 

Regards

Akshay

Avatar

Administrator

Hi @RiyaMa,

Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!



Sukrity Wadhwa