Writing data to a flow field

ptech5443ptech5443 Member Posts: 28
I am looking for a way to write data to a flow field. I am creating a process only report that updates a flow field. The problem is that after the report runs the flow field is not changed. I have stepped through the code as the report runs. I can see the flowfield value change but as the report loops through the data item the value changes back to zero. I have tried a modify, insert and commit after updating the field and nothing seems to change. Does anyone know if it is even possible to write data to a flow field in code? If it is possible then how?

Answers

  • awarnawarn Member Posts: 261
    Why would you want to update a flowfield? By definition, a flowfield 'flows' data from somewhere else.

    If you want to be able to update the field, then either make a new field or change the field to not be a flowfield.

    Or, change the underlying formula.

    So if the flowfield is say the customer name, based on the customer number, and it looks up to the customer table, then you cant change the flowfield, but if you go GET the customer record, and update the Name field, then your flowfield will change. Of course it will also change for every other flowfield that looks up to the name...

    Maybe you should post more of what you are trying to do.

    -a
  • ptech5443ptech5443 Member Posts: 28
    I have built a custom table for scheduling. The table has a flow field, Mon Avail Hrs, with the following calcformual: Sum("Res. Capacity Entry".Capacity WHERE (Date=FIELD(Mon Date),Resource No.=FIELD(Resource Filter),ResourceOfficeCode=FIELD(Office Filter),Scheduled Resource=FILTER(Yes))). The resource capcity is the underlying table. I am trying to take advantage of the Navision feature that will allow you to enter data in the flow field and it will create the entry in the underlying table. It will save me from writing the process to filter the resource capacity table and loop through each date to find how many hours the resource has for a capcity already and determine the difference to enter.
  • krikikriki Member, Moderator Posts: 9,118
    ptech5443 wrote:
    I am trying to take advantage of the Navision feature that will allow you to enter data in the flow field and it will create the entry in the underlying table.
    This is only possible if the flowfield and the table on which it works. I think the table needs as primary key an integer like "Entry No." and to write to it you have to validate the value into it I think. Check out F113, behind the "CellAmount - OnAfterValidate()"-trigger.

    awarn and others : it is possible to write data to the DB through a flowfield, but only few people know this obscure feature. And it is easily forgotten. Just a few days ago, a collegue reminded me of the feature. :oops:
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • DenSterDenSter Member Posts: 8,307
    If for instance you have a sum type flowfield into another table, and you enter a value into the flowfield, then Navision will create an entry in the target table to make the flowfield true.

    So if you make the customer balance editable, and the customer balance is 0, and you enter 25 into the field, Navision will write a Customer Ledger Entry for the "missing" 25.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    This feature is often used to easily create budgets or job/resource planning.
  • DenSterDenSter Member Posts: 8,307
    DenSter wrote:
    So if you make the customer balance editable, and the customer balance is 0, and you enter 25 into the field, Navision will write a Customer Ledger Entry for the "missing" 25.
    You should of course NEVER MAKE LEDGER ENTRY TABLES EDITABLE in a production environment. I wrote this as an example of how it would work. To play around with this you should create your own 'entry' table with a sumindex field, and a flowfield into the table somewhere else. If I remember correctly, there are exercises for this in the development training material.
  • 2tje2tje Member Posts: 80
    Have a look at the Job module. Escpecially the Job Budget Entry.
    This functionality is a good example of standard Navision. You can make a Job planning and create entry records by modifying data in a matrix.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    And the financial budgets (Form 113) 8)
  • kinekine Member Posts: 12,562
    for ptech5443:

    in my opinion it is not possible do that by C/AL. You will need to insert the entry in standard way through the C/AL. This behavior is only for entering the data through visual components...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Maybe it is worth to try with evaluate???
  • ptech5443ptech5443 Member Posts: 28
    I got it to work. Thanks for your help. The "it" is that I am "loading" the capacity for resource for scheduling. I am writing the capacity to flowfileds in a custom table where the flow is coming from the Res. Capacity Entry table. The Navision feature is taking care of the entry. There was a current process in place that was writing to the Res. Capacity Entry table. The problem was that users where running the process multiple times for the same resource. This would cause the capacity to double. The new design allows for the process to be run multiple times without the doubling.

    The design of the report is as follows: I created a process only report that has two data items. The first being the Resource and the second being the Date. In the date data item is the logic for finding the period name and date. after determining that I have a case statement

    CASE "Period Name" OF
    'Monday':
    BEGIN
    CompanySchedule.CALCFIELDS("Mon Avail Hrs");
    CompanySchedule.VALIDATE("Mon Avail Hrs",DailyHours[1]);
    END;
    'Tuesday':
    ......

    The DailyHours[1] is coming from the options tab of the request form of the report. With this report I am creating a capcity for the resource on a daily basis. I am able to populate 8 hours per day for an entire year in about 8 seconds.
  • kinekine Member Posts: 12,562
    Ok, now I will know that it is possible... :-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    That is the fun of this board. It beats any training course :mrgreen:
Sign In or Register to comment.