Chapter 4: Posting C/SIDE Solution Development

seff_yohanson
Member Posts: 23
Hi guys,
I am trying to work through the materials to pass this exam, but having trouble working out where the values come from when creating one of the codeunits.....
P43 of chapter 4 states
11. Enter code in the PostJobJnlLine function trigger so that the
function performs the following tasks:
* Gets the Instructor, Resource, and Customer records that
correspond to the Seminar Registration Header record.
Instructor is simple as there is an instructor code on the Seminar Registration Header, but which field do I use to get the Resource and customer records? Are they related tables?
Thanks in advance for your help
I am trying to work through the materials to pass this exam, but having trouble working out where the values come from when creating one of the codeunits.....

P43 of chapter 4 states
11. Enter code in the PostJobJnlLine function trigger so that the
function performs the following tasks:
* Gets the Instructor, Resource, and Customer records that
correspond to the Seminar Registration Header record.
Instructor is simple as there is an instructor code on the Seminar Registration Header, but which field do I use to get the Resource and customer records? Are they related tables?
Thanks in advance for your help

0
Comments
-
Alternatively, is there anywhere to download the code to refer back to when I get stuck? I find that the learning materials not very well written at all0
-
Hi seff
Currently I'm alsow trying to finish this book and got stuck at the same page as you....
I think you can get the Resource from the Instructor. (Instructor."Resource No.") but I'm not sure.
About the Customer I have no idea how you can get it.
Cheers
IsitarGreetings from Switzerland0 -
Hi Isitar,
Thanks for your reply - i'm glad i'm not the only one! It just seems that some very straight forward things are explained in alot of detail, then some very complex items just say "go away and write the functionality for this....".
Some can be copied from existing funcionality of course, but sadly some can't. It would be good to have the code as an example to refer back to if stuck.
Thanks,
Marc0 -
Hi Marc
I think I found a solution
After I had a look at Codeunit 80 (Sales-Post) I found out, that the function was always called in a loop of SalesLine.
So to adapt this, this function will always be called in a loop of SeminarRegLines.REPEAT Code xy PostJobJnlLine(ChargeType); Code xy UNTIL SeminarRegLine.NEXT = 0;
So I think this code could be a solution:Instructor.GET(SeminarRegHeader."Instructor Code"); Resource.GET(Instructor."Resource No."); Customer.GET(SeminarRegLine."Bill-to Customer No."); WITH JobJnlLine DO BEGIN INIT; VALIDATE("Job No.",SeminarRegHeader."Job No."); // this is not from the book, I just added this code VALIDATE("Gen. Bus. Posting Group",Customer."Gen. Bus. Posting Group"); VALIDATE("Entry Type","Entry Type"::Usage); VALIDATE("Document No.",PstdSeminarRegHeader."No."); VALIDATE("Seminar Registration No.",PstdSeminarRegHeader."No."); VALIDATE("Source Code",SourceCode); VALIDATE("Source Currency Total Cost",SeminarRegLine."Seminar Price"); CASE ChargeType OF ChargeType::Participant: BEGIN VALIDATE("No.",Resource."No."); Description := Customer.Name; VALIDATE("Unit of Measure Code",Resource."Base Unit of Measure"); VALIDATE(Chargeable,SeminarRegLine."To Invoice"); // Qty VALIDATE("Qty. per Unit of Measure",1); VALIDATE("Quantity (Base)",1); VALIDATE(Quantity,1); // Cost VALIDATE(JobJnlLine."Direct Unit Cost (LCY)",0); VALIDATE(JobJnlLine."Unit Cost (LCY)",0); VALIDATE(JobJnlLine."Total Cost (LCY)",0); VALIDATE(JobJnlLine."Total Cost",0); // Price VALIDATE(JobJnlLine."Unit Price (LCY)",SeminarRegLine.Amount); VALIDATE(JobJnlLine."Total Price (LCY)",SeminarRegLine.Amount); VALIDATE(JobJnlLine."Unit Price",SeminarRegLine.Amount); VALIDATE(JobJnlLine."Line Amount",SeminarRegLine.Amount); END; ChargeType::Charge: BEGIN CASE SeminarCharge.Type OF SeminarCharge.Type::Resource: BEGIN Type := Type::Resource; "Unit of Measure Code" := SeminarCharge."Unit of Measure Code"; "Qty. per Unit of Measure" := SeminarCharge."Qty. per Unit of Measure" END; SeminarCharge.Type::"G/L Account": BEGIN VALIDATE(Type,Type::"G/L Account"); VALIDATE(Chargeable,SeminarCharge."To Invoice"); VALIDATE("Quantity (Base)",1); VALIDATE(JobJnlLine."Unit Cost (LCY)",0); VALIDATE(JobJnlLine."Total Cost",0); VALIDATE(Quantity,SeminarCharge.Quantity); VALIDATE("Unit Price",SeminarCharge."Unit Price"); VALIDATE("Total Price",SeminarCharge."Total Price"); END; END; VALIDATE("No.",SeminarCharge."No."); Description := SeminarCharge.Description END; END; JobJnlLine.INSERT; JobJnlPostLine.RUN(JobJnlLine); JobLedgEntry.findlast; EXIT(JobLedgEntry."Entry No."); END;
I hope this helps and it is a correct solutionGreetings from Switzerland0 -
seff_yohanson wrote:I find that the learning materials not very well written at all
I do agree that it is annoying that the objects don't come with the training material. It would be really helpful to have those.0 -
Isitar wrote:I hope this helps and it is a correct solution
A few things to understand:
The amounts in local currency are usually calculated through the validation code. So if there is an "Amount" and an "Amount (LCY)" field, validating the "Amount" field should be sufficient, and the validation code in that field would take care of the (LCY) amount. Likewise with the "Quantity" and "Quantity (Base)" fields. The validation code in the "Quantity" field should trigger logic to calculate the base quantity. Take a look at the validation in the "Sales Line" table to see how that works. There are functions in there that update quantities and amounts, and these are called from various field validations.
This is usually only done when entering values in the unposted documents. As you can see in codeunit 80, when these values are transferred from the unposted document to the Journal for posting, the values are not actually validated. The system at this point trusts the values in the unposted document, since the field validation has already been done at that time, and the document has had a final validation through the release process.
Make sure you know the big picture: at what point in the process are values validated, and don't over validate.0 -
Great, thank you both. I did refer to exiting code for some situations where I got stuck, and to check I had done it correctly but missed this section, so this should help.
I see now it doesnt always make sense if it is for an instructor lead course! Although it has still been invaluable in teaching myself.
Good luck Isitar0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions