Quantcast
Channel: Code For Future
Viewing all articles
Browse latest Browse all 10

Creating custom column with complex logic

$
0
0

Hello Readers,

I got following question from Chris Polek who happen to stumble upon my blog. I tried to answer it best of my knowledge but I am sure there can be multiple ways to achieve this. If you find a better solution, do comment!

Question:
I would like to create a column in a custom list that will sequentially assign the number 1, 2 or 3 to an item created in the list. After assigning a ’3′, it will start over at ’1′. Optionally, this could be a name as well, but a number will work just fine.

Would you be able to help me with this request?

Answer:
Interesting! You can do this by using a calculated column or by using a workflow.

Calculated column method:
You can base your logic with the help of ID column.
For e.g. If the id of the list item is 3 or 6 or 9 or if the sum of the digits is 3/6/9 then put the column value as 3
For e.g. If id =12 then 1+2= 3 hence you will print 3
If all above is false then if the id is even number then print 2 else print 1

If above logic seems complicated then try this
Workflow method:
Create another list, create one list item where Title = 1
Now on your original list write a workflow which will read this value and print in your custom column. Once this is done the workflow will also increment the value into another list by one or reset it to one if it has reached to 3


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images