How to access ctx value in Javascript code workflow | Community
Skip to main content
February 27, 2024
Solved

How to access ctx value in Javascript code workflow

  • February 27, 2024
  • 2 replies
  • 1538 views

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,

 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by AkshayAnand

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


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

2 replies

Manoj_Kumar
Community Advisor
Community Advisor
February 28, 2024

Hello @riyama 

 

I am assuming you are working with webApp.

 

The code to get adminSystem is

ctx.vars.adminSystem
Manoj  | https://themartech.pro
RiyaMaAuthor
February 28, 2024

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

Adobe Employee
February 28, 2024

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.

Sukrity_Wadhwa
Community Manager
Community Manager
April 17, 2024

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