AnsweredAssumed Answered

PDM API multiple serial numbers in one template

Question asked by Johan Visagie on Nov 25, 2020
Latest reply on Dec 14, 2020 by Amen Allah Jlili

I am trying to create a single template that can create multiple serial numbers based on the data which one complete on the data card. I am thinking to create a butom, which will pull the serial number when pressed and run the a code. I have found the following tread, which confirms that it is possible.


I however have asked Solidworks API support to guide me in this process. They shared a very useful knowledge base: S-056874 : How is an Enterprise PDM API add-in created that uses GetVar and SetVar to read and write variable values in a template input form (card)? (See attached files). This definitely will help me to get the variable from the data card to use for the search in the SQL to populate the serial number.


I then explore how PDM assign serial number and issue serial numbers and I found a SQL table SerialNumbers (See sample table attached), which contains the serial number Name, Data and Counter. This was perfect for me, so I basically needed the data format, which is stored in “Data” and the next serial number, which is stored in “Counter”, for a specific serial number name. I then implemented a SQL query to pull the data from the table, which were as follows:

SELECT  concat(Left(SerialNumbers.Data,6),format(SerialNumbers.Counter,'d4'))

FROM [SWPDM_Johantest].[dbo].[SerialNumbers]

WHERE SerialNumbers.Name like '%Kendal%'

Update SerialNumbers

SET Counter = Counter + 1


I however had to concatenate the serial number here, because I could not find an elegant way to make up the serial number from the “Data” field, but there must be a more intelligent way of doing this, since the stored value is already in a number format as shown in the table image attached.


Then my next step were to see if I can call this SQL query from within a VB.Net code (see attached). Preferable I will like to store the values of the SerialNumbers table under Data and counter in variables, which I then can use to build the serial number. And this is where I got stuck. I get an error within Visual Studio and don't know how to get past this.


If I however get the above right I need to have all of this in one vb code / dll file for use in the PDM administration.


I however are not a programmer, but can modify scrips to suit my need. So if there is someone that can give me a project files similar to the PDMWE add-in attached below that will be able to do this, it will be highly appreciated. But any other assistance will also help.