Auto Number field

Kerry,

I just implemented a solution to auto-number customer entry and vendor entry. I use the Company table UD feilds (number01, number02)to keep track of the next number. Customizing the Company form allows you to see and set the next number to be assigned. I am happy to share the code with you if you want.

Keith

--- In vantage@yahoogroups.com, "Kerry_Muntz" <kerry_muntz@...> wrote:
>
> This looks great! I haven't gotten my head around it all yet, but this is definitely something I was contemplating for an upcoming improvement. Kerry.
>
> --- In vantage@yahoogroups.com, "Brian W. Spolarich " <bspolarich@> wrote:
> >
> > The general technique is to keep the counter for the "next available identifier" on a Number field on some master table, such as the Company table.
> >
> > You can then use this fragment of custom code to detect when in the UI the user is creating a new record, and populate the DataView with the new ID.
> >
> > The example below is for Customer, but you get the idea.
> >
> > Of course this only works through the UI. I wonder if you could do something similar with a BPM and UpdateTableBuffer. Basically intercept the GetNewWhatever call and put the ID in the new record based on the custom Numberxx field in the Company table, and then increment the counter via UpdateTableBuffer.
> >
> > In either case, one downside is that if the user doesn't save the new record, the counter is updated anyways. I suspect there's a way to handle that in the UI.
> >
> > -bws
> >
> > Sub InitializeCustomCode()
> >
> >
> > '// ** Wizard Insert Location - Do not delete 'Begin/End Custom Method Calls' lines **
> > '// Begin Wizard Added Variable Intialization
> >
> > edvCustomer = CType(oTrans.EpiDataViews("Customer"), EpiDataView)
> > '// End Wizard Added Variable Intialization
> > '// Begin Custom Method Calls
> >
> > '// End Custom Method Calls
> > End Sub
> >
> >
> >
> > Private Sub edvCustomer_EpiViewNotification(view As EpiDataView, args As EpiNotifyArgs)Handles edvCustomer.EpiViewNotification
> > '// ** Argument Properties and Uses **
> > '// view.dataView(args.Row)("[FieldName]")
> > '// args.Row, args.Column, args.Sender, args.NotifyType
> > '// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView,
> > '//NotifyType.InitAndResetTreeNodes
> >
> > If (args.NotifyType = EpiTransaction.NotifyType.AddRow) Then
> > If (args.Row > -1) Then
> > Dim compAdapt As CompanyAdapter = New CompanyAdapter(CustomerEntryForm)
> > compAdapt.BOConnect()
> > Dim company As String = CustomerEntryForm.Session.CompanyID
> > Dim ret As Boolean = compAdapt.GetByID(company)
> >
> > Dim newCompID As Integer = compAdapt.CompanyData.Tables("Company").Rows(0)("Number01")
> >
> > view.dataView(args.Row)("CustID") = newCompID.ToString()
> > view.Notify(New EpiNotifyArgs(CustomerEntryForm, view.Row, view.Column))
> >
> > newCompID = newCompID + 1
> >
> > compAdapt.CompanyData.Tables("Company").Rows(0).BeginEdit()
> > compAdapt.CompanyData.Tables("Company").Rows(0)("Number01") = newCompID
> > compAdapt.CompanyData.Tables("Company").Rows(0).EndEdit()
> >
> > compAdapt.Update()
> >
> > compAdapt.Dispose()
> >
> >
> > End If
> > End If
> > End Sub
> > End Module
> >
> > --
> > Brian W. Spolarich ~ Manager, Information Services ~ Advanced Photonix / Picometrix
> > Â Â Â Â bspolarich@ ~ 734-864-5618 ~ www.advancedphotonix.com
> >
> >
> > -----Original Message-----
> > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of idiabos
> > Sent: Tuesday, September 15, 2009 11:37 AM
> > To: vantage@yahoogroups.com
> > Subject: [Vantage] Auto Number field
> >
> > Hello,
> >
> > Does anyone have experience on how to set a field up to auto number (sequentially) when a new record is created. We are looking to set this up for the ECO Number field. Can this be done through a BPM or will I need to create a UD Table. Just looking for some direction. Thanks in advance for your time.
> >
> > -Sal
> >
>
Hello,

