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

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

vitor_d
Level 2
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
wodnicki
Correct answer by
Community Advisor
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
wodnicki
Correct answer by
Community Advisor
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

vitor_d
Level 2
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");

 

 

wodnicki
Community Advisor
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);

 

vitor_d
Level 2
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?
wodnicki
Community Advisor
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.