Stock (Products)

Stock (i.e. Product) records can be accessed through the Products object. The Products object exposes standard TASLink Collection properties and methods which are used to navigate the collection and retrieve the Product object we require.

Important

Note that Products/Stock is only available with the TASLink/TASflex Plus product. So, you need to ensure adequate error trapping for situations where this feature has not been enabled in the end-user runtime environment.

First create a valid data connection (see Setup and Login for the TASLink Object).

Now create a reference to a Products object and set it to the Products object exposed through the TASLink object model.

Dim oProducts As TASLink.Products
Set oProducts = oSDK.Products

You can now get access to a particular Product object in the collection.

Dim oProduct As TASLink.Product
Set oProduct = oProduct.item(1)

Retrieving Product Data

Set the order you want the records in the collection presented:

oProducts.SortBy = ProductCode

You can then retrieve a specific product record, either by using the built-in Lookup Form (see the Navigation section in the Appendices for details of the form) like this:

Set oProduct = oProducts.ProvideUserLookup()

Or by specifying an individual product like this:

Set oProduct = oProducts("PRODUCT01")

And then provide information like this:

Debug.Print "Product code: " & oProduct.ProductCode & vbNewLine & "Product name: " & oProduct.Description

Adding a new Product Record

First create the required references to the the Products objects collection and to the Product object as described above.

'create a new Product object
Set oProduct = oSDK.Product

We can prepopulate the Product object’s properties:

oProduct.ProductCode = "PROD01"
oProduct.Description = "Product 01"
oProduct.SellingPrice1 = 100
'continue to set properties of new product...
If oProducts.Add(oProduct) Then
	MsgBox "New Product '" & oProduct.Name & "' (ID: '" & oProduct.Product_AccountCodeID & "') successfully added to TAS"
Else
	MsgBox oSDK.Status.Number & ": " & 	oSDK.Status.userReadableDescription
End If

Updating an existing Product Record

In this example we are going to change the name of a Product record. First retrieve the Product object as described in Retrieving Product Data above.

'Product record must be locked immediately prior to update
If oProduct.LockRecord Then
	oProduct.Name = InputBox("Please enter the new name for: " & vbNewLine & oProduct.Description & ".", "Product Name Change")
	'Set any other changed properties of Product...
	
	If oProducts.UpdateRecord(oProduct) = False Then
		MsgBox "Could not update the record: " & oSDK.Status.userReadableDescription
		'handle error
	Else
		MsgBox "Successfully updated TAS Product name to: '" & _
		oProduct.Description & "'."
	End If
Else
	MsgBox "Could not lock Product record: " & oSDK.Status.userReadableDescription
	'Try again???
End If

Free Format Text Blocks

Free Format Text Blocks can be accessed by users during manual Order entry and contain presetup ‘blocks’ of repetitive text which can be auto-populated into the Sales and Purchase Order body lines, thus saving the user having to remember and type the text. With TASLink you can create and update Free Format Text Blocks in a similar way to Products described above. The sample spreadsheet contains an example of the use of Free Format Text Blocks.

Dynamic Discounts

Dynamic Discounts can be accessed by users during manual Sales Order entry and contain presetup special Customer-Product percentage discounts – in effect, allowing special customer pricing for specific products – which can be auto-populated into the Sales Order body lines, thus saving the user having to remember that a discount exists for that Customer-Product combination. With TASLink you can creater and update Dynamic Discounts in a similar way to Products described above. The sample spreadsheet contains an example of the use of Dynamic Discounts.

Assemblies and Assembly Parts

TAS supports single-level Assemblies and TASLink lets you create and update these, by adding and deleting components, i.e. AssemblyParts. The sample spreadsheet contains an example of the use of Assembly Parts.