help needed: workflow to create a specific reference

  • 22 December 2017
  • 8 replies
  • 2 views

Badge +11

Hello,

can somebody help me creating a simple workflow that does generate the following reference:

- ABCD{CurrentYear}000

example: ABCD17001 | ABCD17002 | ABCD17003 etc.

However, when it reaches year 18 then the digits should start from 1 again e.g ABCD18001 / 002 / 003 etc.

By this, the 3 zeros means there is 999 items gap per year.

Is it doable with a non complicated workflow as I am not advanced.

Cheers.

SEE THE WORKFLOW ATTACHED


8 replies

Badge +4

Hello Bim Bimi,

I hope you'll have great holidays.

I think your request is very simple but I may not understand it well.

I understand three kind of workflow :

   - The first one : Everytime the workflow run, it incremented the reference by 1. So you need to put ABCD17001 for the first item and each time the workflow runs, you take only the number (with a regex for example) and you increment it by 1. Then you put the "ABCD" + the new numbre in a buildstring. And you add it to your reference.

   - The second one : The workflow is always running and it incremented the reference by 1 for a known time. You won't need a regex for this one. You'll just have to initialize the number for 17000 and increment it by 1, then you use a build string action which add the number to your string "ABCD".

   - The third one (and I think it's the one you need) : It's the same at the first one but it changes when the year 18 is check (not when 999 numbers were traveled). 

For this one, you will need to initialize 3 variables:

   - The string "ABCD"

   - The Year "18"

   - The number "1"

The build string is the same, but you'll have to check if your number's length is more than 2 or 3 and then add one or two "0" before the number. Then you put all of this in a build string and do whatever you want with it happy.png

Maybe you'll need to check the year before this, then a regex would be enough. (the 2 characters after "ABCD")

I think there are more ways (and maybe an easier one) to satisfy you, but this is a start.

Regards,

Pierre NOUET

Badge +11

Hello Pierre

thanks for taking the initiative happy.png

i think the 3rd option is the one.

the 999 was just a sample to show that within year 18 there can be 999 items.

Basically, all i want it when a requedt it made the workflow checks which current year we are in and then adds + 1 day to the string of 000 (3 zeros) start 18001 and 18002 ... potentially it can reach 18999 (wonder what does it do when 999 is reached!?

anyway, back to the topic:

the workflow should check the current state of the reference and add + 1 on top and when year 2018 is reached then it should start from 18000 which becomes 18001 etc etc.

i suck big time with workflows and only doing low level of workflows. All this requires creating variables and god knows what ... which is too complicated to start with.

if you got some time, maybe you can create a wf and kind of show what is required etc.

thanks

ps: i better start packing my stuff now lol

Badge +11

Hello All,

I have uploaded the current Reference workflow, which does increment by 1 for each new entry.
However, I would like so that the counting starts from 0 once a new year e.g. FAMAS1800001 | 1800002 | 1800003 etc.

Meaning, each year has a possiblity of 5 digits (likelyhood is over 200 items per year).

So the digits can be decreased to 3 {0} instead of 5.

See the workflow attached in the initial post.

Badge +7

Hi Bim,

I have something similar that I had to do on our SharePoint Enterprise Project Management Server.  Everytime a new project is created I have to pick information about the project, i.e. a short code for the business unit. i.e. MAR, or RTB, etc.  and then get the next available digit to generate a WBS element for the project.

The only way I manage to do this was to create a new list on my site that had two columns Business Unit and Number next to it.  Everytime a new WBS needed to be created I would look for the business unit in this list, get the number.  I would add 1 to this number and write it back.   This would then form my WBS element.

I think you will have to take a similar approach.  You can create a list (Key_List) with the Year and Number as columns.  So every time the workflow kicks off, get the current year, read this Key_List to see if anything exist for the year.  If it does, read the number, add 1 to it and write it back.  If it doesn't exist create the new year, i.e. 2018 or just 18 and in the number column start at 1. 

This way you should be able to keep track of the year and start at 1 again. 

Let me know your thoughts on this or if anything is unclear.

Badge +11

Hey Francois

Thanks for the advise ...
I was hoping there is something via the workflow that can be done without creating extra lists which can be a pain if you have a lot of forms using the same reference principle / process.

I was thinking maybe comparing the CURRENT YEAR 18 with the LAST YEAR 17 :

If CurrentYear > Last year then set counting to 0 and add 1

// This is a flaw as it will always set it to 0 for every new entry ...

This is the tricky bit ...

Did you check out my workflow attached?!

Badge +7

Hi Bim,

I did not look at the workflow.  Screen prints would work better than an actual workflow.

The problem is that you want the counter to reset, or be based on the previous record in the list. So you can take your new item ID and -1 and read the year of ItemID-1. Then read the year of ItemID-1 and see if the years are different from current ItemID to ItemID-1.  If it is different, then start the number from 1...if not just take the number from ItemID-1 and add a 1 for current itemID number field. 

The possible problem with this approach is that a list item might be deleted and you will maybe not have an ItemID-1.  You can add this check to a loop and keep on going up but I think this approach can get a bit technical.

I'm re-reading my explanation and I think it can get a bit confusing.  Let me know if I need to explain more.  

Badge +11

indeed, it is confusing lol

bearing in mind I am still a beginner ...

You can download the wf and uploaded it on your test page and that way you see the variables etc.

I got it from somewhere else, no way I could have done it myself lol

The screenshots would just show the functions but not the inside setup.

Feel free to download it and have a look at it ...

Badge +11

Hello All

can you please help / advise???

I have attached the workflow for you to review ...

can somebody see if my request can be implemented?!

Thanks

Reply