Open a form with the unique key by code
kurt vanhauwaert
Hi all,i have created a production order by sdk in the coresuite editor :
SAPbobsCOM.ProductionOrders oPO = ((SAPbobsCOM.ProductionOrders) B1Connectie.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders));
and filled up the fields :
oPO.ItemNo = lcItemCode;
oPO.DueDate = System.DateTime.Today.Date;
oPO.PlannedQuantity = Convert.ToDouble(ItemGrid.GetValue("11", lnCurrentGridPos));
oPO.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposPlanned;
oPO.Warehouse = "01";
oPO.ProductionOrderOrigin = SAPbobsCOM.BoProductionOrderOriginEnum.bopooSalesOrder;
oPO.ProductionOrderOriginEntry = lnDocEntry;
oPO.ProductionOrderType = SAPbobsCOM.BoProductionOrderTypeEnum.bopotStandard;
then i added the Production order.
RetValPO = oPO.Add();
my question :
is it possible to put this production order on the screen ?
something like
oPO.load and oPO.show ?
thnx
Anders Olsson
Hi Kurt,Form.OpenFormByKey("202", "152");
where 152 is the document key (get the latest added one) and 202 is the Production Order object type.
Regards,
Anders
kurt vanhauwaert
Thanks Anders for your reply.So i have one last question
In my code i get the last added key via :
string queryx = "SELECT DocEntry FROM ORDR WHERE DocNum = " + TextEdit.GetFromUID(pVal.Form , "8").Value;
using (System.Data.SqlClient.SqlDataReader sqlReaderx = SwissAddonFramework.B1Connector.GetB1Connector().ExecuteQuery(queryx))
{
if (sqlReaderx.Read())
{
lnDocEntry = sqlReaderx.GetInt32(0);
}
}
to be honnest i'm not comfortable with this solutions. Like i have the object oPO is it possible to get the DocEntry the moment i do the Add (via this object ) ?
thnx.
Anders Olsson
Hi Kurt,Yes there is a cleaner way. Check that oPO.Add returns 0 (success), then get the DocEntry like this:
string docEntry = string.Empty;
SwissAddonFramework.B1Connector.GetB1Connector().Company.GetNewObjectCode(out docEntry);
Regards,
Anders
kurt vanhauwaert
Thanks Anders for your reply
0
Please sign in to leave a comment.
Comments
0 comments