4 Replies Latest reply on Jun 9, 2014 10:23 AM by Volker Scheithauer

    For loop configuration

      Hi All,

       

      I have a requirement to restart windows services . The values are passed as comma separated, So I need to fetch each and every service and restart it. How to configure this in BAO using for activity. Can we configure this through simple XML file? Help me on this.

       

      Thanks

      Praveen

        • 1. Re: For loop configuration
          Matthew Highcove

          The For activity cannot accept comma-separated values. It needs an XML structure. You can use the workflow AutoPilot-OA-Common_Utilities:Tokenize String to convert a comma-delimited list like this:

           

          MyServer1,MyServer2,MyServer4

           

          into XML like this:

           

          <tokens>

            <token>MyServer1</token>

            <token>MyServer2</token>

            <token>MyServer4</token>

          </tokens>

           

          Provide your list as the input to your For activity with the transform "//token".

          2 of 2 people found this helpful
          • 2. Re: For loop configuration

            Hi Matt,

             

            Thanks for the response. you said "Provide your list as the input to your For activity with the transform "//token". I am not familiar with for loop ? can you please explain clearly with example if possible?

            • 3. Re: For loop configuration
              Matthew Highcove

              A For activity is an activity in Development Studio that functions as a for loop, which is a looping structure in a programming language that executes a given action or set of actions a specified number of times. The For activity accepts one XML document as an input and it uses a transform on that XML to determine how many times to execute. For example, the XML I have above has three <token> elements:

               

              <tokens>
                <token>MyServer1</token>
                <token>MyServer2</token>
                <token>MyServer4</token>
              </tokens>

               

              The transform "//token" means "return all elements named token at any point in the document". Since we have three <token> elements, the transform will return three items, and the activities in the For loop will execute three times, once for each <token>.

               

              Studio's built-in documentation also contains step-by-step instructions for creating a For activity. Click on Help -> Help Contents and search for "for activity"; you will use the context item with your XML document in step (3) and the transform in step (5). If you need a completed example from a workflow, please check the out-of-the-box workflows "AMP-AD-BMC-Remedy-ARS:Find Items" and "AutoPilot-OA-Task_Management:Create Task Relationships" for functional examples of For activities.

              • 4. Re: For loop configuration
                Volker Scheithauer

                Praveen,

                 

                do you have to restart the services on one windows machine or multiple? Do you need to authenticate against the machine? Do you have to authenticate for each individual machine, or do you have a domain service account?

                Next, is it one service per machine or multiple? Are there any dependencies you have to adhere to?

                 

                Once you covered all this, then we can work on the actual workflow.

                I prefer the command line adapter and use: net start "service name"

                See also: Net start

                 

                • Build your workflow to start a service as you see fit, for just one server. Or you the out of the box one
                • Test this workflow against another target
                • Wrap this workflow with a for-loop

                Services.png

                 

                The For activity allows for iterative processing of a list of input data within a process.

                When a For activity is placed on the BMC Atrium Orchestrator Development Studio process canvas, an End For object is automatically placed to the right of it. A For activity is linked to a series of activities, terminating at an End For object. The process will execute the linked activities between the For and End For activities for each item in the list, moving to the next item on the list each time the End For object is reached. When all items in the list have been processed by the For loop activities, the process will continue with the activities that follow the End For object.

                 

                The End For object cannot be deleted individually. When a For activity is deleted, all activities connected to the For activity, including the End For object, will be deleted together as a group. Activities contained between the For and the End For can be deleted individually.

                 

                The Input parameter can be a context item or a dynamic context that contains an XML document. An XPath expression is created through the Transform Editor to designate the Input document that will be processed by the For loop activities. The XPath expression selects the value from each element in the XML document in sequence. When the list is exhausted, the process proceeds with the activities subsequent to the End For object.

                 

                See also:

                 

                Please share comments on how this worked for you

                 

                Regards, "Smooth Orchestrator"

                1 of 1 people found this helpful