Retrieve Component "ID" From Workflow?

Is there a way for me to retrieve the #ID of a component from the local workflow for me to use in a folder path? I would like the component to be able to self identify its own #ID build a unique path for generated log files.

Hi @iCFO

Would this be a starting point?

Unfortunately it is a bit more complicated than that because the same component can be used multiple times per workflow, so I really need to get to the ID level.

I did find that the “Timer Info” node outputs the Node IDs, so I am going to try to use that to search the local workflow folder and then locate the component parent folder.

1 Like

I was able to have components self locate their folder within the workflow using the “Timer Info” node to generate the node IDs. The trick is that the component needs to be saved into the workflow in order for this approach to work on the initial execution of the node. I used the Save Workflow node followed by a 1 second delay to ensure that the component folder exists before the search.

Essentially the trick is to use the “Extract Context Properties” to get the absolute path of the workflow folder (context.workflow.absolute-path), then split the Node ID via Cell Splitter or Regex to grab the second part of the node ID (to find the component ID in the main workflow), then use column expressions to turn it into a regex search (example - .*#16487.) Then use the List Files / Folders node using the workflow folder path variable to find the main folder (using list folder setting), then I used the Component ID variable as the flow variable folders_name_expression to find the specific parent component folder. After that I was able to create a log file folder directory and create / use a component specific logfile.

2 Likes

For future reference of those wishing to nest log files within the components folders… It is best to avoid doing this because updates to those components will remove and replace those log files.

Instead I have settled on creating a log file folder in the main workflow folder with the component IDs incorporated into subfolder file names for each component. Neither approach is perfect. If a component is nested within another component or metanode it will change the component ID. However the prior log files remain intact under the old address, so a manual copy and paste of the logfiles to the new component ID folder allows for recovery of settings.

Hopefully we get the ability to write to the “Table Creator” node as well as manually enter. That would be a much cleaner solution to log integration.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.