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
bharath kuppalabharath kuppala 

in this class i need to add mandatory field is missing and if date format is not yyyy-mm-dd it should show error and deal status field value must be submited by default. can you help me out for this

@RestResource(urlMapping='/DealRegistration/*')
global with sharing class Ebuy_DealReg
{
    @HttpPost
    global static String doPost(String Youremail, String DealStatus, String DealName, String CustomerBudget, Decimal ExpectedRevenue,  
                               Date ExpectedBookingDate, String SourcedbyMarketing, Date ProjectImplementationDate,
                                String MarketingCampaign, String DealDescription, String ProposedAlcatelLucentSolution, String Product,
                                String CustomerName, String Address1, String Address2, String ZipCode, String City, String Country, String StateProvince,
                                String Phone, String Salutation, String CustomerContactLastName, String CustomerContactFirstName, String CustomerContactemail,
                                String CustomercontactRole, String NeworExistingCustomer, String ExistingCustomerSolutionVendor, String ExistingCustomerProduct,
                                String CurrentsolutionReseller, String CurrentsolutionRelease, String CurrentSolutionAge, String Additionalcomments) 
    {
        String response = '';
        
        Deal__c del = new Deal__c();
        
        del.BP_Email__c = Youremail;
        del.Status__c = DealStatus;
        del.Name = DealName;
        del.CustomerBudget__c = CustomerBudget;
        //del.CurrencyIsoCode = Currency;
        del.Estimated_Revenue__c = ExpectedRevenue;
        del.Expected_Booking_Date__c = ExpectedBookingDate;
        del.Sourced_By_Marketing__c = SourcedbyMarketing;
        del.Project_Implementation_Date__c = ProjectImplementationDate;
        del.Campaign_Name__c = MarketingCampaign;
        del.Deal_Description__c = DealDescription;
        del.Proposed_Alcatel_Lucent_Solution__c = ProposedAlcatelLucentSolution;
        del.Product__c = Product;
        del.Company_Name__c = CustomerName;
        del.Street1__c = Address1;
        del.Street2__c = Address2;
        del.ZipCode__c = ZipCode;
        del.City__c = City;
        del.Country__c = Country;
        del.State_Province__c = StateProvince;
        del.Phone__c = Phone;
        del.Salutation__c = Salutation;
        del.Customer_Contact_Last_Name__c = CustomerContactLastName;
        del.Customer_Contact_First_Name__c = CustomerContactFirstName;
        del.Customer_Contact_email__c = CustomerContactemail;
        del.Customer_contact_Role__c = CustomercontactRole;
        del.New_or_Existing_Customer__c = NeworExistingCustomer;
        del.Existing_Customer_Solution_Vendor__c = ExistingCustomerSolutionVendor;
        del.Existing_Customer_Product__c = ExistingCustomerProduct;
        del.Current_Release__c = CurrentsolutionReseller;
        del.Current_solution_Release__c = CurrentsolutionRelease;
        del.Solution_Age__c = CurrentSolutionAge;
        del.AdditionalComments__c = Additionalcomments;
        
    try
        {
            Insert del;
            response = del.Id;
        }    
        catch(Exception ex)
        {
            system.debug('@@@ Exception Message = ' + ex.getMessage());
            //response = ex.getMessage();
            if(response.contains('REQUIRED_FIELD_MISSING')) {
                response = 'REQUIRED FIELD MISSING';
              
            }
            else
            {
                response = ex.getMessage();
            }
            
            
        }
        
        return response;        
        
    }
}