Saltar al contenido principal

Búsqueda

Búsqueda

How to Convert BTXML to Variables in an Action?

Comentarios

4 comentarios

  • Comentario oficial
    Avatar
    Gene Henson
    Comentario oficial

    There's no easy way to grab substring values from the XML file, yet. However, there's a relatively easy workaround using PowerShell.

    The basic premise is that you'll:

    1. Create an variable in the integration to store the email address (I called it email_address.)
    2. Use Powershell to parse the "Event Data" (which is your initial XML script) to find the email_address Substring
    3. Store that value in the email_address variable
    4. Use that variable in the Send email action

    I tested this using the XML file provided above. The below script will work:

    [xml] $xml = '%EventData%'
    $match = $xml.XMLScript.Command.FormatSetup | % {$_.NamedSubstring} | ? {$_.Name -match 'email_address'}
    $match.Value

    Line 1:

    [xml] $xml = '%EventData%'

    This creates a variable ($xml) of XML type and assigns it the value of the EventData variable. Please note the ' around %EventData%. This is sets the input to String type, which is what Powershell needs.

    Line 2:

    $match = $xml.XMLScript.Command.FormatSetup | % {$_.NamedSubstring} | ? {$_.Name -match 'email_address'}

    Here we create a variable to hold the matched data and call it $match. We use dot notation to read down the XML path into the FormatSetup node. Once there, we use '%' to loop through the NamedSubstrings and use '?' to find the Substri

    ng named 'email_address'.

    Line 3:

    $match.Value

    We output the value of the $match variable. This is important because the output of the Powershell script will be assigned to a variable, so we only want the actual value.

    See the below screenshot for how I've set this up:

    Hopefully that makes sense and works for you!

  • Avatar
    Matt Dolnik

    Did you ever find a solution for this?

     

    Edit: The solution from Gene Henson works. A little annoying how one has to jump through these hoops, but it works! Thanks for the very descriptive response.

    0
  • Avatar
    Dwight McWilliams

    No I did not. I came up with a clumsy workaround. Do you know of a solution that I could use to implement my original idea?

    0
  • Avatar
    Matt Dolnik

    Yes as I mentioned above, the solution from Gene Henson works for this purpose

    0

Iniciar sesión para dejar un comentario.