Skip to main content
Legacy User
January 20, 2023
Solved

How do you update a variable value with the current value of an attribute?

  • January 20, 2023
  • 5 replies
  • 460 views

I know how to update attributes with variables, but I can't figure out the reverse. End users update attributes during the course of the workflow, and I need those to update the associated variable in the workflow.

Best answer by Community Expert

Hello ,

That is less intuitive than I wished for (sic!) but technically possible.

Every time you need to read a file's attribute you must use the Find Document step: the step will return the document AND all attributes into a tidy XML. Extracting the value from that XML is then a piece of cake.

Again, I wish there was a more immediate step that does that! :)

Regards,

Carlo

5 replies

Docusign Employee
January 23, 2023

Hello ,

That is less intuitive than I wished for (sic!) but technically possible.

Every time you need to read a file's attribute you must use the Find Document step: the step will return the document AND all attributes into a tidy XML. Extracting the value from that XML is then a piece of cake.

Again, I wish there was a more immediate step that does that! :)

Regards,

Carlo

Legacy User
January 23, 2023

Carlo to the rescue again! Many thanks!

Legacy User
April 27, 2023

 this has been a very helpful thread, as I had the exact same use case. I do want to add, for a non-programmer, getting the attrib out of the XML is not exactly a piece of cake!

First, it's necessary to use a C# expression to return the value of the attrib from the XML. Second, the C# code builder doesn't have the Attribs portion of the XML hierarchy in the autofind feature. So its no so easy. I had to execute the workflow, grab the XML from the Activity trace, put it in a web XML Viewer, and parse through the XML hierarchy to know what is the name of the XML field I am trying to get.

The expression I ended up with is GetVariableValue("TempDoc.Documents.Document.MetadataSOW.VendorContactEmail") , where TempDoc is the name of the variable I created to store the results from my Find Document step, MetadataSOW is the name of my Metadata / Attrib Group, and VendorContactEmail is the name of my Attrib, with spaces removed.

I hope that helps the next person who needs to solve this problem!

Legacy User
April 28, 2023

 

This is correct.

Another way is to use the step Evaluate XPATH to extract the value from a specific sub-node of an XML.

Returning back to @Whitney Nalle​ use case (but it can be applied to any XML use cases), the result of the FInd step is an XML containing information about the document found + all its attributes.

Evaluate XPATH step, takes as input an XML and an XPath expression and returns as output the value of the Xpath expression. We can save that value into a WF Variable directly from the Evaluate XPath step.

Find Document-> XML

XML = <Document stuff><Document attributes>

Evaluate Xpath-> XML and //Document attributes -> sub XML containing only Document Attributes (we can save this into a WF variable)

Evaluate Xpath-> XML and //Document attributes/attributegroup/attribute -> value of the attribute (we can save this into a WF variable)

Justin Jiang
Established Contributor
Established Contributor
April 25, 2024

Very cool

Welcome to the DocuSign Community and University! Your feedback is immensely appreciated. If this answer resolves your issue, please feel free to give it a Like and mark it as the "Best Answer". This helps others in the community find the information they need. Visit us at http://dsucustomers.docusign.com for more resources and support.