Auto Calculating Customer/Supplier ID

We just use a vb field in company maint. I put in the starting
number in the company and whenever we create a new record we just
add one to that, create the ID and save it back to the company.


--- In vantage@yahoogroups.com, "Nick" <neberle@...> wrote:
>
> I wanted to start the numbering at 1000 but I suppose I could
always
> just add 1000 to the custnum value then prefix it with C or S
>
> --- In vantage@yahoogroups.com, "Jim Frice" <Jim.Frice@> wrote:
> >
> > Any thought to use the internal custnum vantage assigns and add
your
> c or s the front for the custid? You want have to go searching
through
> a bunch of records that way so there shouldn't be any performance
issues.
> >
> > Jim
> >
> > ________________________________
> >
> > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> Behalf Of Brian W, Spolarich
> > Sent: Thursday, February 05, 2009 10:38 AM
> > To: vantage
> > Subject: Re: [Vantage] Re: Auto Calculating Customer/Supplier ID
> >
> >
> >
> >
> > I would think this would scale badly since you¹re fetching every
> customer
> > one by one. I¹d want to do a query and sort by CustID.
> >
> > -bws
> >
> > On 2/5/09 11:23 AM, "Nick" <neberle@
> <mailto:neberle%40norcomfg.com> > wrote:
> >
> > > Thanks for the code, We reviewed it and made some changes. Now
what
> > > we have it doing is scanning the customer/vendor ID records,
and
> > > picking the next available #. It will also fill in any blank
spots in
> > > case of a record not being saved or being deleted. I'm not
sure what
> > > performance will be like as I don't have a ton of records yet.
Let me
> > > know what you think. I wanted the numbers to start at 1000 but
it
> > > could be modified. You could also strip the "C" + if you don't
use the
> > > C prefix for your CustID.
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> >
> >
> >
> -------------------------------------------------------------------
-------
> >
> > William Frick & Co's SmartMarkT RFID Named to 2008 Top Ten
Products List
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
Is anybody out there using a customization to automatically generate
Customer or Supplier ID's?

I would like to have Customer and Supplier ID's generated
automatically upon creation of a new record. They would be a 6 digit
number with a prefix of S or C. I basically need to find the highest
number and increment it by one.

Is this a job for BPM, or would a button with some VB be necessary? Or
could I drive it off of the CustNum record generated by Vantage?

Thanks for the help!

Nick
http://groups.yahoo.com/group/vantage/files/Vantage%208.X%20Customizations/CustVendID.zip

This is a customization we're using to auto-set CustID and VendorID for new records. It get triggered when the client clicks on the "new" button. The next available ID for Customers and Vendors is stored in Company.Number01 and Company.Number02 respectively and incremented.

You could modify this code to add a prefix to your IDs. To set a particular starting value just modify Company.Number01, etc. for your company.

One thing that could improve this is to roll back the increment if the new record isn't actually saved. You will have gaps in your sequence if someone hits "New" and then doesn't actually create a new record, and this can make auditors nervous.

-bws

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

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

From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Nick
Sent: Monday, February 02, 2009 9:14 PM
To: vantage@yahoogroups.com
Subject: [Vantage] Auto Calculating Customer/Supplier ID

Is anybody out there using a customization to automatically generate
Customer or Supplier ID's?

I would like to have Customer and Supplier ID's generated
automatically upon creation of a new record. They would be a 6 digit
number with a prefix of S or C. I basically need to find the highest
number and increment it by one.

Is this a job for BPM, or would a button with some VB be necessary? Or
could I drive it off of the CustNum record generated by Vantage?

Thanks for the help!

Nick
Thanks for the code, We reviewed it and made some changes. Now what
we have it doing is scanning the customer/vendor ID records, and
picking the next available #. It will also fill in any blank spots in
case of a record not being saved or being deleted. I'm not sure what
performance will be like as I don't have a ton of records yet. Let me
know what you think. I wanted the numbers to start at 1000 but it
could be modified. You could also strip the "C" + if you don't use the
C prefix for your CustID.

If (args.NotifyType = EpiTransaction.NotifyType.AddRow) Then
If (args.Row > -1) Then
Dim custAdapt As CustomerAdapter = New
CustomerAdapter(CustomerEntryForm)
Dim ret As Boolean = false
dim i as integer = 0
dim customerID as string = ""
custAdapt.BOConnect()
for i = 1000 to 10000
custAdapt.getcustomer("C" + i.tostring)
if
custAdapt.customerdata.tables("customer").rows.count = 0 then
customerID = "C" + i.tostring()
exit for
end if
custAdapt.customerdata.tables("customer").clear
next
view.dataView(args.Row)("CustID") = customerID
view.Notify(New EpiNotifyArgs(CustomerEntryForm,
view.Row, view.Column))
End If
End If
End Sub


--- In vantage@yahoogroups.com, "Brian W. Spolarich " <bspolarich@...>
wrote:
>
>
http://groups.yahoo.com/group/vantage/files/Vantage%208.X%20Customizations/CustVendID.zip
>
> This is a customization we're using to auto-set CustID and
VendorID for new records. It get triggered when the client clicks on
the "new" button. The next available ID for Customers and Vendors is
stored in Company.Number01 and Company.Number02 respectively and
incremented.
>
> You could modify this code to add a prefix to your IDs. To set a
particular starting value just modify Company.Number01, etc. for your
company.
>
> One thing that could improve this is to roll back the increment if
the new record isn't actually saved. You will have gaps in your
sequence if someone hits "New" and then doesn't actually create a new
record, and this can make auditors nervous.
>
> -bws
>
> 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
>
> --
> Brian W. Spolarich ~ Manager, Information Services ~ Advanced
Photonix / Picometrix
> bspolarich@... ~ 734-864-5618 ~ www.advancedphotonix.com
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
Behalf Of Nick
> Sent: Monday, February 02, 2009 9:14 PM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Auto Calculating Customer/Supplier ID
>
> Is anybody out there using a customization to automatically generate
> Customer or Supplier ID's?
>
> I would like to have Customer and Supplier ID's generated
> automatically upon creation of a new record. They would be a 6 digit
> number with a prefix of S or C. I basically need to find the highest
> number and increment it by one.
>
> Is this a job for BPM, or would a button with some VB be necessary? Or
> could I drive it off of the CustNum record generated by Vantage?
>
> Thanks for the help!
>
> Nick
>
Nick,

