Expand my Community achievements bar.

SOLVED

Accessing work flow details in a javascript node

Avatar

Level 4

I would like to set up a generic process to retrieve specific information about a workflow via a java script node? 

 

The specific information I would like to retrieve are :

1) Workflow name

2) Workflow path, for example for a technical work flow => administration/production/technical workflows/Work Flow Folder Name

 

Is there a list of workflow variables that are automatically set which can be retrieved?

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You can use queryDef to fetch workflow details

 

var query = NLWS.xtkQueryDef.create(
  {queryDef: {schema: "xtk:workflow", operation: "select", 
    select: {
        node: [{expr: "@id"},
               {expr: "@label"},
               {expr: "@internalName"}] 
    }, 
    where: {
      condition: [{expr: "[folder/@name]='nmsTechnicalWorkflow'"},
                  {expr: "@production = 1"}]
    }, 
    orderBy: {
      node: {expr: "@internalName", sortDesc: "false"}
    }
  }})

var res = query.ExecuteQuery()

var workflows = res.getElementsByTagName("workflow")
for each (var w in workflows)
  logInfo(w.getAttribute("internalName"))
        

 (https://experienceleague.adobe.com/developer/campaign-api/api/sm-queryDef-ExecuteQuery.html)

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

You can use queryDef to fetch workflow details

 

var query = NLWS.xtkQueryDef.create(
  {queryDef: {schema: "xtk:workflow", operation: "select", 
    select: {
        node: [{expr: "@id"},
               {expr: "@label"},
               {expr: "@internalName"}] 
    }, 
    where: {
      condition: [{expr: "[folder/@name]='nmsTechnicalWorkflow'"},
                  {expr: "@production = 1"}]
    }, 
    orderBy: {
      node: {expr: "@internalName", sortDesc: "false"}
    }
  }})

var res = query.ExecuteQuery()

var workflows = res.getElementsByTagName("workflow")
for each (var w in workflows)
  logInfo(w.getAttribute("internalName"))
        

 (https://experienceleague.adobe.com/developer/campaign-api/api/sm-queryDef-ExecuteQuery.html)

Avatar

Level 4

@david--garcia  Thanks, that helps.  I don't see anything related to => Workflow path, for example for a technical work flow => administration/production/technical workflows/Work Flow Folder Name.  Is this information available?

Avatar

Community Advisor

You can add the following expression to your query

 

[folder/@fullName]

 

David__Garcia_0-1638765525526.png

 

Avatar

Employee Advisor

To view "all your options" you can simply check them by right clicking on a workflow (in workflow view) then "configure list" to see all workflow attributes. That will give you an idea of what is available to use in your JS. While you can do this in JS, you can do the same thing in a standard Query if you needed to.

dloyd_0-1638458908222.png