Find first available number in list

  • 29 October 2015
  • 2 replies
  • 0 views

Userlevel 6
Badge +13

Hi All,

I'm looking for some ideas on how to achieve the following.

I will be given a selection of 4 digit codes from a legacy app. These codes are random, ranging from 1 (I'd append necessary 0's) to 9999 and could be anything in between.

Using Workflow, I need to find an available code. It doesn't have to be the first available sequentially, but just not exist in the list already. I guess if I was doing this in Nintex Form then I'd use Javascript to randomly generate a number and then check it against the list, if it exists, run the code again until success. Ideally though, I'd like to keep this away from the form and in the Workflow.

Is there an inline function I've missed that can help with this?


Thanks


2 replies

Badge +7

Hi,

Via workflow, you could use a "Query List" in a "Loop" in order to query if the code you want to use already exists.

As there is no way to randomize a variable in a workflow, I think you have to use a sequential number.

Userlevel 5
Badge +12

You can always create or call an existing web service that returns a randomized number from within the workflow.  If you can't build one, just google to see what comes up as I've found and used them in the past.  The only thing about this approach (using 3rd party) is to make sure it'll be around for the life of your workflow.  Therefore it might be better to build it.

Thanks,

Mike

Reply