Chapter 4: Posting C/SIDE Solution Development

seff_yohansonseff_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 :)


  • seff_yohansonseff_yohanson Member Posts: 23
    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 all
  • IsitarIsitar Member Posts: 29
    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.

    Greetings from Switzerland
  • seff_yohansonseff_yohanson Member Posts: 23
    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.

  • IsitarIsitar Member Posts: 29
    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.
      Code xy
      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
      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
          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);
          // 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);
        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"
            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("Unit Price",SeminarCharge."Unit Price");
              VALIDATE("Total Price",SeminarCharge."Total Price");
          Description := SeminarCharge.Description
      EXIT(JobLedgEntry."Entry No.");

    I hope this helps and it is a correct solution :)
    Greetings from Switzerland
  • DenSterDenSter Member Posts: 8,300
    I find that the learning materials not very well written at all
    You have to understand that the training materials are not designed for self-study, they are designed for an instructor led class. The trainer would provide the objects for the exercises, and they would also explain what Isitar figured out as part of the training for this chapter.

    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.
  • DenSterDenSter Member Posts: 8,300
    Isitar wrote:
    I hope this helps and it is a correct solution :)
    Great thinking there, and exactly the type of thing you have to do. Look at an existing process and model your own solution after that.

    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.
  • seff_yohansonseff_yohanson Member Posts: 23
    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 Isitar :)
Sign In or Register to comment.