-1
I made an application in C# and to integrate with ERP Spring and passed the engine in VBA through the following line.
void IPublicMethods.UpdateCDU_IfItemSelected(ref dynamic doc, string artigo, int numLinha, ref dynamic plataformaPri, ref dynamic BSO)
{
//Variable to tell if a document must set the CDUs for MoedaRef
bool usaMoedaRef = false;
try
{
//Get the value from DocumentosVanda table that tell if the current document must set the CDUs for MoedaRef
plataformaPri.Dialogos.MostraAviso("Chegei!", Enums.PRI_Informativo, $"Cheguei antes do erro.");
usaMoedaRef = BSO.Comercial.TabVendas.DaValorAtributo(doc.Tipodoc, "CDU_UsaMoedaRef");
}
catch (Exception ex)
{
plataformaPri.Dialogos.MostraAviso("Erro!", Enums.PRI_Informativo, $"Ocorreu um erro ao calcular os preços {ex.Message}.");
}
}
And the VBA is like this
OpsMoedaRef.updateCDU_IfItemSelected Me.DocumentoVenda, artigo, numLinha, PlataformaPRIMAVERA, BSO
Where exactly does he make the mistake? Have you put any breakpoint to figure out where it is?
– João Martins
And do you really need to do this? It seems like you know what kind you’re going to get. Anyway, he doesn’t seem to be responsible for the mistake. Catching an exception like this is horrible in C#, I don’t know if this ERP forces you to do this atrocity.
– Maniero
@acamiloMoz: Don’t forget to mark the answers that help you validate :)
– Sérgio Sereno
João Martins The error occurs in the next line usaMoedaRef = BSO.Comercial.Tabvendas.Davaloratributo(doc.Tipodoc, "Cdu_usamoedaref"); because at runtime is not recognized Tabvendas as property or method of the BSO object.Comercial.
– acamiloMoz
Maybe the engine Commercial is not properly instantiated. If you follow @Sérgiosereno’s instructions you cannot have it functional?
– João Martins
Good, VBA does not work well with Dynamic, but if you use Object instead of Dynamic the popup well
– David Ferreira
@Davidferreira Ué, and I think the
dynamic
had been mainly created to interoperate with VBA and things like.– Maniero