Mandatory Field by Code
Sebastian Schweer
Hallo,did anybody know, how i can make a field Mandatory by C# Code. For UDF and SAP-Standart-Field.
I unfortunately have found no Code example for it.
Can anybody help?
Best regards,
Sebastian
Paolo Manfrin
Hi Sebastian,as you've coresuite customize installed, right click on the field you want to make mandatory. The customize menu will appear and you can choose the option "make field mandatory" An optimizer rule will be created automatically and you can check the code as well.
Kind Regards,
paolo
Sebastian Schweer
Hallo Paolo,thanks for answering.
If i make a Field Mandatory by right click on this field, there will only be created an Rule with "Regex" code, but not C#.
I'd like to create an great C# File, in which i can bundle a lot of Rules. For example i have 10 Mandatory Fields for the Item Master Data and don't wan't to have 10 single Rules for it, but rather 1 great C# Rule witch shown like this:
Field1.mandatory = true;
Field2.mandatory = true;
... and so on.
Is there any chance to do it in C#?
Kind regards,
Sebastian
Paolo Manfrin
Here you are
try
{
string foreignName = TextEdit.GetFromUID(pVal.Form, "128").Value;
if (string.IsNullOrEmpty(foreignName))
{
MessageBox.Show("Foreign Name required", "OK");
return false; // abort commit
}
else return true; // commit
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "OK");
}
return true;
Triggers:
Validate
Form type 134
ItemUID 1
ItemPressed
FormMode MODIFY
hth
paolo
Sebastian Schweer
Hallo Paolo,thank you, that works. :D
But you also have to declare it as an "Before Event".
Otherwise the Item was add anyway.
Best Regards,
Sebastian
0
Please sign in to leave a comment.
Comments
0 comments