Community
Showing results for 
Search instead for 
Do you mean 
Reply

Forcing red exclamation mark next to invalid fields

New Member
Posts: 5
Country: Australia

Forcing red exclamation mark next to invalid fields

Hi all,

 

Does anyone know if there's a way to force the red exclamation mark to display (the one that shows when a field is invalid and an attempt to save is made), using the SDK?

 

I've had a dig around at the events and various methods, but there doesn't seem to be anything there that implements the desired functionality.

 

We are trying to create dynamic mandatory fields, whereby someone might select a certain value from a dropdown field, and this subsequently makes a field mandatory (not in the literal Act! sense however).

 

On saving, there'll be code that checks the saved rules against what is entered, and if any rules fail, it will manually show the red exclamation mark.

 

So far we've just got it showing an error message box, but this isn't very practical nor is it user friendly.

 

Any ideas?

 

Thanks,

 

Alex

Copper Elite Contributor
Posts: 81
Country: Canada

Re: Forcing red exclamation mark next to invalid fields

I haven't tested this so I am not sure if this will work but in theroy if you can search through the controls in actApp.Controls and find the appropriate control for the field which generated that error, and then you should be able to create an image and place it next to that control.

Ahsan Khalid

Chief Technology Officer
Keystroke Quality Computing Inc.
www.keystroke.ca

New Member
Posts: 5
Country: Australia

Re: Forcing red exclamation mark next to invalid fields

Hi Ahsan,

 

Thanks for the reply. I've had a dig around, but can't see how I can grab a specific field (say the texbox that displays the contact's first name), and then add a control next to it.

 

Surely there's a way to trigger that red exclamation mark programmatically!

New Member
Posts: 5
Country: Australia

Re: Forcing red exclamation mark next to invalid fields

Just looking at this further, it appears as though there is a property that stores whether or not the red exclamation is shown, and what the message that accompanies it is.

 

These two properties are named ValidationError and ValidationErrorString, however both are set to ReadOnly. This is obviously where Act! indicates that the exclamation should be shown, but still can't quite figure out how it's doing that.

Copper Super Contributor
Posts: 86
Country: United_Kingdom

Re: Forcing red exclamation mark next to invalid fields


aplant92 wrote:

Just looking at this further, it appears as though there is a property that stores whether or not the red exclamation is shown, and what the message that accompanies it is.

 

These two properties are named ValidationError and ValidationErrorString, however both are set to ReadOnly. This is obviously where Act! indicates that the exclamation should be shown, but still can't quite figure out how it's doing that.


 

Hi Aplant92,

 

I've had a look at our documentation and I can't see that this method is publicly exposed.

This would go hand in hand with what you've already found that the propertly is only publicly exposed as read only as there is no set accessor.

 

My initial thought would be to go with what the other users have said which is to show your own control.

I can't remember the exact syntax but you should be able to use the .NET method FindControls to get hold of any field and take it from there. It's something like Control MyControl = FindControls(oApp, "FullNameEditor");

 

I'll see if I can get some clarification from the developers about this method to confirm if there are any other options.

 

Kind regards,

 

Sam.

____________________________________________________________

Unfortunately I no longer work for Swiftpage International. Please do not send any queries to this account.
New Member
Posts: 5
Country: Australia

Re: Forcing red exclamation mark next to invalid fields

Thanks, that would be much appreciated.

I did look at creating my own custom field control so I could manually control errors, but I cant seem to figure out how to display a "Field Value" dropdown box for the text field when using the designer, similar to what the Act! field controls have.

Any help on this would be very much appreciated.

Any further clarification on your controls suggestion? How would one go about adding an error image next to an existing control?
New Member
Posts: 5
Country: Australia

Re: Forcing red exclamation mark next to invalid fields

Just thought I'd update everyone here on my progress.

 

I was looking through the control lists yesterday, but figured there might be an easier way to do this. It would appear that there isn't, so I've gone with the following code:

 

void Fields_FieldChanged(string fieldName)
        {
            for (int i = 0; i < application.Controls[0].Controls[0].Controls[6].Controls.Count; i++ )
            {
                if (application.Controls[0].Controls[0].Controls[6].Controls[i] is NuPicklistControl)
                {
                    NuPicklistControl npc = (NuPicklistControl)application.Controls[0].Controls[0].Controls[6].Controls[i];
                    if (npc.FieldName == fieldName)
                    {
                        ErrorProvider ep = new ErrorProvider();
                        ep.SetError(npc, "This value is not valid!");
                    }
                }
            }
        }

What it does is loop through all controls on the current view (in this case, I've hardcoded the contact details view Controls collection), finds the control with the specified fieldName, and then throws a little red error image saying it isn't valid.

 

Obviously this doesn't actually do anything useful at the moment, but I now have the beginnings of what will hopefully be a Dynamic Mandatory Fields plugin.