Does anyone have experience on how to set a field up to auto number (sequentially) when a new record is created. We are looking to set this up for the ECO Number field. Can this be done through a BPM or will I need to create a UD Table. Just looking for some direction. Thanks in advance for your time.

-Sal
The general technique is to keep the counter for the "next available identifier" on a Number field on some master table, such as the Company table.

You can then use this fragment of custom code to detect when in the UI the user is creating a new record, and populate the DataView with the new ID.

The example below is for Customer, but you get the idea.

Of course this only works through the UI. I wonder if you could do something similar with a BPM and UpdateTableBuffer. Basically intercept the GetNewWhatever call and put the ID in the new record based on the custom Numberxx field in the Company table, and then increment the counter via UpdateTableBuffer.

In either case, one downside is that if the user doesn't save the new record, the counter is updated anyways. I suspect there's a way to handle that in the UI.

-bws

Sub InitializeCustomCode()


'// ** Wizard Insert Location - Do not delete 'Begin/End Custom Method Calls' lines **
'// Begin Wizard Added Variable Intialization

edvCustomer = CType(oTrans.EpiDataViews("Customer"), EpiDataView)
'// End Wizard Added Variable Intialization
'// Begin Custom Method Calls

'// End Custom Method Calls
End Sub



Private Sub edvCustomer_EpiViewNotification(view As EpiDataView, args As EpiNotifyArgs)Handles edvCustomer.EpiViewNotification
'// ** Argument Properties and Uses **
'// view.dataView(args.Row)("[FieldName]")
'// args.Row, args.Column, args.Sender, args.NotifyType
'// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView,
'//NotifyType.InitAndResetTreeNodes

If (args.NotifyType = EpiTransaction.NotifyType.AddRow) Then
If (args.Row > -1) Then
Dim compAdapt As CompanyAdapter = New CompanyAdapter(CustomerEntryForm)
compAdapt.BOConnect()
Dim company As String = CustomerEntryForm.Session.CompanyID
Dim ret As Boolean = compAdapt.GetByID(company)

Dim newCompID As Integer = compAdapt.CompanyData.Tables("Company").Rows(0)("Number01")

view.dataView(args.Row)("CustID") = newCompID.ToString()
view.Notify(New EpiNotifyArgs(CustomerEntryForm, view.Row, view.Column))

newCompID = newCompID + 1

compAdapt.CompanyData.Tables("Company").Rows(0).BeginEdit()
compAdapt.CompanyData.Tables("Company").Rows(0)("Number01") = newCompID
compAdapt.CompanyData.Tables("Company").Rows(0).EndEdit()

compAdapt.Update()

compAdapt.Dispose()


End If
End If
End Sub
End Module

--
Brian W. Spolarich ~ Manager, Information Services ~ Advanced Photonix / Picometrix
    bspolarich@... ~ 734-864-5618 ~ www.advancedphotonix.com


-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of idiabos
Sent: Tuesday, September 15, 2009 11:37 AM
To: vantage@yahoogroups.com
Subject: [Vantage] Auto Number field

Hello,

Does anyone have experience on how to set a field up to auto number (sequentially) when a new record is created. We are looking to set this up for the ECO Number field. Can this be done through a BPM or will I need to create a UD Table. Just looking for some direction. Thanks in advance for your time.

-Sal
Yes I did a bpm for autogenerate customerid and autoshiptonum ill put it out on site
Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: "idiabos" <idiabos@...>

Date: Tue, 15 Sep 2009 15:36:30
To: <vantage@yahoogroups.com>
Subject: [Vantage] Auto Number field


Hello,

Does anyone have experience on how to set a field up to auto number (sequentially) when a new record is created. We are looking to set this up for the ECO Number field. Can this be done through a BPM or will I need to create a UD Table. Just looking for some direction. Thanks in advance for your time.

-Sal




[Non-text portions of this message have been removed]
Thanks Brian!! I appreciate the time! This helps a lot!

-Sal

