You need to sign in to do that
Don't have an account?
cl0s3r
How to handle an On Click
I have a custom VF Button on my Opportunties. How can I validate if the custom button has been clicked within a Trigger? If the button is clicked I would like to verify if a custom field is null or not.
Change your constructor to
This will work for you.
All Answers
Are you using native page layout or custom vfp where this button is?
The button is just referencing the custom vf page so I can gather records via the custom controller, I think I can just validate if the field is null via the controller but I am not sure how to post a custom msg to the screen of the Opportunity.
Ia ma not getting your issue, Do you want to show error detected in trigger to be shown at vf page? Could you elaborate your issue a bit more?
It isnt an error, I want to validate if a field is null and post to the screen a msg requesting additional info.
You can add error using many ways
1)Simplest is :
2)
But these message will only be visible on the page if you have page message in your page
Add this just after form tag if you don't have it.
I am definately getting closer, I have added the Apex.AddMessage() function and the msg is still not displaying on the page. I was thought theissue was a little more strait forward so I didnt include code, but I have inclded the code to assist with my explanation.
When I run the code I get the following,
"
Visualforce Error
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Opportunity.Implementation_Contac__c
Class.ProdCase.prodDetails: line 48, column 31 Class.ProdCase.prodDetails: line 19, column 32 External entry point
"
Change your constructor to
This will work for you.
That worked like a charm!
Good to know it worked for you :)
How do you suggest to debug using Eclipse since the force.com plug-in doesnt support break points? I am now sufferning from code coverage issues!
I did not get you, If you are facing test coverage issue , I would suggest you should write a test class. And for debuging you have to use system.debug() statements and you can check debug logs to verify results.
LIke
Integer i = 100/2;
system.debug('****** value of i : + i);