Get Data from unposted Document
Sebastian Schweer
Hi Everybody,
I need to create a validation for an Invoice Document. The validatio must run, before the document is added.
Means, I need to get the document total, compare it to some conditions and then allow/block the adding of the document.
My Problem is now to get the relevant information.
If I try to get the value from UID like this
TextEdit.GetFromUID(pVal.Form,
"29").Value.ToString();
than the system returns the value to me including the currency sign, like "100.00 EUR". But I don't want to have the currency signs in there. And I can not use substring, because the currency can be different from time to time and it can also be on the right or left side of the value.
My next thought was, to get the information directly from the document object like this:
SAPbobsCOM.Documents oInv = (SAPbobsCOM.Documents)
SwissAddonFramework.B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
oInv.GetByKey(xy); // DocEntry needed
StatusBar.WriteSucess("oInv Total: " + oInv.DocNum.ToString()
);
This will work perfectly if I had a DocEntry which that I can use to connect to the object.
For documents already posted to the database this is no problem, because I can get the DocEntry via Database Selcet.
But how I can connect to an UNPOSTED Document where I have no Doc Entry?
Did anybody have a solution for me?
Or did anyone maybe have an other solution for me, how to get the data?
Best Regards,
Sebastian
Paolo Manfrin
Hi Sebastian,
the framework contains some classes to help you in that :)
Check the following script:
string amount = TextEdit.GetFromUID(pVal.Form, "29").Value;
StatusBar.WriteSucess(amount);
SwissAddonFramework.Utils.Misc.Money money = SwissAddonFramework.Utils.Misc.ConvertStringToMoney(amount, SwissAddonFramework.Utils.Misc.FORMAT.CURRENT);
StatusBar.WriteSucess("Cleaned amount is " + money.Amount.ToString());
hth
paolo
Sebastian Schweer
Good Morning Paolo,
that really works :D
Thanks for your fast support! Have a nice day :)
Sebastian
Please sign in to leave a comment.
Comments
0 comments