내 커뮤니티 업적 표시줄을 확대합니다.

Get ready! An upgraded Experience League Community experience is coming in January.
해결됨

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,

 
주제

토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.

1 채택된 해결책 개

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

원본 게시물의 솔루션 보기

6 답변 개

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