Greetings all, admitted newbie here slogging through creating my first set of extensions in BC.
I created a couple of tables to calculate commissions and need to move data from one to the other when an invoice is created from an order. The 2 tables are "Order Commissions" and "Invoice Commissions" Both files have the same setup with 2 field keys (Order No/Seq and InvoiceNo/Seq) I have the logic all figured out on taking 1 Order Commissions record, changing the order number to Invoice Number, and inserting the record into the Invoice Commissions table. Invoice commissions table has 2 extra fields, #7 for storing invoiced amount, and #8 for Commission calculated.
So the issue at hand is an order might have more than 1 order commissions record. I've been experimenting with "Order Commission.findset(false, false) as a record reference expression, but I only seem to hit 1 record. How can I get this code to loop through multiple records in the Order Commissions table?
Code shown below:
May I ask, possible, a stupid question like WHY do you do all these stuff SO complex? Do you want to play with RecordRec and FieldRef?
And to understand how many records do you select just change temporary the //OrderComm.FindSet(false, false); to "message(format(OrderComm.Count)));" and then debug all ftuff
LOL, because I'm just discovering how to do any of this. It would be great to stumble on the most efficient way to do things right off the bat, right?
Funny you should comment right now. I figured out I should use SetFilter instead of SetRange. Works like a charm EXCEPT now I'm getting database errors as I try to overwrite the existing records. Some other logical issue to deal with. Tomorrow. It's getting late and my brain is fried for today!
It absolutely makes no sense at all to use RecordRef and FieldRef and I hope that what you are developing is purely for "fun learning" and not an actual development request from a customer. Unless you have a very good reason to do it like this.. then this is the most stupid way of doing it (sorry, i know i am rude) Secondly RecordRef and FieldRef are very slow compared and should only be used in very special situations.
What part of 'newbie' did you not understand? Good lord, I'm a beginner at this with NO training at all and I got this far. Is it the most efficient way to do this? Obviously not, but I don't know a better way. So thank you for your advice, but I am asking for help. If you have a suggestion, I would appreciate it if you shared. If not, feel free to ignore the pleadings of a beginner.
BTW, I am not in this for a 'customer'. I am a customer. I'm doing this for my team because my MSP's programmer took another job and they are short handed. I'm trying to make a go live deadline and I'm doing my best.
If you have gotten No training at all - then stop yourself! You can easily make more damage than good. There's a reason why people get training, and do this for a living.
What you are doing is something that others has done for more than a decade, and I would strongly suggest that you find someone that knows BC and Development - What you do in days/week this person will be able to do in a few hours/days - making your deadline easier to reach, and with the right solution. But if it has nothing to do with "reaching a deadline" - Be my guest, and continue your work. Having said that - forget about RecordRef and FieldRef this is ONLY for VERY experienced developers.
I you want to work with a table /record then use that record in your code!
Change your OrderComm to a tablerelation as "Order Commision" like you did with the Sales Lines.
Take a look at e.g. Table 18 Customer, Table 36 Sales Header og 37 Sales Line.
Hi GTOGuy64,Please check out the e-books on development, I am also not a pro developer, but have some basic knowledge and for past 3 months, I am working as a one man bad, where I do everything regarding the NAV for an end-user and I am reading ebooks that help me to write the code...
I have a subscription and reading this book
https://subscription.packtpub.com/book/application-development/9781789137798 -admin, please do not bank me for posting the link to the paid service:)
I am sure you can find e-book and code as you read.
Thank you very much. I was going to buy that book a few weeks ago, but for whatever reason I hesitated. Now I'm glad! I'm starting my trial on packtpub today.
BTW, in my defense I have been an IT pro, developing a bunch of minor apps using antique technology - RPG and the like. A lot of the concepts of OOP aren't natural to me. Am I being wise moving forward on my own? Maybe not. But I have successfully modified several tables and pages, created a few triggers that work fine, and am learning every day. I am a one man shop in a 50 person organization, and it isn't technically even my job. I am responsible for the day to day operation, on top of watching and maintaining our It infrastructure and moving to a new ERP platform. I'm a busy guy.
We fully understand that you are a busy guy.(ofcource). You are trying to do something that is really not within your current range of knowledge, and therefore you are spending a lot of time.
I, myself knows a something about cars and repairing - but I would never spend 10-20 hours of fixing my car if someone else can do it in matter of 1 or 2 hours - unless I do it for fun.
Your time is probably better spent in doing something that you are an expert in and if you really want to do BC development - go get a training class - what you learn in a week wil save you months of googling/reading time - trust me I've been there myself.If you don't know much about BC then take a look at www.usedynamics.com and/or at youtube where you will find more than 350 videos.
Here is also an free online course from Microsoft:
Here is how to start it after the download: https://community.dynamics.com/365/b/learningcurriculum/posts/how-to-run-a-downloaded-course
I think people should support newbies more. There is a lack of information on Business Central for Developers compared to other Programming Languages / Systems.
Imagine a world where you can learn BC online without paying a fortune for workshops in countries someone may not afford to travel to.