--- In vantage@yahoogroups.com, "Brian W. Spolarich " <bspolarich@...> wrote:
>
> The general technique is to keep the counter for the "next available identifier" on a Number field on some master table, such as the Company table.
>
> You can then use this fragment of custom code to detect when in the UI the user is creating a new record, and populate the DataView with the new ID.
>
> The example below is for Customer, but you get the idea.
>
> Of course this only works through the UI. I wonder if you could do something similar with a BPM and UpdateTableBuffer. Basically intercept the GetNewWhatever call and put the ID in the new record based on the custom Numberxx field in the Company table, and then increment the counter via UpdateTableBuffer.
>
> In either case, one downside is that if the user doesn't save the new record, the counter is updated anyways. I suspect there's a way to handle that in the UI.
>
> -bws
>
> Sub InitializeCustomCode()
>
>
> '// ** Wizard Insert Location - Do not delete 'Begin/End Custom Method Calls' lines **
> '// Begin Wizard Added Variable Intialization
>
> edvCustomer = CType(oTrans.EpiDataViews("Customer"), EpiDataView)
> '// End Wizard Added Variable Intialization
> '// Begin Custom Method Calls
>
> '// End Custom Method Calls
> End Sub
>
>
>
> Private Sub edvCustomer_EpiViewNotification(view As EpiDataView, args As EpiNotifyArgs)Handles edvCustomer.EpiViewNotification
> '// ** Argument Properties and Uses **
> '// view.dataView(args.Row)("[FieldName]")
> '// args.Row, args.Column, args.Sender, args.NotifyType
> '// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView,
> '//NotifyType.InitAndResetTreeNodes
>
> If (args.NotifyType = EpiTransaction.NotifyType.AddRow) Then
> If (args.Row > -1) Then
> Dim compAdapt As CompanyAdapter = New CompanyAdapter(CustomerEntryForm)
> compAdapt.BOConnect()
> Dim company As String = CustomerEntryForm.Session.CompanyID
> Dim ret As Boolean = compAdapt.GetByID(company)
>
> Dim newCompID As Integer = compAdapt.CompanyData.Tables("Company").Rows(0)("Number01")
>
> view.dataView(args.Row)("CustID") = newCompID.ToString()
> view.Notify(New EpiNotifyArgs(CustomerEntryForm, view.Row, view.Column))
>
> newCompID = newCompID + 1
>
> compAdapt.CompanyData.Tables("Company").Rows(0).BeginEdit()
> compAdapt.CompanyData.Tables("Company").Rows(0)("Number01") = newCompID
> compAdapt.CompanyData.Tables("Company").Rows(0).EndEdit()
>
> compAdapt.Update()
>
> compAdapt.Dispose()
>
>
> End If
> End If
> End Sub
> End Module
>
> --
> Brian W. Spolarich ~ Manager, Information Services ~ Advanced Photonix / Picometrix
> Â Â Â Â bspolarich@... ~ 734-864-5618 ~ www.advancedphotonix.com
>
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of idiabos
> Sent: Tuesday, September 15, 2009 11:37 AM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Auto Number field
>
> Hello,
>
> Does anyone have experience on how to set a field up to auto number (sequentially) when a new record is created. We are looking to set this up for the ECO Number field. Can this be done through a BPM or will I need to create a UD Table. Just looking for some direction. Thanks in advance for your time.
>
> -Sal
>
This looks great! I haven't gotten my head around it all yet, but this is definitely something I was contemplating for an upcoming improvement. Kerry.

