One Input Value to Three Variables

Last post 07-08-2020, 7:48 PM by Dannie4. 9 replies.
Sort Posts: Previous Next
  • One Input Value to Three Variables
    Posted: 03-16-2020, 9:40 AM

    I'm writing a more complex workflow than I ever have before. Users will know which file server they're on from a pre-populated list. From that single choice, I need to populate at least three fields: client, subclient, and basepath to all files. 

    My instinctive method is to assocate each input value with a character string that has delimited values. Were I writing in, say, perl or REXX, breaking apart that delimited string is child's play. 

    Is there a canonical way in Workflows to parse a character string into values? 

    Is there a better way in Workflows to populate three or more variables based on one imput field?

    Is there a good language reference I should use for such questions? Someone said Java is similar, but looking at an 800 page O'Reilly manual on Learning Java, and scanning their four pages on OO methods to parse text, I'm hoping I misunderstood or misremembered that answer. 

    Help? Smile

    Nick

  • Re: One Input Value to Three Variables
    Posted: 03-16-2020, 11:35 AM

    Maybe a long way, but a robust and working solution (using the row-id as an indirect index) :

    * I use a query in getBackupServers like :

         ----***************************************************************************
    IF OBJECT_ID('dbo.ServerResults', 'U') IS NOT NULL
      DROP TABLE  dbo.ServerResults;
    select row_number() OVER (Order by type desc,server asc) AS rij
      , server+', gescand op '+lastscanned+' en is '+type+'-backupserver,' as label
      ,server,lastcsanned,type
    into dbo.ServerResults
    from dbo._Digi06_BackupServers
    ----*************************************************************************

    * In the userinput 'ask_actie' , I use a string-field ask_server with

    possible labels  : xpath:{/workflow/getBackupServers/resultSets/row/col[@name="label"]}
    possible values: xpath:{/workflow/getBackupServers/resultSets/row/col[@name="rij"]}

    * I can use in a future query, with 1 parameter xpath:{/workflow/askActie/ask_server}

    select * from dbo.ServerResults where rij = ?

     

    Have fun and stay healthy!

    Mark

  • Re: One Input Value to Three Variables
    Posted: 03-16-2020, 12:59 PM

    Are you saying you built a temporary table from the text inputs and then loaded variables with an SQL query? Am I reading that correctly? 

  • Re: One Input Value to Three Variables
    Posted: 03-16-2020, 1:04 PM

    not a temporary, but a permanent (because temporary tables don't survive over workflow-activities)

  • Re: One Input Value to Three Variables
    Posted: 03-16-2020, 1:10 PM

    I think the rest of my team would severely criticize me for creating unmaintainable code.

  • Re: One Input Value to Three Variables
    Posted: 03-16-2020, 1:26 PM
    But is works …
  • Re: One Input Value to Three Variables
    Posted: 03-16-2020, 3:29 PM

    Based on some ideas from Mark Gielen, I'm trying a combination of "text to results set" and "assign values" to accomplish what want. 

    I still have no idea if I found the canonical method or if i found Yet Another Reinvented Wheel. 

  • Re: One Input Value to Three Variables
    Posted: 06-19-2020, 12:27 PM

    Not sure if this is what you are looking for but in several of my more complex WorkFlows I would get the information either through user input and/or a CommVault SQL query, ect. and then build my variable separating the values with a ~ tilde

    Example:

    StringBuffer sb = new StringBuffer();

    sb.append(xpath:{/workflow/ForEach_ActiveAuxCopy/row/col[@name="jobID"]} + "~");

    sb.append(xpath:{/workflow/ForEach_ActiveAuxCopy/row/col[@name="storagePolicyName"]} + "~");

    sb.append(jobCntrlState);

    sb.append(xpath:{/workflow/ForEach_AuxCopyBehind/row/col[@name="NumOfJobsBehind"]} + "~");

    sb.append(xpath:{/workflow/ForEach_ActiveAuxCopy/row/col[@name="percentcomplete"]} + "~");

    sb.append(xpath:{/workflow/ForEach_ActiveAuxCopy/row/col[@name="CopyName"]});

     

    return sb.toString();

     

    I then either set that to a WorkFlow variable or sometimes just reference back to the script output but I can than parse, in java split,  by the ~ symbol.

    Example:

    for (int i=0; i < xpath:{/workflow/variables/auxSummary}.size(); i++)

          {

            String section = xpath:{/workflow/variables/auxSummary}.get(i);

            String[] parts = section.split("~");

            sb.append("<tr>");

            sb.append("<td>"+parts[0]+"</td>"); //JobID

            if(parts[2].equals("Warning")  || parts[2].equals("Pending"))

              {

                sb.append("<td bgcolor=\"#f9f004\">"+parts[2]+"</td>"); //Status

              } else

              {

                sb.append("<td bgcolor=\"#93D490\">"+parts[2]+"</td>");   

              }

                   

            sb.append("<td>"+parts[1]+"</td>"); //Storage Policy

            sb.append("<td>"+parts[5]+"</td>"); //Storage Policy CopyName

            sb.append("<td>"+parts[3]+"</td>"); //Number of Jobs Behind

            sb.append("<td>"+parts[4]+"</td>"); //Percent Complete

            sb.append("</tr>");

          }

  • Re: One Input Value to Three Variables
    Posted: 06-19-2020, 12:27 PM

    Not sure if this is what you are looking for but in several of my more complex WorkFlows I would get the information either through user input and/or a CommVault SQL query, ect. and then build my variable separating the values with a ~ tilde

    Example:

    StringBuffer sb = new StringBuffer();

    sb.append(xpath:{/workflow/ForEach_ActiveAuxCopy/row/col[@name="jobID"]} + "~");

    sb.append(xpath:{/workflow/ForEach_ActiveAuxCopy/row/col[@name="storagePolicyName"]} + "~");

    sb.append(jobCntrlState);

    sb.append(xpath:{/workflow/ForEach_AuxCopyBehind/row/col[@name="NumOfJobsBehind"]} + "~");

    sb.append(xpath:{/workflow/ForEach_ActiveAuxCopy/row/col[@name="percentcomplete"]} + "~");

    sb.append(xpath:{/workflow/ForEach_ActiveAuxCopy/row/col[@name="CopyName"]});

     

    return sb.toString();

     

    I then either set that to a WorkFlow variable or sometimes just reference back to the script output but I can than parse, in java split,  by the ~ symbol.

    Example:

    for (int i=0; i < xpath:{/workflow/variables/auxSummary}.size(); i++)

          {

            String section = xpath:{/workflow/variables/auxSummary}.get(i);

            String[] parts = section.split("~");

            sb.append("<tr>");

            sb.append("<td>"+parts[0]+"</td>"); //JobID

            if(parts[2].equals("Warning")  || parts[2].equals("Pending"))

              {

                sb.append("<td bgcolor=\"#f9f004\">"+parts[2]+"</td>"); //Status

              } else

              {

                sb.append("<td bgcolor=\"#93D490\">"+parts[2]+"</td>");   

              }

                   

            sb.append("<td>"+parts[1]+"</td>"); //Storage Policy

            sb.append("<td>"+parts[5]+"</td>"); //Storage Policy CopyName

            sb.append("<td>"+parts[3]+"</td>"); //Number of Jobs Behind

            sb.append("<td>"+parts[4]+"</td>"); //Percent Complete

            sb.append("</tr>");

          }

  • Re: One Input Value to Three Variables
    Posted: 07-08-2020, 7:48 PM

    I'm not entirely sure what you're after here.

    You get one input (say a variable of type ClientEntity). If you want to retrieve extra information from that ClientEntity, your next activity is likely going to be a CSDBQuery activity, where you take the inputs/client/clientId as parameter.

    You query the available subclients with something like "SELECT subclientName FROM APP_Application WHERE client = ?", and use the output ResultSet from that activity in your next activity.

    If you really want to assign a certain value to a global variable (the ones in the tab "Variables" under the workflow properties) you can use an AssignValues activity, or from Java, you can call "workflow.setVariable("myvar", myval);".

    However, most of the time, it would be enough to simply use the output from the previous activity in your next activity.

The content of the forums, threads and posts reflects the thoughts and opinions of each author, and does not represent the thoughts, opinions, plans or strategies of Commvault Systems, Inc. ("Commvault") and Commvault undertakes no obligation to update, correct or modify any statements made in this forum. Any and all third party links, statements, comments, or feedback posted to, or otherwise provided by this forum, thread or post are not affiliated with, nor endorsed by, Commvault.
Commvault, Commvault and logo, the “CV” logo, Commvault Systems, Solving Forward, SIM, Singular Information Management, Simpana, Commvault Galaxy, Unified Data Management, QiNetix, Quick Recovery, QR, CommNet, GridStor, Vault Tracker, InnerVault, QuickSnap, QSnap, Recovery Director, CommServe, CommCell, SnapProtect, ROMS, and CommValue, are trademarks or registered trademarks of Commvault Systems, Inc. All other third party brands, products, service names, trademarks, or registered service marks are the property of and used to identify the products or services of their respective owners. All specifications are subject to change without notice.
Close
Copyright © 2020 Commvault | All Rights Reserved. | Legal | Privacy Policy