C/SIDE Solution Development: When to use validate

CaponeCapone Member Posts: 125
Hi!

I'm studying to the C/SIDE Solution Development exam and during my studies I can't really get a grip on when to use validate.

Don't get me wrong, I know how to use validate it is more a philosophical on how often I should use it.

I have almost stopped using := instead I use validate. Sometimes it has happened that I need to write some validation code in a trigger but then I realise that the coder before haven't been using validate when given the field the value which means that I have to go through all code that has := and replace it with validate which could be a time consuming process.

In the C/SIDE Solution Development examples they mostly use := unless they know they have trigger code that want to run with validate.

What are your opinions about validate? Do you prefer it over := or do you only use it when you need it?
Hello IT, have you tried to turn it off and on?
Have you checked the cables?
Have you released the filters?

http://www.navfreak.com

Answers

  • CaponeCapone Member Posts: 125
    Thanks! Exactly what I was looking for but I had hoped for an more simplier answer but they usually aren't :)
    Hello IT, have you tried to turn it off and on?
    Have you checked the cables?
    Have you released the filters?

    http://www.navfreak.com
  • DenSterDenSter Member Posts: 8,307
    I don't agree with the gimmicky message in that blog post at all, it simplifies this issue way too much. There's no hard and fast rule as to when to use it and when not to. It's up to you, you have to decide whether to validate a field or if you want to take care of associated values in your code.

    One very common modification is to automate certain steps, like some process that automatically creates an order based on certain parameters. I usually start with actually doing the process manually myself, and note what all happens during the process. simulating a manual process often is a series of strategically placed VALIDATE statements. You'll be amazed at how much happens automatically behind the scenes when you validate field values. Setting up a completely valid sales header for instance can be as simple as doing an INSERT(TRUE), and then validating the Sell-to Customer, the External Document number. Then on the line rarely does a user need to do more than enter an Item number and a Quantity, and maybe 1 or 2 other fields. By simply validating those fields, you can automate that process very quickly.

    On the other hand, there are some functions that are called repeatedly (Quantity and Amount update functions for instance), so it pays to investigate each process and see if you can find those and change it to simple assignments. HOWEVER, if you DON'T validate, then you WILL need to take care of business logic in code. Most of the time though, VALIDATE is a very powerful tool to make sure that business logic runs properly.
  • Alex_ChowAlex_Chow Member Posts: 5,063

    The article written is not good advice and I do not recommend any person taking that article seriously.

    The rule is to use VALIDATE when there are coding behind the fields you're modifying. There are exceptions to the rule, but not many cases.

    The order of what fields to validate is important too if you're inserting or modifying a table like item journal or general journal.
  • CaponeCapone Member Posts: 125
    The article by itself is not good but the discussion in the comment section is good. It makes you aware of the pros and cons about using validate.
    Hello IT, have you tried to turn it off and on?
    Have you checked the cables?
    Have you released the filters?

    http://www.navfreak.com
  • lvanvugtlvanvugt Member Posts: 774
    Hey guys, the article (my writing) was intended to get that discussion. I see you are critical, and yes you should. But then also read the series I wrote on validation and then you could understand what I meant all together. There I also explain what Daniel suggest to
    DenSter wrote:
    start with actually doing the process manually myself, and note what all happens during the process
    and various validations ...
    DenSter wrote:
    are called repeatedly (Quantity and Amount update functions for instance), so it pays to investigate each process and see if you can find those and change it to simple assignments
    BTW: I only stumbled across this thread today :shock:
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
Sign In or Register to comment.