Question

Adding multiple products via Bussines Process

I have an API that returns products in JSON format like this:

{
  "productCode": "1027",
  "productDescription": "Bed Extension Legs x 4",
  "barcode": null,
  "neverDiminishing": false,
  "lastCosts": 0,
  "defaultPurchasePrice": 0,
  "defaultSellPrice": 81,
  "customerSellPrice": 0,
  "averageLandPrice": 40,
  "obsolete": false,
  "notes": "Bed Height Adjustable Legs x 4 (Bodyline Range)",
  "xeroTaxCode": "INPUT",
  "xeroTaxRate": 0.1,
  "taxablePurchase": true,
  "taxableSales": true,
  "xeroSalesTaxCode": "OUTPUT",
  "xeroSalesTaxRate": 0.1,
  "isComponent": true,
  "isAssembledProduct": false,
  "xeroSalesAccount": "41109",
  "xeroCostOfGoodsAccount": "50020",
  "binLocation": null,
  "isSerialized": false,
  "isBatchTracked": false,
  "isSellable": true,
  "guid": "d0de0979-9739-4e05-b6d5-1436ec58a627"
}

I know how to add singular product, but how can I process a collection of thoose returned from WebService and add them to BPM?

Like 0

Like

2 comments

In order to process a custom response, please create a script task, call the web service from there via native c# and process the response with c# tools as well. 

We have something similar to this for getting product stock and updating in bpm'online product section. We took the stock data collection recieved  from webservice into a table, say a temp table, then processed the records one by one and at the end deleted the processed records. You might need to write a script to put the collection into the temp table, something like given below. Usrproductstocktemp is the temporary table used here.

var collaterals = Get<ICompositeObjectList<ICompositeObject>>("WebService1.UsrGetProductStockData_Out");
Guid obj = Guid.NewGuid();
foreach(var collateral in collaterals) {
	string value = ""; 
    var ItemMasterId = collateral.TryGetValue<string>("UsrITEMMASTERID_Out", out value) ? value : "";
 	if (!string.IsNullOrEmpty(ItemMasterId)) {
 
 		Set("UsrTrackId",obj);
 
 		var insert = new Insert(UserConnection)
		.Into("UsrProductStockTemp")
 		.Set("UsrItemMasterId",Column.Parameter(collateral.TryGetValue<string>("UsrITEMMASTERID_Out", out value) ? value : ""))
		.Set("UsrItemId",Column.Parameter(collateral.TryGetValue<string>("UsrITEMID_Out", out value) ? value : ""))
		.Set("UsrUnitId",Column.Parameter(collateral.TryGetValue<string>("UsrUNITID_Out", out value) ? value : ""))
		.Set("UsrClosingQty",Column.Parameter(collateral.TryGetValue<string>("UsrCLOSINGQTY_Out", out value) ? value : ""))
		.Set("UsrLocId",Column.Parameter(collateral.TryGetValue<string>("UsrLOCID_Out", out value) ? value : ""))
		.Set("UsrTrackId",Column.Parameter(obj))
		.Set("UsrIsDeleted",Column.Parameter(false));
		insert.Execute();
 	}
} 
 
return true;

 

Show all comments