Autofill a boolean field

LeroyLeroy Member Posts: 199
Dear folks, I've two fields in a table, field1 is an option field (and flowfield also) and field2 is a boolean field. Also there is a form on appear these fields. I'd like that when on filed1 option was, for example, "All" the field2 autofill as true. It's possible to do i?. Also I don't very clear is I've to do it on open form or in table.
Thanks for help.

Comments

  • AlbertvhAlbertvh Member Posts: 516
    Hi Leroy,

    Put this code in the AfterValidate of Field1
    Field2 := Field1 = Field1::All;
    


    Hope this helps

    Albert
  • LeroyLeroy Member Posts: 199
    Thanks for reply. But I need that field2 became TRUE automatically if the condition meets. It's possible?.
    Thanks for help.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Use this code in Onvalidate of Field 1


    IF F1 = F1::"All " THEN
    F2 := TRUE
    ELSE
    F2 := FALSE;
  • AlbertvhAlbertvh Member Posts: 516
    Hi Leroy,

    The Field2 will automatically become TRUE or FALSE. You must put the coding in the form in the OnAfterValidate Triggr of Field1.



    Albert
  • LeroyLeroy Member Posts: 199
    Thanks both for help, but it doesn't work. I'll try it in onValidate of field1 from table and fonValidate of field1 from form and also OnAfterValidate form form, and doesn't work, field2 don't appear as TRUE. Any idea else please?.
    Thanks for help.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    write dis code in Field 1 onafter validate trigger in frm

    Field2 := Field1 = Field1::All;
  • LeroyLeroy Member Posts: 199
    Thanks, but I had already written and doesn't work.
    Thanks for reply.
  • AlbertvhAlbertvh Member Posts: 516
    Hi Leroy

    maybe put a CurrForm.UPDATE(FALSE); after the code


    Albert

    Edit Maybe also put the code in AfterGetCurrRecord of the form
  • satraja2004satraja2004 Member Posts: 45
    Hi,
    IF F1 = F1::"All " THEN
    F2 := TRUE
    ELSE
    F2 := FALSE;
    This code works fine, try with using debugger
    Thanks & Regards

    Raja.B
  • satraja2004satraja2004 Member Posts: 45
    place this code in onvalidate trigger of that option field
    Thanks & Regards

    Raja.B
  • DenSterDenSter Member Posts: 8,304
    write dis code in Field 1 onafter validate trigger in frm
    No never write this type of code on the form [-X .

    This is validation logic, and it should be in the table's field validation code.
  • LeroyLeroy Member Posts: 199
    Thanks everybody for help. Finally I've put the following code on AfterGetCurrRecord of the form and have worked!!!, but with a little problem.
    field2:= field1= field1::All;
    IF field1=field1::All THEN
    field2:=TRUE
    ELSE
    field2:=FALSE;
    

    When I get into the form field2 has became TRUE, that is correct, but the form has created me a new line (because it's a list form) exactly equal to the other line but with field2 on FALSE :shock: . I know it's very strange but this is that occurs. Any idea about it please?.
    Thanks for help.
  • garakgarak Member Posts: 3,263
    edited 2009-02-19
    other question:
    Why do you need this?
    You can't, with this solution here, filter on the field2 because you set it to true if the flowfield (!) field1 has the option "ALL".
    So on list forms, for example you must enable the flowfield field1 to set the field2 <- but this will not be transmitted to the table self, because there is no modification. You can only filter on field1. So you doesn't need a field in the table you only need a Checkbox on the form.

    So the question is: Why do you need this whats the reason????
    Do you make it right, it works too!
  • DenSterDenSter Member Posts: 8,304
    That's the kind of behavior that you get by putting validation code on forms. Before you know it, you put code all over the place to correct unwanted behavior.

    Do yourself a favor and put this validation code in the table.
  • AlbertvhAlbertvh Member Posts: 516
    I agree with DenSter put all validations in the table validations


    Albert
  • LeroyLeroy Member Posts: 199
    Thanks everybody. But If I put de code on OnValidate from table it doesn't work; only do something on form.

    I'll try to explain because I want to do this. The reason is because in this form I put a customer and after inform serveral fields; when I don't need this customer I've created a boolean field that cancel this line and then this customer is not taken into account for other processes.
    When a customer is blocked as All (in Customer table) my form don't let insert this customer. The problem is that I can insert a customer but this customer can be blocked as "All" after, then obviusly can't be taken into account for other preccess; then I need something that automatically look for is this customer is blocked and cancel field ticks automtically.
    Sorry if I have not explained well.
    Thanks for help.
  • DenSterDenSter Member Posts: 8,304
    Leroy wrote:
    Thanks everybody. But If I put de code on OnValidate from table it doesn't work; only do something on form.
    Then you haven't figured out a way to do it. Whether code is on the form or in the table shouldn't matter. Besides, you haven't been able to make it work on a form either... It's your system to screw up and it looks like you're not going to take our advice to put this in the table.

    If you want to get better at this, then listen to the people that you asking advice from. Just saying "that doesn't work" is of no help for us to figure out what you might have to do differently. Maybe you can share with us what code you are using, in which trigger, and what exactly the error message is. Those can all be clues to troubleshoot your problem.

    One more time: this type of validation code should be in the table
  • jversusjjversusj Member Posts: 489
    Leroy wrote:
    Thanks everybody. But If I put de code on OnValidate from table it doesn't work; only do something on form.

    I'll try to explain because I want to do this. The reason is because in this form I put a customer and after inform serveral fields; when I don't need this customer I've created a boolean field that cancel this line and then this customer is not taken into account for other processes.
    When a customer is blocked as All (in Customer table) my form don't let insert this customer. The problem is that I can insert a customer but this customer can be blocked as "All" after, then obviusly can't be taken into account for other preccess; then I need something that automatically look for is this customer is blocked and cancel field ticks automtically.
    Sorry if I have not explained well.
    Thanks for help.

    i am not sure if i understand exactly what you mean, but let me see if i have it straight:
    you have some fields on the sales header that trigger certain downstream processes. the system will not allow a sales order to be created for a blocked customer, so your downstream processes should only be seeing customers that are not blocked. However, since you can create an order AND THEN block the customer, your downstream processes do end up seeing orders that they should not.

    if this is the case, i think you should put some code in the OnValidate of the Blocked field of the customer table. this code would cycle through the sales order for this customer and change the flagging fields as necessary.

    so, you would initially set these flags with code OnValidate trigger of some field in the Sales Header table, and modify them from the OnValidate of Blocked from the customer table.

    Is this what you want to do?
    kind of fell into this...
  • SavatageSavatage Member Posts: 7,142
    the main point of the putting the code on the table is that it will always work regardless of how that field is accessed.

    For example - down the road - another form might be used to activate that field and if you forget to add your code - the 2nd part will not work. If for whatever reason you need to go directly to the table to make a change the 2nd part will not work. so you can put the code on the table ONCE. or remember to add the code everywhere you access that field & never make a change directly in the table.

    If it's not working then your simply doing something wrong. Don't bail on it beacuse you got the form to work.
  • LeroyLeroy Member Posts: 199
    Thanks everybody for reply; reading your comments maybe the problem is that I'm focusing on bad. I'll pick all your suggestions and I'll see what are the best possibilities.
    Thanks for your help and time.
Sign In or Register to comment.