hello everyone,
i have searched the forums and read some of the post on this subject, but i still can't seem to get it to work. it seems very simple, yet i can't figure it out.
i have added a new field to the job table called Work Order. Every work order will be tied to a job number. The new field is type text 50. What I would like is if a new job is created, the work order field has to be filled.
i tried going into the job card form and changing the "delayed insert" property to yes, and then placing code in the OnInsert and OnModify triggers on the job table. The code is just either
TESTFIELD("Work Order");
or
IF "Work Order" = '' THEN
ERROR("Please insert a Work Order");
but when i try a combination of these things, i either can NOT create a new job b/c once i try to create a new job, i get the constant error message to fill in the work order, but i can't even click the new field on the form to change it, or the job is created and inserted and modified without having a Work Order or the error pops us and then the form closes.
I even tried to place those code bits in the OnValidate trigger of the new field Work Order.
I even read where someone metioned to :
I can suggest you another way:
1. Block Items after insert (field Blocked must be TRUE, and it couldn't be editable )
2. Provide some function to test the item
if required fields are not blank, then you "Unblock" item, in the other case
you can demand to fill up your field
I was wondering if there was a simplier solution? I must be missing something..it seems so basic, yet i can't get it.... ](*,) DOH!!!
0
Comments
OnCloseForm
TESTFIELD("Payment Terms Code");
This is fine for us.. I believe there is a mandatory post that doesn't allow the user to leave until it's entered. lemme see.....
ah found it...
http://www.mbsonline.org/forum/topic.as ... ORY,FIELDS
http://www.BiloBeauty.com
http://www.autismspeaks.org
hmmm....somehow the code from that link above allows you to create a new record and then when you hit the -> (next) button, you can create another new record, but when you try to close, it won't let you until you place a value into the "Work Order", which is what I want, but then somehow, it creates 2 records. the 1st one is missing a Work Order, but the 2nd one has it.... :-k
Here is the code that I used...
in OnQueryCloseForm ...
IF "Work Order" = '' THEN
ERROR('Please insert a value into the Work Order field for Job No. %1!', "No.");
in OnAfterGetRecord ... No. is the PK
IF ("No." <> xRec."No.") AND (xRec."No." <> '') THEN BEGIN
IF xRec."Work Order" = '' THEN BEGIN
Rec := xRec;
xRec.TRANSFERFIELDS(Rec);
CurrForm.UPDATE(FALSE);
MESSAGE('Please fill in the Work Order field!');
END;
END;
im assuming that "No." is the PK that you have to use, that is why I choose "No." b/c that is the PK in table Job. this may be the reason why i am getting that problem.
If you run this code and create 1 record at a time, it works like a charm...
I LOVE THESE FORUMS!!!!
in the trigger on_modify of table check the information and block the table if the value is not insered.
IF "Work Order" = '' THEN begin
blocked := true;
Message( 'item will be blocked because yod don't insert ..')
end;
I use this solution because i don't want to use the error, with error if you make 2 modify the sistem rallback all and this his a problem.
anyway there are other topic i the forum that speack about this problem
1. On the Property of the Field (In the table, Set "NOT BLANK" to True). This works only when you enter into the field (when the cursor is inside the field).
2. On the OnBeforePutRecord() Trigger of the Form, put a TESTFIELD to ensure that the value is set. It this is done, the system generates an error Whenever you do not put a value in the field.
This System will work whether you modify the record or not.
However, you may choose not to use a testfield to avoid Error Message. then you can use a message function to show the message.
where is my mistake?
for example
on my Vendor Card - to make sure Payment Terms Code is filled. When the user closed the form & the field is blank a message appears.
OnCloseForm()
TESTFIELD("Payment Terms Code");
http://www.BiloBeauty.com
http://www.autismspeaks.org
http://www.BiloBeauty.com
http://www.autismspeaks.org
You would think that since this has been part of Navision since at least 2.0, and since every user of Navision since the beginning of time has requested this option, that it would actually work without doing additional coding, but alas, it doesn’t work without extra coding.
Maybe in Navision 5.0 you will actually be able to set this property on a form and it will work
We can always hope.
what can i do to keep it open?
TESTFIELD does not stop the form from closing
http://www.mibuso.com/forum/posting.php ... te&p=17988
Doesn't help? Maybe you're doing something wrong?
http://www.BiloBeauty.com
http://www.autismspeaks.org
I suggest to make a new field, a checkmark, called "approved", put the checking of mandatory fields in the OnValidate, and tell users to check this field and their work is not finished until they manage to check it. Make a simple report showing "not approved" records and tell managers to check it every evening and shout the hair off people if it shows any records. Also make the name/description of the record red in the list form so others know that that record is not finished. If it is an Item, you can also block until it is approved.
Do It Yourself is they key. Standard code might work - your code surely works.
1. On the table (this example is using the Job table, Person Responsible column) put the following code on the OnValidate trigger of the column that needs to be mandatory:
IF ("Person Responsible" = '') THEN
IF (CONFIRM(error10, TRUE, FIELDCAPTION("Person Responsible"), "No.")) THEN
ERROR(error11, FIELDCAPTION("Salesperson Code"))
ELSE
Rec := xRec;
This will confirm with the user that the field is required and give them th option of reentering it. If they say yes, then the ERROR aborts the update to the table and keeps the form open. If they say no, then the form is closed and the record is set back to what it was prior to the field being updated.
2. Place the following code in the OnQueryCloseForm trigger of the Form:
VALIDATE("Person Responsible");
This forces the OnValidate trigger to fire even though the user has not entered anything in the field in question.
I hope this helps! Take Care! 8)
1. Set Form to DelayedInsert.
2. Create a Button called Save, code: IF NOT INSERT THEN MODIFY;
3. Create a function called SaveData, with code:
IF NOT CONFIRM(’Do you want to save changes?’) THEN ERROR(’’);
You can put TESTFIELD here for all the mandatory fields.
4. Put a call to SaveData to OnInsertRecord and OnModifyRecord.
What you got?
Whenever the user changes data and either moves away from the record or pushes save, the confirmation question aroses to protect against unwanted data entry, and then the fields are checked.
The reason it's a 95% right solution is that there is a minor inconvenienced that if the users gets an error message during a modify, all his changes are lost. However, during an insert, luckily, not, so it's not a big problem.
The message is displayed, but the form is also closed.
Now i tend to go for
http://www.mibuso.com/forum/viewtopic.php?t=9646
http://www.BiloBeauty.com
http://www.autismspeaks.org
I also try this type of coed.
Here I want to make Dimension code mandatory at the time of posting.
So I insert this code in G/L journal =>Post button =>Onpush trigger.
And it works very well.
Microsoft Certified Business Management Solutions Professional
Microsoft Certified Business Management Solutions Specialist
http://www.navisiontech.com
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Microsoft Certified Business Management Solutions Professional
Microsoft Certified Business Management Solutions Specialist
http://www.navisiontech.com