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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How to read variable (xml) from workflowEvent

kaushal13
Level 2
Level 2

In workflow event , there xml variable which contains data.

I want to read those data to get some info out of it . How can i parse this data because when i try to check in event schema this variable is not present because data is not stored in data schema.

Thanks,

Kaushalevent_variable_xml.JPG

3 Replies
Marcel_Szimonisz
Community Advisor
Community Advisor

Hello,

You can access them by instance.vars. ...

instance.vars.CELL_OFFSET

Marcel

kaushal13
Level 2
Level 2

Thanks Marcel for pointing how to use it , I guess instance variable in java script ,  can you please help with one example so i can explore further.  Thanks Schema_variables.JPG

Marcel_Szimonisz
Community Advisor
Community Advisor

Hello Kaushal,

You can consider them as global variables which can be used not only by downstreem activities but anywhere in in the wf instance see more below:

JavaScript scripts and templates

How to use an instance variable in a workflow Split activity

PS:

1316122_pastedImage_1.png

1316153_pastedImage_2.png

- you can also pass them from one runtime to another of the same wf

Marcel

kaushal13
Level 2
Level 2

thanks for example. I am able to get the variable accessible in another activity of workflow.  but i can access these variable value if its static or one. how to read variable against the each column below is example:

1. there is variable element (xml) in workflowevent against each activity

2. when i read variable under each values its remain same for each instance.

event_variable_xml.JPG

output i want to retrieve

Event id , Cell_offest

39664368  72057.....

419..., 720....

JavaScript to get the data:

var query = xtk.queryDef.create(

    <queryDef schema={vars.targetSchema} operation="select" distinct = "true">

      <select>

        <node expr="@activity"/>

      </select>

    </queryDef>

  );

  var resul = query.ExecuteQuery();

  for each(var r in resul)

{

       logInfo( "Activity name " + r.@activity + " Schema Name : " + vars.schema);

}

logInfo:

02/10/2017 16:36:31 js Activity name fileExport Schema Name : xtk:workflowEvent

02/10/2017 16:36:31 js Activity name extract2 Schema Name : xtk:workflowEvent

02/10/2017 16:36:31 js Activity name queryEvents Schema Name : xtk:workflowEvent

02/10/2017 16:36:31 js Activity name writer22 Schema Name : xtk:workflowEvent

02/10/2017 16:36:31 js Activity name lock Schema Name : xtk:workflowEvent

02/10/2017 16:36:31 js Activity name extract Schema Name : xtk:workflowEvent

02/10/2017 16:36:31 js Activity name writer2 Schema Name : xtk:workflowEvent

02/10/2017 16:36:31 js Activity name delivery2 Schema Name : xtk:workflowEvent

02/10/2017 16:36:31 js Activity name schedule Schema Name : xtk:workflowEvent

02/10/2017 16:36:31 js Activity name query Schema Name : xtk:workflowEvent

02/10/2017 16:36:31 js Activity name start Schema Name : xtk:workflowEvent

if changing to  instance.vars.schema, all data appears as null

02/10/2017 16:41:32 js Activity name start4 Schema Name : undefined

02/10/2017 16:41:32 js Activity name fileExport Schema Name : undefined

02/10/2017 16:41:32 js Activity name extract2 Schema Name : undefined

02/10/2017 16:41:32 js Activity name queryEvents Schema Name : undefined

02/10/2017 16:41:32 js Activity name writer22 Schema Name : undefined

02/10/2017 16:41:32 js Activity name lock Schema Name : undefined

02/10/2017 16:41:32 js Activity name extract Schema Name : undefined

02/10/2017 16:41:32 js Activity name writer2 Schema Name : undefined

02/10/2017 16:41:32 js Activity name delivery2 Schema Name : undefined

02/10/2017 16:41:32 js Activity name schedule Schema Name : undefined

02/10/2017 16:41:32 js Activity name query Schema Name : undefined

02/10/2017 16:41:32 js Activity name start Schema Name : undefined

02/10/2017 16:41:32 js Activity name signal Schema Name : undefined

Marcel_Szimonisz
Community Advisor
Community Advisor

Hello Kaushal,

-why you need to use xtkQuerDef? You can access current workflow instance, event,task ... variables by eg typing instance.vars.CELL_OFFSET... what ever is created by developer or by any activity, event automatically.

-why targetSchema is undefined? because i presume your only activity in wf is javascript activity you need to have any of query activities

--> read group, query, rdbms, file import ... to have this variable initialized in vars.tergetSchema

1316647_pastedImage_0.png

1316742_pastedImage_2.png

1316741_pastedImage_1.png

Without query activity you get undefined

1316743_pastedImage_3.png

1316744_pastedImage_4.png

PS:

Bytheway you have helped me too. Where have you found vars.targetingSchema I was looking for variable that holds temp table schema name and had to get this information differently

Marcel

Marcel_Szimonisz
Community Advisor
Community Advisor

just found out query does not initialize the vars.targetSchema.. so far readGroup it is doing and enrichment that i have used and they work