Autofill a boolean field

Leroy
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.
Thanks for help.
0
Comments
-
Hi Leroy,
Put this code in the AfterValidate of Field1Field2 := Field1 = Field1::All;
Hope this helps
Albert0 -
Thanks for reply. But I need that field2 became TRUE automatically if the condition meets. It's possible?.
Thanks for help.0 -
Use this code in Onvalidate of Field 1
IF F1 = F1::"All " THEN
F2 := TRUE
ELSE
F2 := FALSE;0 -
Hi Leroy,
The Field2 will automatically become TRUE or FALSE. You must put the coding in the form in the OnAfterValidate Triggr of Field1.
Albert0 -
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.0 -
write dis code in Field 1 onafter validate trigger in frm
Field2 := Field1 = Field1::All;0 -
Thanks, but I had already written and doesn't work.
Thanks for reply.0 -
Hi Leroy
maybe put a CurrForm.UPDATE(FALSE); after the code
Albert
Edit Maybe also put the code in AfterGetCurrRecord of the form0 -
Hi,IF F1 = F1::"All " THEN
F2 := TRUE
ELSE
F2 := FALSE;Thanks & Regards
Raja.B0 -
place this code in onvalidate trigger of that option fieldThanks & Regards
Raja.B0 -
mohana_cse06 wrote:write dis code in Field 1 onafter validate trigger in frm
This is validation logic, and it should be in the table's field validation code.0 -
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.0 -
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!0 -
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.0 -
I agree with DenSter put all validations in the table validations
Albert0 -
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.0 -
Leroy wrote:Thanks everybody. But If I put de code on OnValidate from table it doesn't work; only do something on form.
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 table0 -
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...0 -
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.0 -
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions