function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sekhar 131sekhar 131 

Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Enter the Year of Passing: []

hi 
this my error in backend and this error message dispaly the frented message.
how to dispaly the frented message

Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Enter the Year of Passing: []
Saravanan RajarajanSaravanan Rajarajan
Hi Sekhar,
 
Looking at this "Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You must select an Organization or Contact: []" error, there might be a validation rule on that object, which is causing record insert problem.


Please try below code.
Apex:-
if (fieldname == null)
{
    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));
    return null;
} 
 
Insert the below tag inside the visualforce page within page block
 
<apex:pageMessages ></apex:pageMessages>


Please mark it best answer if it helps you.
 
Saravanan RajarajanSaravanan Rajarajan
Please try Use this code
<script type="text/javascript">
    function checkform()
    {
    var dateString = document.purchase.txndt.value;
    var myDate = new Date(dateString);
    var today = new Date();
         if (document.purchase.txndt.value == "")
          { 
          //something is wrong
          alert('REQUIRED FIELD ERROR: Please enter date in field!')
          return false;
          }
          else if (myDate>today)
          { 
          //something else is wrong
            alert('You cannot enter a date in the future!')
            return false;
          }
          // if script gets this far through all of your fields
          // without problems, it's ok and you can submit the form
          return true;
    }
</script>

Please mark it best answer if it helps you.