SaveStockItem - accountsIQ/API-Wiki GitHub Wiki

The SaveStockItem function updates or creates a stock item in an Entity.

Declaration

C#

public WSResultStatus SaveStockItem(string token, StockItem stockItem, bool create)

Visual Basic

Public Function SaveStockItem(ByVal token As String, ByVal stockItem As StockItem, ByVal create As Boolean) As WSResultStatus

Parameter List

Parameter Type Description
token String The session token retrieved during authentication.
stockItem StockItem The stock item to create / update.
create Boolean If the flag is not set, the method will attempt to update but not create the stock item. If the item does not already exist, the method will return NotCreated. If the flag is set, the method will attempt to update the item and if it does not exist, it will attempt to create it.

Description

The SaveStockitem method can:

  • Create a new stock item;
  • Update an existing stock item only if it does not already exist;
  • Update or create a stock item if it does not already exist.

The operation returns a WSResultStatus object.

When the operation is successful, the Status property is Success or Created.

When the operation is unsucessful, the ErrorCode property holds the precise error that happened.

Example

C#

Integration ws = new Integration();

String auth = ws.Login(entityID, partnerKey, userKey);
if (auth != null)
{
  StockItem item = new StockItem();
  item.StockItemID = "MYTEST";
  item.Active = true;
  item.ClosingStockGLAccountCode = "2200";
  item.ClosingWorkInProgressGLAccountCode = "2200";
  item.DefaultLocationID = "1";
  item.DefaultPurchasesGLAccountCode = "2000";
  item.DefaultSalesGLAccountCode = "1000";
  item.DefaultSublocationID = "BIN1";
  item.Description = "Stock item id";
  item.ItemPrice = 50;
  item.ItemTypeID = "P";
  item.OpeningStockGLAccountCode = "4000";
  item.OpeningWorkInProgressGLAccountCode = "4000";
  item.TaxCode = "NT";
  item.UpdateOnHand = true;

  WSResultStatus result = ws.SaveStockItem(auth, item, true);
  Assert.IsTrue(result.Status == OperationStatus.Created);
}

Visual Basic

Dim ws As New Integration

Dim auth As String = ws.Login(entityID, partnerKey, userKey)
If (Not Me.auth Is Nothing) Then
  Dim item As New StockItem
  item.StockItemID = "MYTEST"
  item.Active = True
  item.ClosingStockGLAccountCode = "2200"
  item.ClosingWorkInProgressGLAccountCode = "2200"
  item.DefaultLocationID = "1"
  item.DefaultPurchasesGLAccountCode = "2000"
  item.DefaultSalesGLAccountCode = "1000"
  item.DefaultSublocationID = "BIN1"
  item.Description = "Stock item id"
  item.ItemPrice = 50
  item.ItemTypeID = "P"
  item.OpeningStockGLAccountCode = "4000"
  item.OpeningWorkInProgressGLAccountCode = "4000"
  item.TaxCode = "NT"
  item.UpdateOnHand = True
  Assert.IsTrue((Me.ws.SaveStockItem(Me.auth, item, True).Status = OperationStatus.Created))
End If
⚠️ **GitHub.com Fallback** ⚠️