Declaring global variable

Hi,

 

Please help me variablize "name" and "description" as global variable. This XML is a header string (BODY for REST POST method).

 

<securityTag>
<objectTypeName>SecurityTag</objectTypeName>
<type><typeName>SecurityTag</typeName></type>
<name>XYZ</name>
<description>Demo</description>
<extendedAttributes/>
</securityTag>

 

 

Thanks,

Sam

Parents
  • Hi Sam,

     

    Thanks for raising this question! You may use the 'System properties', which are global flow variables with values that never change and can be used in any flow.

    Please refer to the Studio Guide - 'Configuring System Properties' section for more info on this matter.

     

    Let me know if this helps!

     

    Regards,

    Mitko

  • Hi Mitko,

     

    Thanks for the reply. I understand that I will have to declare global variable in system properties however it is an XML header so wondering how can I variablize it. I can variablize a URL but not sure about an attribute of an XML header body.

     

     

    Thanks,

    Sam

  • Hi Sam,

     

    Which operation are you using?

     

    Is this the request or the response header?

     

    If this is the request header you can create a new result for the operation, assign it the value of your input XML header and use an Xpath or XML Get Element Value filter to take out the values that you require.

     

    If this is the response header, again you can filter the response using XML Get Element Value or a XPath Query filter.

     

    If you are using the InvokeMethod2 operation you can simply add a Scriptlet in it and make use of the rawXMLRequest:

     

    scriptletContext.put("rawXML", scriptletRawResult['rawXMLRequest']);

     

    This will add the rawXMLRequest in the Step Context and from there you can easily use a filter on the result and afterwards Set Flow Variable as the next step and grab the actual value.

     

    Best regards,

    Daniel

  •  

    Hi Daniel,

     

    Thanks for the reply. I am running POST RAW operations. I now have attached screenshots for more clarity on my query. I have variablized "nsxMagaer" here, same way I want to variablize "name" and "description" attributes of the xml header below.

     

    <securityTag>
    <objectTypeName>SecurityTag</objectTypeName>
    <type><typeName>SecurityTag</typeName></type>
    <name>XYZ</name>
    <description>Demo</description>
    <extendedAttributes/>
    </securityTag>

     

    Thanks,

    Sam

  • Hi Sam,

     

    In order to extract the name and value from the string input you defined in the operation:

     

    Define a result (call it name) to your operation that takes the value of the string input. For this result, create a filter using XML Get Element Value in order to get the value XYZ. Once you run the operation, it will provide a result called name with value XYZ that can be used further in your operations.

     

    For the next operation, use Assign from variable and select the previously defined result (name).

     

    The same goes for each pair you want to extract.

     

    Hope this helps!

     

    Best regards,
    Daniel

  • Hi Daniel,

     

    I forgot to mention that I would need to insert values for "name" and "description"  everytime I run the flow and thats the reason I want to variablize it. Just the way "nsxManager" will have different ip's everytime I run it.

     

     

    thanks,

    Sam

  • Hi Daniel,

     

    I forgot to mention that I would need to insert values for "name" and "description"  everytime I run the flow and thats the reason I want to variablize it. Just the way "nsxManager" will have different ip's everytime I run it.

     

     

    thanks,

    Sam

  • Verified Answer

    Hi Sam,

     

    You can create 2 inputs either for the operation or for the actual flow (name and description) and define the header as:

     

    <securityTag>
    <objectTypeName>SecurityTag</objectTypeName>
    <type><typeName>SecurityTag</typeName></type>
    <name>${name}</name>
    <description>${description}</description>
    <extendedAttributes/>
    </securityTag>

     

    In this way it will populate the header with the values that you define for your inputs.

     

    Best regards,
    Daniel

  • Hey Daniel,

     

    It works like charm :)

     

    I appreciate your help with my queries. It was nice interacting with you.

     

     

     

     

    Thanks,

    Sam

Reply Children