Accessing work flow details in a javascript node | Community
Skip to main content
Ken_Qrious
Level 4
Dec 2, 2021 3:22 AM UTC
Solved

Accessing work flow details in a javascript node

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?

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
david--garcia
david--garciaAccepted solution
Level 10
Dec 2, 2021 5:16 AM UTC

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)

5 replies

David_Loyd
Employee
Dec 2, 2021 3:29 PM UTC

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.

 

Translate
david--garcia
david--garciaAccepted solution
Level 10
Dec 2, 2021 5:16 AM UTC

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)

Translate
Ken_Qrious
Level 4
Dec 5, 2021 9:48 PM UTC

@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?

Translate
david--garcia
Level 10
Dec 6, 2021 4:39 AM UTC

You can add the following expression to your query

 

[folder/@fullName]

 

 

Translate