Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Visualforce Development
- :
- Re: Field Message just doesn't work. Help!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Field Message just doesn't work. Help!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-05-2011 08:45 AM
Hi There.
I want to copy the standard behavior of field validation error on a visual force page.
here is my prototype:
Page:
<apex:page controller="Test">
<apex:form >
<apex:pageBlock title="Hello {!$User.FirstName}!">
<apex:inputtext value="{!ola}" id="e_validation"/>
<apex:commandButton action="{!save}" value="Save"/>
<apex:message for="e_validation" />
</apex:pageBlock>
</apex:form>
</apex:pageAnd the controller:
public with sharing class Test {
public String ola {get;set;}
public PageReference save(){
ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.ERROR,'test') );
return null;
}
}
Nothing happens when I click on save button. I expect that message 'test' appears bellow the inputtext component on visual page : (
Solved! Go to Solution.
Re: Field Message just doesn't work. Help!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-05-2011 09:25 AM
That's how apex:message is supposed to work I'm afraid.
I wrote a blog post that I think covers exactly what you are looking for at:
http://bobbuzzard.blogspot.com/2011/04/field-level
Certified Salesforce Technical Architect, Developer, Advanced Developer, Administrator, Advanced Administrator, Consultant, Sales Cloud Consultant,Service Cloud Consultant
Force.com MVP | The Bob Buzzard Blog | Linked In | Twitter
I don't respond to private messages/emails asking for help.
Take the Bob Buzzard Sobject Fields quiz.
Re: Field Message just doesn't work. Help!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-05-2011 11:04 AM
Thanks for your fast reply.
Apart of your very useful blog, can you tell me:
1. if this documentation example works:
http://www.salesforce.com/us/developer/docs/pages/
2. Do you have an idea how to send the message to an inputfield in the current page when the adderror() has to be called from a trigger on the child object?
With this line, I cancel the transaction and a message is placed on the top of the current page:
childobject.addError('Error: Field content is invalid');
I tried this:
childobject.parent__r.field__c.addError('Error: Field content is invalid');
and this
parentObject = [select field__c from parentObject__c where id = :childobject.parent__c];
parentObject.field__c.addError('Error: Field content is invalid');
both resulting in messages on top of the page.
Let me know if you need further detail to check this issue.
Thnaks in advance.
Re: Field Message just doesn't work. Help!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-07-2011 07:36 AM
i dont know if it helps but try adderror..
Re: Field Message just doesn't work. Help!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-07-2011 11:38 AM
If y read my code that is what I have done :smileywink:
Re: Field Message just doesn't work. Help!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-08-2011 04:51 AM
1. That does work, but it just puts coloured messages at the bottom of the page I think.
2. I'm not sure how easy its going to be to add an error to a field from that trigger. I'd expect the error needs to be added to the object + field combo that is present on the page. At the point that the trigger fires, you don't have access to that object instance. Querying another one back and adding errors is unlikely to help. Can you post a bit more detail about the scenario.
Certified Salesforce Technical Architect, Developer, Advanced Developer, Administrator, Advanced Administrator, Consultant, Sales Cloud Consultant,Service Cloud Consultant
Force.com MVP | The Bob Buzzard Blog | Linked In | Twitter
I don't respond to private messages/emails asking for help.
Take the Bob Buzzard Sobject Fields quiz.
Re: Field Message just doesn't work. Help!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-08-2011 05:37 AM
Hi.
1: So it is not expected that it puts some message at field level, i.e., below the visualforce connected to the field. : (
2. For now I am throwing a custom exception from the trigger so I can catch it on the controller and I can do
soBj.adderror('MyErrorStringTopofThepage');
soBj.field.adderror('MyErrorStringFieldLevel');
However I am facing a liitle problem:
At the top of the page are appearing both messages which seems be natural once i am adding errors to the object.
I would want to setup different independent messages for top page and for field level but I think it demands another type of customization. Some ideas?
Re: Field Message just doesn't work. Help!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-08-2011 05:42 AM
1. I don't think I had an expectation when I tried it. I didn't find it useful though, which is why I spent some time trying to understand how all that works.
2. Are you putting the errors at the top of the page using apex:pageMessages? if so, I think that does duplicate it.
We've used our own error div at the top of the page and simply added items to a string that gets output inside that div.
Certified Salesforce Technical Architect, Developer, Advanced Developer, Administrator, Advanced Administrator, Consultant, Sales Cloud Consultant,Service Cloud Consultant
Force.com MVP | The Bob Buzzard Blog | Linked In | Twitter
I don't respond to private messages/emails asking for help.
Take the Bob Buzzard Sobject Fields quiz.
Re: Field Message just doesn't work. Help!
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-08-2011 05:51 AM - edited 08-08-2011 05:53 AM
yeah. The use of a div or something is the kind of customization I was talking about.
For now It will stays this way. I am checking deeply your blog later so I can purpose an alternative customized solution. Meanwhile tanks very much for your support.
Regards

