Validate FlowField

WojtekmWojtekm Member Posts: 123
Hi Guys,

I`ve made new table with field:
"Used on PO Lines"
type: flowfield
CalcForlula: Count("Purchase Line" WHERE ([Field1]=FIELD(No.)))

Then i`ve add smoe code in OnModify trigger like:
OnModify()
CALCFIELDS("Used on PO Lines", 
           "Used on SO Lines", 
           "Used on Purch. Inv. Lines", 
           "Used on Sales Inv. Lines");

VALIDATE("Used on PO Lines",0);
VALIDATE("Used on SO Lines",0);
VALIDATE("Used on Purch. Inv. Lines",0);
VALIDATE("Used on Sales Inv. Lines",0);

And when i modify record in this table i`ve got an error:
"The CalcFormula (...) should start with 'Sum...('"

My question is why i can not validate this field?

What i need is to check if this record were used in posted or unposted documents.
And then prevent user to modify records which were used.

How to make NAV work that way?

Best regards,
Wojtekm

Comments

  • matttraxmatttrax Member Posts: 2,309
    You can't tell the system what value to put in a flowfield. It has to calculate it.

    Perform a CALCFIELDS on your flow fields, check their value, and throw an error if necessary. You can read more about flow fields in the NAV Client Help or the Application Designer's Guide on the product cd.
  • WojtekmWojtekm Member Posts: 123
    Of course you right.

    :oops:

    I need to use TESTFIELD function instead of VALIDATE.

    regards,
    Wojtekm
  • BeliasBelias Member Posts: 2,998
    Correct, use testfield, or IF statements toghether with ERROR if the condition is more complex.
    about the error text you got, i'll give you a little explanation about why the system tells you about 'Sum...'
    (it's not recommended but possible) :-$
    flowfields can actually be modified, but only if they're flowfield of type Sum. Anyway, the result is horrible, you can try it by yourself if you want. :wink:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Belias wrote:
    about the error text you got, i'll give you a little explanation about why the system tells you about 'Sum...'
    (it's not recommended but possible) :-$
    flowfields can actually be modified, but only if they're flowfield of type Sum. Anyway, the result is horrible, you can try it by yourself if you want. :wink:


    :shock: why is it not recommended. I use this FEATURE a lot, its documented and used in many places in the base app. Definitely the result is NOT horrible, it works great. :-k :-k :-k :-k
    David Singleton
  • BeliasBelias Member Posts: 2,998
    note: i'm not telling that it's buggy, it works as expected.

    anyway, in my opinion it's risky in some cases, for example i tried to modify the balance field of a customer (some years ago, as a test), resulting (as expected) in additional incomplete detailed customer ledger entries.
    I am personally not confident in using this feature, and i've never felt the need to use it.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Belias wrote:
    I am personally not confident in using this feature, and i've never felt the need to use it.

    You need to get over this. :mrgreen:

    I have seen your posts over the years, and you appear to know Navision very well. If I was a customer would feel confident having you doing complex and risky stuff on my database. :thumbsup:

    I know that I warn beginners not to do a lot of things, but once a person knows where to look out in Navision they need to start using that skill and knowledge and make great solutions for their customers. As you start trying more and more you learn simpler ways to do many things and thus create simpler solutions that are more stable, are easier to upgrade and have a much lower "cost of ownership" for the customer.

    Many of the things I tell people not to do are things that I have done myself.
    David Singleton
  • BeliasBelias Member Posts: 2,998
    I have seen your posts over the years, and you appear to know Navision very well. If I was a customer would feel confident having you doing complex and risky stuff on my database. :thumbsup:
    Thanks for this :oops:

    anyway, if you say you've used this feature proficiently, i'll try to use it, if i have the occasion, and i'll also take much care in suggesting things i don't know so well :whistle:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.