Some item fields are mandatory fields. We have to ensure it.

Some item fields are mandatory fields. We have to ensure, that these fields are always filled if an
item is created or modified.

The item card (form 1) has to be changed, so that if somebody pushes the button (edit
button) and modifies an item or creates an new one and after that pushs the button
(save button) there is a proof if the following fields are NOT empty. If one of them is empty there has
to be an error message as stated below.

Mandatory fields:
Field No. Field Name Caption
1 Name.

2.Address

Error Message should display:
“Please enter ”+Captions of the empty mandatory fields

You can’t create mandatory fields in Navision simply by a property. Possible solutions:

1 - Make them mandatory for example during a posting routine.

2 - Don’t allow insert insert direcetly in Item card. Create some kind of wizard to insert items. Take for example wizard in Marketing for creating to-do’s. In that way you can create mandatory fields.

Also try to serach in this forum about that subject. You will find out many posts about that subject.

Hi,

Nav does not come with a “Save” button, so you must have had some modification to have these fields.

If that is the case you need a testfield on the fields in question on the push of the edit button. You won’t get the exact error message you requrie, but this is the standard way of Nav telling you that you should enter a value.

Press F1, search for TESTFIELD and DON’T add it to OnAfterGetRecord :wink:

T

A simple train of thought would be to have the BLOCKED field set to true on insert.
Then don’t let it be unchecked if any of your fields that you need mandatory are blank.

you can use testfield

[Y] this is also my prefered method.

I just read this again, and see that it might have looked like I suggested adding the “Save” button. I meant that I got the impression they had already had a save button implemented!

Having a Blocked default to yes and adding the testfields on there would be cleaner for sure.

T

Here is another idea:

It is not like mandatory but more recommended and reduce some time of form design.

As you know in some systems recommended fields are marked with “*”

With a little modification in CU1 and it is possible to set a property of a field to “recommended” so that it this is visible to the user.

The property I mean is Caption Class:Set Property (for example in field Name of table customer) “Caption class” to

  • ‘4,1,18,2’ = recommended = returns Caption + “*” or

  • ‘4,0,18,2’= no changes (is not essentials)

Explanation

  • 4= Set recommended

  • 1= Yes

  • 18 = TableNo

  • 2 = FieldNo

Insert a new function in CU 1 called “Recommendedfields”

Source:
RecommendedFields(Recommended : Text[30]) : Text[80]
//get the values
CommaPosition:= STRPOS(Recommended,’,’);
IF (CommaPosition > 0) THEN BEGIN
DimCaptionType := COPYSTR(Recommended,1,CommaPosition - 1);
DimCaptionRef := COPYSTR(Recommended,CommaPosition + 1);
CommaPosition := STRPOS(DimCaptionRef,’,’);
IF (CommaPosition > 0) THEN BEGIN
DimOptionalParam1 := COPYSTR(DimCaptionRef,CommaPosition + 1);
DimCaptionRef := COPYSTR(DimCaptionRef,1,CommaPosition - 1);
CommaPosition := STRPOS(DimOptionalParam1,’,’);
IF (CommaPosition > 0) THEN BEGIN
FieldTableNoText := COPYSTR(DimOptionalParam1,1,CommaPosition - 1);
DimOptionalParam1 := COPYSTR(DimOptionalParam1,CommaPosition + 1);
CommaPosition := STRPOS(DimOptionalParam1,’,’);
FieldNoText := COPYSTR(DimOptionalParam1,CommaPosition+1);
END;
END;
//get the field caption
EVALUATE(FieldTableNo,FieldTableNoText);
EVALUATE(FieldNo,FieldNoText);
FieldTable.RESET;
FieldTable.SETRANGE(FieldTable.TableNo,FieldTableNo);
FieldTable.SETRANGE(FieldTable.“No.”,FieldNo);
IF NOT FieldTable.FINDFIRST THEN
EXIT;
//Set to recommended or not
CASE DimCaptionType OF
‘4’:
BEGIN
CASE DimCaptionRef OF
‘0’:; //no changes in caption
‘1’: EXIT(FieldTable.“Field Caption” + ‘’); // change caption with '’ or ‘Recommended’
END;
END;
END;
END;

CaptionClassTranslate(Language : Integer;CaptionExpr : Text[80]) : Text[80]
CommaPosition := STRPOS(CaptionExpr,’,’);
IF (CommaPosition > 0) THEN BEGIN
CaptionArea := COPYSTR(CaptionExpr,1,CommaPosition - 1);
CaptionRef := COPYSTR(CaptionExpr,CommaPosition + 1);
CASE CaptionArea OF
‘1’ : EXIT(DimCaptionClassTranslate(Language,CaptionRef));
‘2’ : EXIT(VATCaptionClassTranslate(Language,CaptionRef));
‘3’ : EXIT(CaptionRef);

’4’ : EXIT(RecommendedFields(CaptionExpr)); NEW!!

END;
END;
EXIT(’’);

Thanks Rega, That could come in handy. Glad i went through this post.

Hi!

I forgot one function at the end in the posting …-> UPPERCASE

EXIT(**UPPERCASE(**FieldTable.“Field Caption”)… or whatever you want to do!

regards,

Rene

We have red color on all our mandatory fields to make sure users fill them in. Seems to work very good. We make sure to tell all the users red fields must be filled in.

It seems to be useful to us.

can you guide what are the variable to be defined in locals. I defined some of from the code still giving some error on tableno & field caption varialble not define in C/AL global.

Hey, to which reply is your question related? :wink:

Hey Rene,

at the top of all threads is a button “Change View” here you can change to a threaded view, there you can see execlty which reply was made to which post.

hey david!

thx for this info!

Rene

Savatage, excellent solution for mandatory item fields. I love the “automate standard functionality” approach.

On a similar “mandatory fields” topic… Would you suggest coding in CU 414 & 415 for document mandatory fields? Something like a “CheckMandatoryFields” function to keep it from being released and thereby posted?