Active IQ Unified Manager Discussions

provisioning - increment qtree name from a text file

MPERIYAK
3,103 Views

Hello Mates - I need help with a workflow. I have attached dar file.

This workflow works perfectly for us. We are looking for one improvement to this.

In the qtree/share name sometimes, for an example: we give either qtree_name as a name which there is no issues in using this.

Sometime we give qtree_name_XXXX and we get this number from an excel sheet and after using we increment by 1 in the excel sheet, which is a manual process today.

 

What I want is a text file stored in the wfa server (c:\incr.txt) say with a number to start with 8000.

 

Just above Qtree/Share name in the workflow, I want an option

Add Unique id - Yes/No.

If yes we need to pull the number 8000 from the txt file, number pops in the Qtree/Share name area and increment that txt file by 1

if no nothing happens.

  Is this possible ?

May be we can do without a text file. I am not sure how. The other thing is we don’t want to scan existing qtrees and then increment.

3 REPLIES 3

ranjeetr
3,103 Views

you can add a custom function like below which will accept the name ending with numeric (test_800) this function will return next name as (test_801).:

def nextName(name)

{

java.util.regex.Pattern RESOLVE_PATTERN = java.util.regex.Pattern.compile(

                    "(^.*?)(\\d+$)");

         java.util.regex.Matcher matcher = RESOLVE_PATTERN.matcher(name);

         if (matcher.matches())

{

              String prefix = matcher.group(1);

              String number = matcher.group(2);

  if (number!=null)

  {

                  return prefix + String.valueOf((Integer.valueOf(number)+1));

              }

         }

         throwException('The input must be in the format of: <string prefix><number suffix>');

}

MPERIYAK
3,103 Views

Hello ranjeet

Thanks for the response. I am learning WFA and let me try to get some understanding of your code to begin with.

Looks too complicated to me though.

Muru

adaikkap
3,103 Views

Hi Muru,

     Why dont you use your Excel as a datasource to your workflow so that the name/increment is taken care as part of the workflow itself ?

Regards

adai

Public