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

Is it possible to find out what is the filtering dimension on Javascript Code?

Avatar

Level 2

I noticed that vars.schema returns the targeting dimension name on Javascript Code, but I would like to know if it is possible to find out which is the Filtering Dimension on Javascript Code. Thank you!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

 

It's not stored to vars, no.

Crude approach is to search the workflow's xml, looking for query transition target = your activity, then retrieve [query/where/@filteringSchema] from it.

This can be done in 1 line using E4X filtering, doc here:

 

Thanks,

-Jon

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Hi,

 

It's not stored to vars, no.

Crude approach is to search the workflow's xml, looking for query transition target = your activity, then retrieve [query/where/@filteringSchema] from it.

This can be done in 1 line using E4X filtering, doc here:

 

Thanks,

-Jon

Avatar

Level 2

Thank you! I will try that! One final question, how do I get the workflow's XML in javascript?

 

I wrote down the following code to test some filtering, but it didn't work:

 

 

var test = instance.activities.jumpout.(@name == "jumpout");

 

 

Avatar

Community Advisor

Nah it's not going to work, instance is 'wppObject' not XML. Have to do it the hard way:

 

function getPriorActivityByType(activityType) {
  for each (var priorActivity in instance.activities[activityType]) {
    for each (var transition in priorActivity.transitions) {
      if (transition.target === activity.name) return priorActivity;
    }
  }
}

var priorActivity = getPriorActivityByType('query');
if (priorActivity) logInfo(priorActivity.schema);

 

Avatar

Level 2
Amazing, thank you! I will try this approach. One last curiosity: so it is not possible to get the XML of the workflow? It gets mapped to WppObject?

Avatar

Community Advisor
There's xtk.workflow.get(instance.id), which also returns wppObject. Would have to use queryDef or sqlGetString for the data clob (or specifically [activities/query] for queryDef) and run it through new XML(). Cheaper to iterate over the wppObject in hand.