--- In vantage@yahoogroups.com, "Brian W. Spolarich " <bspolarich@...> wrote:
>
> The general technique is to keep the counter for the "next available identifier" on a Number field on some master table, such as the Company table.
>
> You can then use this fragment of custom code to detect when in the UI the user is creating a new record, and populate the DataView with the new ID.
>
> The example below is for Customer, but you get the idea.
>
> Of course this only works through the UI. I wonder if you could do something similar with a BPM and UpdateTableBuffer. Basically intercept the GetNewWhatever call and put the ID in the new record based on the custom Numberxx field in the Company table, and then increment the counter via UpdateTableBuffer.
>
> In either case, one downside is that if the user doesn't save the new record, the counter is updated anyways. I suspect there's a way to handle that in the UI.
>
> -bws
>
> Sub InitializeCustomCode()
>
>
> '// ** Wizard Insert Location - Do not delete 'Begin/End Custom Method Calls' lines **
> '// Begin Wizard Added Variable Intialization
>
> edvCustomer = CType(oTrans.EpiDataViews("Customer"), EpiDataView)
> '// End Wizard Added Variable Intialization
> '// Begin Custom Method Calls
>
> '// End Custom Method Calls
> End Sub
>
>
>
> Private Sub edvCustomer_EpiViewNotification(view As EpiDataView, args As EpiNotifyArgs)Handles edvCustomer.EpiViewNotification
> '// ** Argument Properties and Uses **
> '// view.dataView(args.Row)("[FieldName]")
> '// args.Row, args.Column, args.Sender, args.NotifyType
> '// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView,
> '//NotifyType.InitAndResetTreeNodes
>
> If (args.NotifyType = EpiTransaction.NotifyType.AddRow) Then
> If (args.Row > -1) Then
> Dim compAdapt As CompanyAdapter = New CompanyAdapter(CustomerEntryForm)
> compAdapt.BOConnect()
> Dim company As String = CustomerEntryForm.Session.CompanyID
> Dim ret As Boolean = compAdapt.GetByID(company)
>
> Dim newCompID As Integer = compAdapt.CompanyData.Tables("Company").Rows(0)("Number01")
>
> view.dataView(args.Row)("CustID") = newCompID.ToString()
> view.Notify(New EpiNotifyArgs(CustomerEntryForm, view.Row, view.Column))
>
> newCompID = newCompID + 1
>
> compAdapt.CompanyData.Tables("Company").Rows(0).BeginEdit()
> compAdapt.CompanyData.Tables("Company").Rows(0)("Number01") = newCompID
> compAdapt.CompanyData.Tables("Company").Rows(0).EndEdit()
>
> compAdapt.Update()
>
> compAdapt.Dispose()
>
>
> End If
> End If
> End Sub
> End Module
>
> --
> Brian W. Spolarich ~ Manager, Information Services ~ Advanced Photonix / Picometrix
> Â Â Â Â bspolarich@... ~ 734-864-5618 ~ www.advancedphotonix.com
>
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of idiabos
> Sent: Tuesday, September 15, 2009 11:37 AM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Auto Number field
>
> Hello,
>
> Does anyone have experience on how to set a field up to auto number (sequentially) when a new record is created. We are looking to set this up for the ECO Number field. Can this be done through a BPM or will I need to create a UD Table. Just looking for some direction. Thanks in advance for your time.
>
> -Sal
>
Thanks!! I would greatly appreciate that!

--- In vantage@yahoogroups.com, advantage@... wrote:
>
> Yes I did a bpm for autogenerate customerid and autoshiptonum ill put it out on site
> Sent from my Verizon Wireless BlackBerry
>
> -----Original Message-----
> From: "idiabos" <idiabos@...>
>
> Date: Tue, 15 Sep 2009 15:36:30
> To: <vantage@yahoogroups.com>
> Subject: [Vantage] Auto Number field
>
>
> Hello,
>
> Does anyone have experience on how to set a field up to auto number (sequentially) when a new record is created. We are looking to set this up for the ECO Number field. Can this be done through a BPM or will I need to create a UD Table. Just looking for some direction. Thanks in advance for your time.
>
> -Sal
>
>
>
>
> [Non-text portions of this message have been removed]
>
They're out there in BPM folder
Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: "idiabos" <idiabos@...>

Date: Wed, 16 Sep 2009 16:20:19
To: <vantage@yahoogroups.com>
Subject: [Vantage] Re: Auto Number field


Thanks!! I would greatly appreciate that!

--- In vantage@yahoogroups.com, advantage@... wrote:
>
> Yes I did a bpm for autogenerate customerid and autoshiptonum ill put it out on site
> Sent from my Verizon Wireless BlackBerry
>
> -----Original Message-----
> From: "idiabos" <idiabos@...>
>
> Date: Tue, 15 Sep 2009 15:36:30
> To: <vantage@yahoogroups.com>
> Subject: [Vantage] Auto Number field
>
>
> Hello,
>
> Does anyone have experience on how to set a field up to auto number (sequentially) when a new record is created. We are looking to set this up for the ECO Number field. Can this be done through a BPM or will I need to create a UD Table. Just looking for some direction. Thanks in advance for your time.
>
> -Sal
>
>
>
>
> [Non-text portions of this message have been removed]
>





[Non-text portions of this message have been removed]