This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - How to increment sequence number programatically?

Harsha - Tuesday, August 28, 2012 5:24 AM:

Hi,

   I have created a server side VB method on OnBeforeAdd event to generate Id for my Itemtype automatically. 

And It should increment the Id value by 1 every time I open new one. I used a loop to do this based on some conditions. But what the problem is, it straight away giving the end value of 'for' loop.

For i = 1 To 4   this is the condition ,where it returning only 4 every time, without performing the loop from 1 to 4.   I mean for first time Id should be 1, if I open next one Id should be 2 and so on.

The code I used is:

Dim plan_id As String = Me.getProperty("plan_id")
Dim year As String = Me.getProperty("year")
Dim i As Integer

If (plan_id = "Q1") Then
For i = 1 To 4

i += 1

Next i
   Else  
    For i=5 To  8
Next     
 End If
Dim item_id As String = plan_id & "-" & year & "-" & i
Me.setProperty("item_id",item_id)

 

 How to increment sequence number by 1 ?  Any mistakes in the above code?

  Help me to do this.

 

Thank You,                                                                                                                                                                  

Harsha