In this post I'll put some code to create price lists through Business Connector. The basic idea is to update the existing price of an existing price list for a specific item (using the combination of the dimension, color and size). It might be a bit specific, but you may find it useful. I don't have enough time now to complete the post, so I will just go ahead and paste the code.
AxaptaRecord rcInventDim = ax.CreateAxaptaRecord("InventDim");
AxaptaRecord rcPriceDiscTable = ax.CreateAxaptaRecord("PriceDiscTable");
// set invent dim, get the correct one using the dimensions you have
rcInventDim.Clear();
rcInventDim.set_Field("InventSizeId", "XXL"); //big guy
rcInventDim.set_Field("InventColorId", "01"); //red
rcInventDim = ax.CallStaticRecordMethod("inventDim", "findOrCreate", rcInventDim) as AxaptaRecord;
string sInventDimId = rcInventDim.get_Field("inventDimId").ToString();
//select the discount group you use, make sure you use the dimension as we don't want to step on the same item all the time
rcPriceDiscTable.ExecuteStmt("select forUpdate * from %1 where %1.ItemRelation == '" + oPriceDisc.Item
+ "' && %1.Currency == '" + oPriceDisc.Currency + "' && %1.InventDimId == '" + sInventDimId .Trim() + "'");
AxaptaObject axPriceDiscTable = ax.CreateAxaptaObject("AxPriceDiscTable");
axPriceDiscTable.Call("PriceDiscTable", rcPriceDiscTable);
//set basic (header) fields. You might not need this, just put it here to show that you can set these fields
axPriceDiscTable.Call("parmAgreement", "001");
axPriceDiscTable.Call("parmAccountCode", 1);
axPriceDiscTable.Call("parmAccountRelation", "002");
axPriceDiscTable.Call("parmModule", 1);
// set all the rest of the line fields
axPriceDiscTable.Call("parmItemCode", "MYWHITETSHIRT");
axPriceDiscTable.Call("parmrelation", 1);
axPriceDiscTable.Call("parmCurrency", "USD");
axPriceDiscTable.Call("parmItemRelation", "MYWHITETSHIRT");
axPriceDiscTable.Call("parmQuantityAmount", 1); //1 is usually what you'll have to put
axPriceDiscTable.Call("parmAmount", 34.5M);
axPriceDiscTable.Call("parmPriceUnit", 34.5M);
//set the DimId we found before
oPriceDisc.IvDim.InventDimId = sInventDimId;
axPriceDiscTable.Call("parmInventDimId", sInventDimId);
//save price disc
axPriceDiscTable.Call("save");
No comments:
Post a Comment