WriteItemValue() generate/en72.jpg


 

Use the WriteItemValue() function to store information in a transaction's item columns or create new transaction line items.

Syntax

WriteItemValue(cField, xData, [nPosition]) --> nLineResult

Arguments

<cField> --> The field value to write to. Refer to the table below for available codes and their meanings.

Code

Meaning

Boxqty

The box quantity if applicable.

Carrier

The line item's carrier/shipping code.

Cost

The item's cost price.

Dimension

The line item's dimension conversion factor.

Discount

The line item's discount percentage.

Disclist

The line item's discount percentage off list price.

Invoiceno

The invoice number this item relates to. (Purchase orders only.)

Listprice

The line item's list price.

Listdisc

The line item's discount off list price if applicable.

Measure

The stock item's unit of measure.

Orderno

The order number this item relates to. (Purchase orders only.)

Pcode

The product code.

Qty

The quantity sold or shipped.

Qtyback

The quantity back ordered.

Ref1

User line reference #1

Ref2

User line reference #2

Required

The date the item is required. (Sales orders only.)

Stockid

The Stock ID.

Sellprice

The item's sell price.

Taxcharge

The line item's total tax charge. This is based on the sell price x the quantity shipped, sold or ordered.

Title

The product description.

Unitcost

The unit cost price if applicable.

Unitsell

The item's standard unit sell price.

Zone

The line item's shipping zone.

 

Special Code

Meaning

Add

Adds a blank line item to the transaction at the position specified by nPosition.

Delete

Deletes a line item on the transaction at the position specified by nPosition.

 

<nPosition> --> The row number to write the value into. If this parameter is not passed to the function the current row number is assumed. Acceptable values are listed in the following table:

Value

Meaning

<none>

The currently selected line item is assumed. Note that the WriteItemValue() and ReadItemValue() functions do not change the selected line item number.

0

Add a new line item to the bottom of the existing transaction

1-4000

The row position to write a value into.

You should not specify a position number larger than the maximum size of the transaction. You can call the function: ReadItemValue("STOCKID", -1) to return the largest number you may pass into the function.

Returns

The row number written to or -1 if an error occurred.

Description

Use this function to alter the column information stored in the currently open transaction or to add new line items to a transaction.

Notes

generate/mistake1.gifCertain write values will be rejected if a line item does not have a valid product code and/or description. For example, you cannot assign a tax rate or sell price to a line item which does not yet have a product code or description. In these cases, particularly when adding new line items to a transaction, always assign the product code, description or Stock ID before assigning other values.

Example

* Create a stock item at line 1, and

* add a blank line, then add items at

* lines 3, 4 and 5 of the transaction

WriteItemValue("STOCKID", "0040529", 1)

WriteItemValue("TITLE", "Example Description", 1)

WriteItemValue("UNITSELL", 13.13, 1)

WriteItemValue("UNITCOST", 8.5, 1)

WriteItemValue("QTY", 10, 1)

WriteItemValue("ADD",, 2)

WriteItemValue("PCODE", "P", 3)

WriteItemValue("PCODE", "P", 4)

WriteItemValue("STOCKID", "0040529", 5)

____________________________

Related Topics:

Invoice Columns Hook

Invoice Pre-Saving Hook

Other Transaction Pre-Saving Hooks

ReadItemValue()

Transaction User Columns Hook



Help Topic Map