Select to view content in your preferred language

Programatically Make a field Mandatory

2317
3
03-25-2013 07:24 PM
KierenTinning1
Deactivated User
I'm looking to make a field mandatory.

I know I can do so within the database by setting the field to Null not allowed. But does anyone know how to do this in code? I.e. have ArcGIS Mobile display the 'Red Dot'?

Thanks,
0 Kudos
3 Replies
KierenTinning1
Deactivated User
Well for anyone who is interested.

Another bit of a hack, but prior to opening my EditAttributesDialog the code iterates through the fields and sets AllowNulls to false and then writes in System.DBNull.Value

this causes the field to be in an invalid state and therefore it shows with a Red Dot in the EditAttributesDialog. Not pretty and not perfect, but it works
0 Kudos
KimGicasvili1
Occasional Contributor
Hi Kieren,

Do you have any sample code you could share? I am looking at doing the same with some workflows that require particular fields to be mandatory for 1 particular workflow but not for another.

Thanks

Kim
0 Kudos
KierenTinning1
Deactivated User
Kim,

The way I have it working is I look for the field then set AllowNull to false and then write in a Null value which forces the field into an invalid state causing ArcGIS Mobile to make it mandatory

                        if (dc.ColumnName.Equals("MATERIAL"))
                        {
                            dc.AllowDBNull = false;
                            fdr[dc.ColumnName] = System.DBNull.Value;
                        }

As for the workflows, I base it on the project name (for my current work), so depending on the project name different combinations of fields are set to mandatory. If you using a different "value" to base you workflows on then I can certainly help you out.

Kieren
0 Kudos