You need to sign in to do that
Don't have an account?
SS Karthick
Trigger and Validation Error in Visualforce page using JavaScript Remoting
Hi folks,
Can anyone tell me how to catch the trigger and validation error in visualforce page using javascript remoting?
I wanna sample code to catch the trigger or validation error in visualforce using java script remoting.
Thanks in advance
Karthick
Can anyone tell me how to catch the trigger and validation error in visualforce page using javascript remoting?
I wanna sample code to catch the trigger or validation error in visualforce using java script remoting.
Thanks in advance
Karthick
in java script remoting you would be calling @RemoteAction method which would return you error string and there you can use try catch block and return a error string, based on that error string you can show the error in java script.
//controller
public class ErrorHandler{
@RemoteAction
public static String errorWhileInserting(){
String error = '';
try{
//insert statement;
}
catch(Exception e){
error=e.getMessage();
}
return e;
}
}
//page
<apex:page controller="ErrorHandler" >
<script>
//call it on some event
function onclickFunction(){
ErrorHandler.errorWhileInserting(function(result, event){ if(event.status) {
document.getElementById("result").innerHTML = result(your error message); }
});
}
</script>
</apex:page>
All Answers
I have seen this link..
I have to know about how to handle the trigger error in javascript remoting
Please help!
i.e.
} else if (event.type === 'exception') { document.getElementById("responseErrors").innerHTML = event.message + "<br/>\n<pre>" + event.where + "</pre>"; }
thanks for your response.
Can you share your mailid,skype id to my mail(pskarthick.sonacse23@gmail.com)
Because i've lot of doubts in salesfoce
Thanks in advance
Karthick
in java script remoting you would be calling @RemoteAction method which would return you error string and there you can use try catch block and return a error string, based on that error string you can show the error in java script.
//controller
public class ErrorHandler{
@RemoteAction
public static String errorWhileInserting(){
String error = '';
try{
//insert statement;
}
catch(Exception e){
error=e.getMessage();
}
return e;
}
}
//page
<apex:page controller="ErrorHandler" >
<script>
//call it on some event
function onclickFunction(){
ErrorHandler.errorWhileInserting(function(result, event){ if(event.status) {
document.getElementById("result").innerHTML = result(your error message); }
});
}
</script>
</apex:page>