• sravya sadhu
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
whenever user enters data in email and move cursor to next field it has to call a webservice and validate email.If it is valid we have a field called email validity which is checkbox the result should display in this check like if it is valid Check if not uncheck. same thing for phone.But somehow iam able to call email but not phone.Could anyone help me plz.here is my code.

public with sharing class myController {

    public PageReference Cancel() {
        return null;
    }

    Account account;

    public Account getAccount() {
        if(account == null) account = new Account();
        return account;
    }
    
    public PageReference save() {
     
        // Add the account to the database. 
        insert account;
        // Send the user to the detail page for the new account.
        PageReference acctPage = new ApexPages.StandardController(account).view();
        acctPage.setRedirect(true);
        return acctPage;
        
       
    }
    public PageReference validEmailAddress() {
               
        if(account.Email__c != '') {
        account.Email_Validity__c= true;
        string baseUrl1 = 'http://fusionq-2022595240.us-west-2.elb.amazonaws.com/EmailValidator/webresources/verify?email='+account.Email__c;
      
         // Prepare request
        Http http = new Http();
        
        HttpRequest req = new HttpRequest();
        req.setMethod('GET');
        
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        req.setEndpoint(baseUrl1);
       
        //req.setMethod(method);
        req.setTimeout(60000);
        //req.setBody(postParams);
        
        try {
            HttpResponse res = http.send(req);
            // Analyze and log response.
            String response = res.getBody();
            System.debug('Method callApi response: ' + response);
            System.debug(res.toString());
            System.debug('STATUS:'+res.getStatus());
            System.debug('STATUS_CODE:'+res.getStatusCode());
            
            
            JSON2Apex obj = (JSON2Apex) System.JSON.deserialize(response, JSON2Apex.class);
            System.debug('obj::::::'+obj);
            System.debug('obj.verificationResults.entry[1].value::::::'+obj.verificationResults.entry[1].value);
            if (obj.verificationResults.entry[1].value == 'FAIL'){
                    account.Email_Validity__c= true;
            }
            for(integer i=0; i<obj.verificationResults.entry.size(); i++) {
                System.debug('obj.verificationResults.entry['+i+'].value::::::'+obj.verificationResults.entry[i].value);
            
                if(obj.verificationResults.entry[i].value =='FAIL') {
                     account.Email_Validity__c= false;
                     break;
                
                } 
             } 
        } catch(System.CalloutException e) {
            System.debug('CalloutException:'+e);
        
        }
        
        }
       return null;
       
      } 

    public PageReference validPhone() {
               
        if(account.Phone__c != '') {
        account.Phone_Validity__c= true;
       String baseUrl2 = 'http://fusionq-2022595240.us-west-2.elb.amazonaws.com/phonevalidator/webresources/service/phonenumber='+account.Phone__c;
         // Prepare request
        Http http = new Http();
        
        HttpRequest req = new HttpRequest();
        req.setMethod('GET');
        
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        req.setEndpoint(baseUrl2);
       
        //req.setMethod(method);
        req.setTimeout(60000);
        //req.setBody(postParams);
        
        try {
            HttpResponse res = http.send(req);
            // Analyze and log response.
            String response = res.getBody();
            System.debug('Method callApi response: ' + response);
            System.debug(res.toString());
            System.debug('STATUS:'+res.getStatus());
            System.debug('STATUS_CODE:'+res.getStatusCode());
            
            
            JSON2Apex obj = (JSON2Apex) System.JSON.deserialize(response, JSON2Apex.class);
            System.debug('obj::::::'+obj);
            System.debug('obj.verificationResults.entry[1].value::::::'+obj.verificationResults.entry[1].value);
            if (obj.verificationResults.entry[1].value == 'FAIL'){
                    account.Phone_Validity__c= true;
            }
            for(integer i=0; i<obj.verificationResults.entry.size(); i++) {
                System.debug('obj.verificationResults.entry['+i+'].value::::::'+obj.verificationResults.entry[i].value);
            
                if(obj.verificationResults.entry[i].value =='FAIL') {
                     account.Phone_Validity__c= false;
                     break;
                
                } 
             } 
        } catch(System.CalloutException e) {
            System.debug('CalloutException:'+e);
        
        }
        
        }
       return null;
       
      } 

    
    public class Entry {
        public String key;
        public String value;
    }
    public class JSON2Apex {

        public String contact;
        public String domain;
        public String emailAddress;
        public String errorText;
        public String mailHost;
        public String user;
        public VerificationResults verificationResults;


    }

    public class VerificationResults {
        public List < Entry > entry;
    }

Write a trigger to create a CAPA and Cortex/CAPA records when these conditions are met:
Confirmed Late Delivery field is ticked
Cortex/Order field equals Order
Delivered Status (Final) field = Delivered Late

When you are creating the CAPA record, populate the fields with these values:

CAPA field                                  Value

CAPA Status                              New
Date/Time CAPA created        Time record is created
Category                                     Corrective Action
Source                                         Late Delivery
Initial Description                       From hearing field Late Code (enter key)
                                                       From hearing field Late Code Sub Category (enter key)
                                                       From hearing field Reason for Late Delivery (enter key)
Immediate Action Taken           Wording always:  Transcript merged and sent.
Employee (s) Involved                From hearing field Merger Responsible
Hearing Number (s)                    Wording always: See CAPA Cortex records

If a following fields changes value and the linked CAPA has a Status that is not Closed and CAPA Source of “Late Delivery”, Quality Team would like to know about it. For the purpose of this test, please send email to llau@fortherecord.com.
- When Hearing.Confirmed Late Delivery is changed to unticked
- When Delivered Status is changed to a value that is not "Delivered Late"
- When Late Code is changed
- When Late Code Subcategory is changed

Hints:
Create your own email template (text only) with appropriate subject.


How get start with this and could you please provide me the code . as iam not aware od triggers and how to write triggers
Write a trigger to create a CAPA and Cortex/CAPA records when these conditions are met:
Confirmed Late Delivery field is ticked
Cortex/Order field equals Order
Delivered Status (Final) field = Delivered Late

This is the scenario .I am new to development could anyone explain how to get started with the task.
Write a trigger to create a CAPA and Cortex/CAPA records when these conditions are met:
Confirmed Late Delivery field is ticked
Cortex/Order field equals Order
Delivered Status (Final) field = Delivered Late

This is thje scenario.I just want to know how to get started.
Write a trigger to create a CAPA and Cortex/CAPA records when these conditions are met:
Confirmed Late Delivery field is ticked
Cortex/Order field equals Order
Delivered Status (Final) field = Delivered Late

This is thje scenario.I just want to know how to get started.