When attempting to save a purchase document with the following code on a V10 DEMO database with an external application ...
var documento = new CmpBE100.CmpBEDocumentoCompra();
documento.Tipodoc = "VGR";
documento.Serie = "A";
documento.Entidade = "F0001";
documento.TipoEntidade = "F";
ErpEngine.Compras.Documentos.PreencheDadosRelacionados(documento);
documento.NumDocExterno = "A-1234";
documento.DataDoc = DateTime.Today;
documento.DataIntroducao = DateTime.Today;
double qty = 10;
string warehouseCode = "A1";
string location = "A1";
ErpEngine.Compras.Documentos.AdicionaLinha(documento, "A0001", ref qty, ref warehouseCode, ref location, 0, 0);
Engine.PrimaveraEngine.ErpEngine.Compras.Documentos.CalculaValoresTotais(documento);
string avisos = "";
Engine.PrimaveraEngine.ErpEngine.Compras.Documentos.Actualiza(documento, ref avisos);
Debug.WriteLine (avisos);
... the method Updates () throws an exception:
System.Exception HResult = 0x80131500 Message = Error integrating the Document into the Inventory. One or more validation errors were detected during model generation: Spring.Inventory100.Entities.MasterTaskInfo:: EntityType 'MasterTaskInfo' has no key defined. Set the key for this EntityType. Spring.Inventory100.Entities.VariationMasterTask:: EntityType 'VariationMasterTask' has no key defined. Set the key for this EntityType. MasterTaskInfoes: EntityType: EntitySet 'MasterTaskInfoes' is based on type 'MasterTaskInfo' that has no keys defined. VariationMasterTasks: EntityType: EntitySet 'VariationMasterTasks' is based on type 'VariationMasterTask' that has no keys defined. Source = CMPBS100 StackTrace: at CmpBS100.CmpBSCompras.Updates (CmpBEDocumentoCompra com clsDocCompra, String & strAvisos, String & IdDocLiqRet, String & IdDocLiqRetGar) at CmpBS100.CmpBSCompras.Actualiza (CmpBEDocumento compra clsDocCompra, String & strAvisos) at Moving2U.PrimaveraEngine100.Engine.PrimaveraEngine.Test () in C: \ dev \ m2uvso \ m2uLogistics \ Legacy \ V4.5-dev \ Integration \ M2uLogisitcsIntegration.PrimaveraV10 \ Moving2U.PrimaveraEngine100 \ Engine \ Engine.cs: line 494 ... Inner Exception 1: ModelValidationException: One or more validation errors were detected during model generation: Spring.Inventory100.Entities.MasterTaskInfo:: EntityType 'MasterTaskInfo' has no key defined. Set the key for this EntityType. Spring.Inventory100.Entities.VariationMasterTask:: EntityType 'VariationMasterTask' has no key defined. Set the key for this EntityType. MasterTaskInfoes: EntityType: EntitySet 'MasterTaskInfoes' is based on type 'MasterTaskInfo' that has no keys defined. VariationMasterTasks: EntityType: EntitySet 'VariationMasterTasks' is based on type 'VariationMasterTask' that has no keys defined.
If you create a document of this type in the Spring itself with the same data, the document is written without errors. Does the same code work in Spring V8 / V9, is it missing something in the code or in the company settings?