# Validating a flow field??

**URL:** <https://www.dynamicsuser.net/t/validating-a-flow-field/17583>\
**Category:** Developers Forum\
**Created:** [October 10, 2007, 4:54am UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583 "2007-10-10T04:54:06Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie\_niner](https://avatars.discourse-cdn.com/v4/letter/c/74df32/32.png) [@charlie\_niner](https://www.dynamicsuser.net/u/charlie_niner)\
**Post date:** [October 10, 2007, 4:54am UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/1 "2007-10-10T04:54:06Z")

</div>

Hi all

I’ve noticed the following behaviour when working with Item Budgets.

Form 7139 - Sales Budget Overview

CellAmount - OnAfterValidate

…  
ValueType::“Sales Amount”:  
BEGIN  
ItemStatisticsBuffer.CALCFIELDS(“Budgeted Sales Amount”);  
ItemStatisticsBuffer.VALIDATE(“Budgeted Sales Amount”,BudgetedAmount - ItemStatisticsBuffer.“Budgeted Sales Amount”);  
END;

…

Now the interesting bit to me was the validation of the ItemStatisticsBuffer.“Budgeted Sales Amount” field. This field is a flow field and is the sum of the “Sales Amount” field on the “Item Budget Entry” table.

When the ItemStatisticsBuffer.“Budgeted Sales Amount” field was validated, it resulted in a record being inserted in the underlying table (the “Item Budget Entry” table).

I don’t recall coming across this behaviour before. I didn’t think you could validate a flowfield and never really thought twice about doing it.

Can anyone shed a little more light on this behaviour and what is necessary to make it work?

Cheers

Craig

---

<div class="post-metadata">

**Author:** ![David\_Singleton](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/david_singleton/32/7471_2.png) [@David\_Singleton](https://www.dynamicsuser.net/u/David_Singleton)\
**Post date:** [October 10, 2007, 8:16am UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/2 "2007-10-10T08:16:46Z")

</div>

This is standard NAV behaviour, and has been part of Navision since the early DOS versions.

Basically what happens is that NAV looks at the current filters applied to the underlying source Table. It then looks at the sum of the records, and compares this to the number that you just entered. Now NAV creates a new Record in the source table, with a value that will then add up to the new total that you want. It then adds a new record.

For this to work, the Primary key of the source table must end in an integer.

This feature is mainly used for Budgets, in the Base App, but can I use it a lot for many other types of functions.

---

<div class="post-metadata">

**Author:** ![Anna\_Perotti](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Anna\_Perotti](https://www.dynamicsuser.net/u/Anna_Perotti)\
**Post date:** [October 10, 2007, 8:18am UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/3 "2007-10-10T08:18:24Z")

</div>

> [@](#):
>
> Hi all
> 
> I’ve noticed the following behaviour when working with Item Budgets.
> 
> Form 7139 - Sales Budget Overview
> 
> CellAmount - OnAfterValidate
> 
> …  
> ValueType::“Sales Amount”:  
> BEGIN  
> ItemStatisticsBuffer.CALCFIELDS(“Budgeted Sales Amount”);  
> ItemStatisticsBuffer.VALIDATE(“Budgeted Sales Amount”,BudgetedAmount - ItemStatisticsBuffer.“Budgeted Sales Amount”);  
> END;
> 
> …
> 
> Now the interesting bit to me was the validation of the ItemStatisticsBuffer.“Budgeted Sales Amount” field. This field is a flow field and is the sum of the “Sales Amount” field on the “Item Budget Entry” table.
> 
> When the ItemStatisticsBuffer.“Budgeted Sales Amount” field was validated, it resulted in a record being inserted in the underlying table (the “Item Budget Entry” table).
> 
> I don’t recall coming across this behaviour before. I didn’t think you could validate a flowfield and never really thought twice about doing it.
> 
> Can anyone shed a little more light on this behaviour and what is necessary to make it work?
> 
> Cheers
> 
> Craig

It actually is unusual, but not illegal. To validate a flowfield is just a way to execute some code put in the VALIDATE trigger. Why put it there is in the programmer’s mind - a place as good as any other.

What is really weird in this specifical case is that there is no code in the VALIDATE trigger of the “Budgeted Sales Amount”, actually there isn’t any code in the whole table. Funny.

---

<div class="post-metadata">

**Author:** ![David\_Singleton](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/david_singleton/32/7471_2.png) [@David\_Singleton](https://www.dynamicsuser.net/u/David_Singleton)\
**Post date:** [October 10, 2007, 8:30am UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/4 "2007-10-10T08:30:38Z")

</div>

> [@](#):
>
> It actually is unusual, but not illegal. To validate a flowfield is just a way to execute some code put in the VALIDATE trigger. Why put it there is in the programmer’s mind - a place as good as any other.
> 
> What is really weird in this specifical case is that there is no code in the VALIDATE trigger of the “Budgeted Sales Amount”, actually there isn’t any code in the whole table. Funny.

In terms of the actual Validation, this is required if the filters do not give enough data to generate the entry. You can then add some code of your own to fill bits in.

---

<div class="post-metadata">

**Author:** ![Anna\_Perotti](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Anna\_Perotti](https://www.dynamicsuser.net/u/Anna_Perotti)\
**Post date:** [October 10, 2007, 8:32am UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/5 "2007-10-10T08:32:39Z")

</div>

> [@](#):
>
> This is standard NAV behaviour, and has been part of Navision since the early DOS versions.
> 
> Basically what happens is that NAV looks at the current filters applied to the underlying source Table. It then looks at the sum of the records, and compares this to the number that you just entered. Now NAV creates a new Record in the source table, with a value that will then add up to the new total that you want. It then adds a new record.
> 
> For this to work, the Primary key of the source table must end in an integer.
> 
> This feature is mainly used for Budgets, in the Base App, but can I use it a lot for many other types of functions.

Now I understand what it’s all about! Thank you, David. [:)]

---

<div class="post-metadata">

**Author:** ![shep](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@shep](https://www.dynamicsuser.net/u/shep)\
**Post date:** [October 10, 2007, 8:58pm UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/6 "2007-10-10T20:58:18Z")

</div>

Hi

I’m still missing something here with my understanding of this feature? If all that was required was that the base table had to have an integer as it’s last field in the PK then validating the Balance field on the customer record would result in a new entry in the detailed customer ledger entry table, which is obviously a bad idea.

What have I missed? Thanks.

Shep

---

<div class="post-metadata">

**Author:** ![lars\_westman](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@lars\_westman](https://www.dynamicsuser.net/u/lars_westman)\
**Post date:** [October 10, 2007, 10:46pm UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/7 "2007-10-10T22:46:01Z")

</div>

Yes. It would create new entries.

Good thing that the balance field in the customer table isn’t editable then…

/Lars

---

<div class="post-metadata">

**Author:** ![shep](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@shep](https://www.dynamicsuser.net/u/shep)\
**Post date:** [October 10, 2007, 11:05pm UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/8 "2007-10-10T23:05:47Z")

</div>

After I did the post I tried this in a codeunit:

gRecCust.GET('NEW\_CUST);  
gRecCust.VALIDATE(gRecCust.Balance,10);

and sure enough a new detailed customer ledger entry was added for that customer. Not with any meaningful data but it did it.

Interesting in a scary kind of way. Thanks

Shep

---

<div class="post-metadata">

**Author:** ![DenSter](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/denster/32/7478_2.png) [@DenSter](https://www.dynamicsuser.net/u/DenSter)\
**Post date:** [October 11, 2007, 12:42am UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/9 "2007-10-11T00:42:32Z")

</div>

Yes very SCARY powerful, and obviously something you should be extremely careful with. Do NOT do this on the balance field (or any other field that sums any ledger entry tables for that matter), because it will %$#@ up your financial system.

---

<div class="post-metadata">

**Author:** ![David\_Singleton](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/david_singleton/32/7471_2.png) [@David\_Singleton](https://www.dynamicsuser.net/u/David_Singleton)\
**Post date:** [October 11, 2007, 1:08am UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/10 "2007-10-11T01:08:23Z")

</div>

This feature is nothing new, I have been using this since the DOS days. (Though the validate wasn’t exactly there then). But in terms of dangerous, its not different from anything else you can do. Try this code:

> GLEntry.Init;
> 
> GLEntry.Amount := 0.01;
> 
> GLEntry.INSERT;

Your database is not corrupt and unusable. This is why Application Builder is seperatd from Solution Designer. And why we have code units to call.

---

<div class="post-metadata">

**Author:** ![David\_Singleton](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/david_singleton/32/7471_2.png) [@David\_Singleton](https://www.dynamicsuser.net/u/David_Singleton)\
**Post date:** [October 11, 2007, 1:09am UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/11 "2007-10-11T01:09:28Z")

</div>

> [@](#):
>
> Yes. It would create new entries.
> 
> Good thing that the balance field in the customer table isn’t editable then…
> 
> /Lars

Hey Lars, great to see you back and active again [\<:o)]

---

<div class="post-metadata">

**Author:** ![shep](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@shep](https://www.dynamicsuser.net/u/shep)\
**Post date:** [October 11, 2007, 3:29am UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/12 "2007-10-11T03:29:59Z")

</div>

Hi David Scary because the difference between your example and the insert as a result of the validation on a flow field is that your code is explicit; the flow field insert happens in the background. I wouldn’t think it would be too hard to accidently validate a flow field with a value and then have a ledger entry inserted without your knowledge. Also scary because I’ve been working with Nav for 5 years and I’ve never seen this in the development documentation or twigged that it could happen. Another example of how much more there is to learn for me on this product and whenever I think I’ve got a handle on most things something like this harpoons my ego – thank heavens ! Shep

---

<div class="post-metadata">

**Author:** ![DenSter](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/denster/32/7478_2.png) [@DenSter](https://www.dynamicsuser.net/u/DenSter)\
**Post date:** [October 11, 2007, 1:50pm UTC](https://www.dynamicsuser.net/t/validating-a-flow-field/17583/13 "2007-10-11T13:50:11Z")

</div>

Nah don’t let it harpoon your ego. Just realize that there is always something else to learn. What is so great about these forums is that there is something you hadn’t thought of in some post every day. Why do you think we spend so much time in here? [:D]