Look at doing this in a BPM, it will get very very slow
otherwise...



If you really must do it in customisation land Perform a get list on the
customer adapter, then parse the dataset returned.



Regards,

Stephen



From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of Nick
Sent: 05 February 2009 16:23
To: vantage@yahoogroups.com
Subject: [Vantage] Re: Auto Calculating Customer/Supplier ID



Thanks for the code, We reviewed it and made some changes. Now what
we have it doing is scanning the customer/vendor ID records, and
picking the next available #. It will also fill in any blank spots in
case of a record not being saved or being deleted. I'm not sure what
performance will be like as I don't have a ton of records yet. Let me
know what you think. I wanted the numbers to start at 1000 but it
could be modified. You could also strip the "C" + if you don't use the
C prefix for your CustID.

If (args.NotifyType = EpiTransaction.NotifyType.AddRow) Then
If (args.Row > -1) Then
Dim custAdapt As CustomerAdapter = New
CustomerAdapter(CustomerEntryForm)
Dim ret As Boolean = false
dim i as integer = 0
dim customerID as string = ""
custAdapt.BOConnect()
for i = 1000 to 10000
custAdapt.getcustomer("C" + i.tostring)
if
custAdapt.customerdata.tables("customer").rows.count = 0 then
customerID = "C" + i.tostring()
exit for
end if
custAdapt.customerdata.tables("customer").clear
next
view.dataView(args.Row)("CustID") = customerID
view.Notify(New EpiNotifyArgs(CustomerEntryForm,
view.Row, view.Column))
End If
End If
End Sub





[Non-text portions of this message have been removed]
I would think this would scale badly since you¹re fetching every customer
one by one. I¹d want to do a query and sort by CustID.

-bws

On 2/5/09 11:23 AM, "Nick" <neberle@...> wrote:

> Thanks for the code, We reviewed it and made some changes. Now what
> we have it doing is scanning the customer/vendor ID records, and
> picking the next available #. It will also fill in any blank spots in
> case of a record not being saved or being deleted. I'm not sure what
> performance will be like as I don't have a ton of records yet. Let me
> know what you think. I wanted the numbers to start at 1000 but it
> could be modified. You could also strip the "C" + if you don't use the
> C prefix for your CustID.



[Non-text portions of this message have been removed]
Any thought to use the internal custnum vantage assigns and add your c or s the front for the custid? You want have to go searching through a bunch of records that way so there shouldn't be any performance issues.

Jim

________________________________

From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Brian W, Spolarich
Sent: Thursday, February 05, 2009 10:38 AM
To: vantage
Subject: Re: [Vantage] Re: Auto Calculating Customer/Supplier ID




I would think this would scale badly since you¹re fetching every customer
one by one. I¹d want to do a query and sort by CustID.

-bws

On 2/5/09 11:23 AM, "Nick" <neberle@... <mailto:neberle%40norcomfg.com> > wrote:

> Thanks for the code, We reviewed it and made some changes. Now what
> we have it doing is scanning the customer/vendor ID records, and
> picking the next available #. It will also fill in any blank spots in
> case of a record not being saved or being deleted. I'm not sure what
> performance will be like as I don't have a ton of records yet. Let me
> know what you think. I wanted the numbers to start at 1000 but it
> could be modified. You could also strip the "C" + if you don't use the
> C prefix for your CustID.

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





--------------------------------------------------------------------------

William Frick & Co's SmartMarkT RFID Named to 2008 Top Ten Products List


[Non-text portions of this message have been removed]
I wanted to start the numbering at 1000 but I suppose I could always
just add 1000 to the custnum value then prefix it with C or S

--- In vantage@yahoogroups.com, "Jim Frice" <Jim.Frice@...> wrote:
>
> Any thought to use the internal custnum vantage assigns and add your
c or s the front for the custid? You want have to go searching through
a bunch of records that way so there shouldn't be any performance issues.
>
> Jim
>
> ________________________________
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
Behalf Of Brian W, Spolarich
> Sent: Thursday, February 05, 2009 10:38 AM
> To: vantage
> Subject: Re: [Vantage] Re: Auto Calculating Customer/Supplier ID
>
>
>
>
> I would think this would scale badly since you¹re fetching every
customer
> one by one. I¹d want to do a query and sort by CustID.
>
> -bws
>
> On 2/5/09 11:23 AM, "Nick" <neberle@...
<mailto:neberle%40norcomfg.com> > wrote:
>
> > Thanks for the code, We reviewed it and made some changes. Now what
> > we have it doing is scanning the customer/vendor ID records, and
> > picking the next available #. It will also fill in any blank spots in
> > case of a record not being saved or being deleted. I'm not sure what
> > performance will be like as I don't have a ton of records yet. Let me
> > know what you think. I wanted the numbers to start at 1000 but it
> > could be modified. You could also strip the "C" + if you don't use the
> > C prefix for your CustID.
>
> [Non-text portions of this message have been removed]
>
>
>
>
>
>
--------------------------------------------------------------------------
>
> William Frick & Co's SmartMarkT RFID Named to 2008 Top Ten Products List
>
>
> [Non-text portions of this message have been removed]
>