Flowfields and sumindex

superjmasuperjma Member Posts: 10
Hi I got a problem concerning flowfields and sumindexes.

The problem is that I need some information on "Job Ledger Entry" and do not want to modify all the codeunits.

Therefore I used a Flowfield to get this information. But now I can't make any sums based on a filter on that field.

I tried this code with no luck.
JobLedgEntryRec.SETRANGE(Type,JobLedgEntryRec.Type::Resource);
JobLedgEntryRec.CALCFIELDS("Resource Type");
JobLedgEntryRec.SETRANGE("Resource Type",JobLedgEntryRec."Resource Type"::Machine);
JobLedgEntryRec.SETRANGE("Entry Type",JobLedgEntryRec."Entry Type"::Usage);
JobLedgEntryRec.SETRANGE("Job No.","Job No.");
JobLedgEntryRec.SETRANGE("Phase Code","Phase Filter");
JobLedgEntryRec.SETRANGE("Task Code","Task Filter");
JobLedgEntryRec.SETRANGE("Step Code","Step Filter");
JobLedgEntryRec.SETRANGE(Type,"Type Filter");
JobLedgEntryRec.SETRANGE("Posting Date","Date Filter");
JobLedgEntryRec.CALCSUMS("Total Price");

I hope someone are able to help me out here.

Comments

  • kinekine Member Posts: 12,562
    There is some error or what?

    :?:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,307
    Are you sure that the fields you are trying to do a CALCSUM on are sumindexfields? Are you sure that the key that those fields are attached to is active?
  • superjmasuperjma Member Posts: 10
    Yes. An error occur.

    The problem is that Resource Type is a flowfield (lookup) which is not possible to use in a key.

    Thats why I use CALCSUMS instead of CALCFIELDS.

    When I run it an error occur saying that my filter includes a flowfield which is not possible.

    This is why i'm stucked, because none trigges are runned when the entries are generated and therefore the only way to receive the information from the resource is to use a lookupfield.
  • DenSterDenSter Member Posts: 8,307
    Ah well that's not possible then. The Resource Type is a custom field right? I don't have this field in my standard Cronus database.

    If you have to be able to use the field in a CALCSUM, then you will have to change the job posting routine to populate the Resource Type instead of setting it as a flowfield, and put some code in the OnModify of the Resource table to update all ledger entries if the resource type is changed, or disallow the field to be changed if there are outstanding ledger entries, similar to the way you can't change the Base Unit of Measure on the Item if there are Item Ledger entries.
  • superjmasuperjma Member Posts: 10
    Well, thats exactly my problem. I do not want to change any posting routine, because I do then have to modify all posting routines, including CU 12, 80 and 202 which mean a lot of touble when the customer have to upgrade in the future.

    Are there any other way to do this.
    Copy the resultset to a tmp table and do the calcfield on that.
    Or is that too slow? (This is for analysis purpose)

    Any suggestions are welcome.
  • DenSterDenSter Member Posts: 8,307
    The only posting routine to create job ledger entries should be codeunit 202, and populating that field would be one line of code.
Sign In or Register to comment.