• Soumyaranjan Pati 10
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
How to integrate fax(any third party) with Salesforce?
hi   can anybody help me to write Test class for this Trigger  and trigger handler class (after update)
custom object(Meeting__c in this checkbox field defult checked) 
scenario:if opportunity stage is 'closed own' or 'closed lost' then meeting__object check box is unchecked

opportunityTrigger
trigger opportunityFactoryTrigger on Opportunity (after update) {
  opportunityFactoryTriggerHandler.doAfterUpdate(trigger.new,trigger.newMap);
    
}

opportunityFactoryTriggerHandler​
public  class opportunityFactoryTriggerHandler {
     public static void doAfterUpdate(List<Opportunity> oppRecList, Map<Id, Opportunity> newMap){
      List<Meeting__c> mettingRecList1 = new List<Meeting__c>();
      List<Meeting__c> meetingRecListToBeUpdated = new List<Meeting__c>();
      mettingRecList1 = [SELECT Id, Opportunity__c FROM Meeting__c WHERE Opportunity__c IN :newMap.keySet()];
        for(Opportunity oppRec : oppRecList){
               if(oppRec.StageName == 'Closed Won' || oppRec.StageName == 'Closed Lost' ) {
                    for(Meeting__c meetingRec : mettingRecList1) {
                        if(meetingRec.Opportunity__c == oppRec.Id) {
                          meetingRec.Outcome_Flag__c = false;
                          meetingRecListToBeUpdated.add(meetingRec);
                        }    
                        
                    }
                    
                } 
         } 
          update meetingRecListToBeUpdated; 
    }     

}

 

I have here two VFP's one for Edit and one for Detail.

 

On Detail is a button called 'Edit' which opens the Edit page.

 

On the Edit page is a button called 'Save' and a button 'Cancel'. When i click the Save button, it saves the edited record  and navigates to the Detail page as defined in the save() method, however the Edit button on the Detail page is not displayed. Even the Cancel button navigates to where I was but the Edit button disappears from the Detail Page.

 

I thik there's some conflict between StandardController and the extension.

 

Can someone please takle a look and tell me what I doing wrong  .

 

Thanks.

 

 

Detail Page 

<apex:page standardController="Transaction__c" extensions="TransactionsCtrl" id="thePage" >
<apex:pagemessages />
<apex:form id="theForm" >  
     <apex:pageBlock id="detailsPB" title="Details" mode="detail">
          <apex:pageBlockButtons id="detailButtons" location="top" >
          <apex:commandButton id="editBtn" value="Edit" action="{!edit}" />    
          </apex:pageBlockButtons>
<apex:pageBlockSection title=" AUDIT RESEARCH" columns="2" id="pgBlckSct1">
    <apex:outputField id="rescodeFld" value="{!transaction.Research_Code__c}"/>
    <apex:outputField id="mancloseFld" value="{!transaction.Manually_Close_Y_N__c}"  />
</apex:pageBlockSection> 
</apex:pageBlock> 
</apex:form>
</apex:page>



Edit Page 

<apex:page standardController="Transaction__c" extensions="TransactionsCtrl" id="thePage" >
<apex:pagemessages />
<apex:form id="theForm" >  

<apex:pageBlock id="editPB" title="Edit" >
          <apex:pageBlockButtons id="editButtons" location="top" rendered="true">
          <apex:commandButton id="saveBtn" value="Save" action="{!save}" />
          <apex:commandButton id="cancelBtn" value="Cancel" action="{!cancel}" />
          </apex:pageBlockButtons>
<apex:pageBlockSection title="Audit Record" columns="2" id="pgBlckSct1">
<apex:inputField id="statusFld" value="{!transaction.Status__c}" />
<apex:inputField id="empidFld" value="{!transaction.EmplId__c}"  />
</apex:pageBlockSection> 

</apex:pageBlock> 
</apex:form>
</apex:page>


Class

public with sharing class TransactionsCtrl { 
    
    private ApexPages.StandardController stdController  { get; set; }
    public Transaction__c transaction { get; set; }
    
    public TransactionsCtrl(ApexPages.StandardController stdController) {
        
        
      System.debug('is it in the constructor');
      this.stdController = stdController;
      this.transaction = (Transaction__c)this.stdController.getRecord();

        pbatransaction = [SELECT Id, Name
                        FROM Transaction__c 
                                        WHERE Id = :transaction.Id limit 1];   
       }       
  public PageReference edit() {  
    PageReference page = new Pagereference('/apex/Transactions_Edit?Id='+transaction.Id);
        page.setRedirect(true);
        return page;
  }
        
  public PageReference save() {   
            try{
                update this.transaction;
                }catch(exception e){
                }
                PageReference page = new Pagereference('/apex/Transaction_Detail?Id='+transaction.Id);
            page.setRedirect(true);
            return page;
 }
 public Pagereference cancel(){
        PageReference newpage = new Pagereference('/apex/Transaction_Detail?Id='+transaction.Id);
        newpage.setRedirect(true);
        return newpage;
 }
   
}





 

I've written an Apex Service that will be called from an inhouse application.  I have a try/catch block that catches any exceptions and returns an error type that I've defined.  I also send an email notification out.  I know you can grab the exception type and message with .getTypeName() and .getMessage(), but how do I get the exception line number?  That would be handy information to send in the error notification email.  If I don't handle the error, the service returns the exception type, exception message, class name, class method, and line number in the faultstring element.  I don't see anything in the Apex documentation that would allow you to access the line number when catching the exception though.  What gives?  Is this available?