• Ajay_SFDC
  • NEWBIE
  • 125 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 51
    Replies
Hi all,

I have a VF page where I am getting basic information for a lead like, FirstPage (VF page) and I am inserting into the lead object. Now FirstPage is calling SecondPage and which is asking to enter some more info and now I want to informaiton from SecondPage to be insertred in the same lead of the FirstPage (I have leadid).

Could anyone please tell me how to do that? My code is below.

<apex:page controller="FirstController">
    <apex:sectionHeader title="signup form" />
    <apex:form >
        <apex:pageBlock title="Create a New formr">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Volunteer Information" columns="1">
                <apex:inputField id="firstName" value="{!Lead.FirstName}" required="true"/>
                <apex:inputField id="lastName" value="{!Lead.LastName}"/>                 
                <apex:inputField id="Company" value="{!Lead.Company}" required="true"/>     
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

--------------------------------------------------------------------- SecondPage ----------------

<apex:page controller="FirstController">
    <apex:sectionHeader title="signup form details" />
    <apex:form >   
        <apex:pageBlock >     
            <apex:pageBlockButtons >
                <apex:commandButton action="{!Mysave}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Contact Inforamtion" columns="1">
                <apex:inputField id="Street" value="{!Lead.Street}" style="width:200px" required="false"/>              
                <apex:inputField id="City" value="{!Lead.City}" required="false"/>
                <apex:inputField id="State" value="{!Lead.State}" required="false"/>
                <apex:inputField id="Country" value="{!Lead.Country}" required="false"/>
                <apex:inputField id="PostalCode" value="{!Lead.PostalCode}" required="false"/>
            </apex:pageBlockSection>              
        </apex:pageBlock>
    </apex:form>
</apex:page>


------------------------------------------------- Controller -------------------------------------------------------------------------------

public class VolunteerInformationController { 
      
    Lead lead;
    String leadId;
    
    public VolunteerInformationController () {
        leadId = ApexPages.currentPage().getParameters().get('leadId');
    }
           
    public VolunteerInformationController (ApexPages.StandardController controller) {
        leadId = ApexPages.currentPage().getParameters().get('leadId');
    }
    
    public Lead getLead() {
        if(lead == null) lead = new Lead();
        return lead;
    }


    public PageReference save() {
        // Add the lead to the database. 
        insert lead;
        // Send the user to the detail page for the new lead.
        //PageReference leadPage = new ApexPages.Thankyou
        PageReference leadPage = new PageReference('/apex/Volunteer_Initial_Signup2');
        leadPage.getParameters().put('leadId', lead.Id);
        leadPage.setRedirect(true);
        return leadPage;
    }
    
    public PageReference Mysave() {
        
       //not able to figureout how to insert rest of the information for that lead id
        PageReference pageRef = ApexPages.currentPage();        
        return pageRef;
    }

}

Why isn't my formatting and table showing for this VF page?  Please help I'll give kudos to anyone that contributes.

 

Thank you,

Steve Laycock

 

<apex:page standardController="Contract"  showHeader="false" sidebar="false" standardStylesheets="false"  renderAs="pdf">

        <!-- Sales Invoice reference for the following VF markup  -->
        <apex:variable var="Contract1" value="{!Contract}"/>
        
        <!-- ************************* BEGIN COPY / PASTE HERE ******************************** -->
        

        
        <!-- Styles -->
        <apex:variable var="styleFontColor"                         value="#000000" />
        <apex:variable var="styleHeaderBGColor"                     value="#E4EAF4" />
        <apex:variable var="styleHeaderFontColor"                   value="#000000" />
        <apex:variable var="styleLineColor"                         value="#3B5E91" />
        <head>
            <style type="text/css">
                body,td,th, h1 {
                font-family:Verdana, Arial, Helvetica, sans-serif;
                font-size:7.5pt;
                color:{!styleFontColor};
                }
            
                .email table{
                width:100%;
                border-collapse:collapse;
                margin-bottom:10px;
                }
            
                .email table.tableSummary{
                width:250px;
                }
            
                .email table.tableDescription{
                width:68%;
                margin-top:10px;
                margin-bottom:5px;
                }
                
                .email table.noBottomMargin{
                margin-bottom:0px;
                }
                
                .email table.tableTaxSummary, .email table.tableAdditional {
                margin-top:10px;
                margin-bottom:0px;
                }
            
                .email table h1{
                font-size:20px;
                font-weight:700;
                text-transform:uppercase;
                text-align:right;
                margin:0;
                }
            
                .email table td,
                .email table th{
                padding:5px;
                }
                .email table th{
                background-color:{!styleHeaderBGColor};
                color:{!styleHeaderFontColor};
                }
            
                .email table th.nobg{
                background-color:transparent;
                color:{!styleFontColor};
                }
            
                .email table td.noPadding{
                padding:0px;
                }
                .email table td.noPaddingLeft{
                padding-left:0px;
                }
            
                .email table td.alignTop{
                vertical-align:top;
                }
            
                .email table .textAlignLeft{
                text-align:left;
                }
                .email table .textAlignCenter{
                text-align:center;
                }
                .email table .textAlignRight{
                text-align:right;
                }
            
                .email table.boxed{
                border-left:1px solid {!styleLineColor};
                border-top:1px solid {!styleLineColor};
                }
            
                .email table.boxed th, .email table.boxed td{
                border-left:1px solid {!styleLineColor};
                border-top:1px solid {!styleLineColor};
                }
            
                .email table.boxedNoTop{
                border-top:none;
                border-left:none;
                }
                
                .email table.boxedNoBottom{
                border-bottom:none;
                }
                
                .email table.boxedNoTop td.boxedNoTop{
                border-top:none ;
                }
            
                .email table.boxed th{
                border-right:1px solid {!styleLineColor};
                border-bottom:1px solid {!styleLineColor};
                }
            
                .email table.boxed th.noLines{
                border-right:1px solid {!styleLineColor};
                border-left:none;
                border-top:none;
                border-bottom:none;
                }
            
                .email table.boxed td{
                border-right:1px solid {!styleLineColor};
                border-bottom:1px solid {!styleLineColor};
                }
            
                .email table.boxed td.widthLineNumbers{width:15pt;}
                .email table.boxed td.widthSmall{width:45pt;}
                .email table.boxed td.widthMedium{width:75pt;}
                
                .widthMedium{width:75pt;}
            
                .email table.boxed td span.description{
                font-size:85%;
                font-style:italic;
                display:block;
                }
                
                .boxedtop {
                border-top:1px solid {!styleLineColor};
                }
                    
                .boxed {
                border-left:1px solid {!styleLineColor};
                border-right:1px solid {!styleLineColor};
                border-bottom:1px solid {!styleLineColor};
                }
                
                table { page-break-inside:auto }
                tr    { page-break-inside:avoid; page-break-after:auto }
                
                @page {
                    @bottom-right {content:"Page " counter(page) " of " counter(pages);
                               font-family:Verdana, Arial, Helvetica, sans-serif;
                               font-size:7.5pt;
                               font-weight:bold;
                               padding-bottom;25px;
                  }
                }
              </style>
        </head>
       
       
            
        <table>
                <tr>
                    <td>
                        
                        <div>
                            <apex:outputText value="{!Contract1.Contact_Email__c} (Email)" rendered="{!Contract1.Contact_Email__c!=''}" escape="false"/>
                        </div>
                        
                    </td>
                </tr>
        </table>
       
        
        <apex:variable var="lblProforma"                     value="PROFORMA" />
        
        <table>
                <tr>
                    <td>
                        <h1>{!lblProforma}</h1>
                    </td>
                </tr>
            </table>
        
        <apex:variable var="lblContractNumber"              value="Contract Number" />
        <apex:variable var="lblContractTotal"              value="Contract Amount" />
                
        <apex:outputPanel rendered="{!Contract1.ContractNumber != ''}">
                                <table styleClass="boxed noBottomMargin">
                                    <tr>
                                        <th>{!lblContractNumber}</th>
                                        <td>{!Contract1.ContractNumber}</td>
                                    </tr>
                                    
                                    <tr>
                                        <th>{!lblContractTotal}</th>
                                        <td>
                                            <td>{!Contract1.Total_Maintenance_Price__c}</td>
                                        </td>
                                    </tr>
                                </table>
                            </apex:outputPanel> 
        
  </apex:page>

 

Hi there ,

I have written an Inbound Email service of salesforce . I am sending excel file to this salesforce service . Below is ocde in my method of InboundEmailHandler class :

     Messaging.Inboundemail.Binaryattachment[] binaryAttachement = email.binaryAttachments;
        
         if(binaryAttachement !=null && binaryAttachement.size() > 0)
         {
        for(Messaging.Inboundemail.Binaryattachment bAttach :binaryAttachement )
            {
                if(bAttach.filename.endsWith('.xls'))
                {
                        String bodyEncoded = EncodingUtil.base64Encode(bAttach.body);
                        system.debug('&&&&&&&&bodyEncoded'+bodyEncoded);
                        Blob decoded4Bytes = EncodingUtil.base64Decode(bodyEncoded );
                       system.debug('&&&&&&&&bodyEncoded'+decoded4Bytes.toString() );
                }
            }
         }

I am getting exception "BLOB is not a valid UTF-8 string"  while converting this binary data into string :(In system.debug)

Excel file always gives body in binary format . I want to parse/get contents of the excel file . Is there any way to get the contents of excel file ? Has anyone written parser for excel body ?

Thanks ,
 Ajay


Hi there ,

I am having a simple WebToCase form from which I am submitting Case to my SF org . The case is successfully creating in my org /sandbox.

But I want to do some manipulation on this case record coming from form. So I have written trigger to do the same .

Problem :
Trigger is not getting fired after submitting case . I have tried all the events before and after on trigger . But not able to trace this case record in the trigger .
I have some assignment rules on it . I tried with activating /deactivating it .  I have checked the Api version of the class/trigger .

Any workaround on this issue ?

I have implmented it in a developer edition and its successfully firing the trigger . But in sandbox its not working :(
 


Thanks ,
 Ajay

Hi Members,

Did any one used Jeffdouglas code to overide standard quick create Popup Dialog :- http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/ 
If yes can any body tell me how to get account id in save method to contact record.

Thanks in Advance
Hi all,

I have a VF page where I am getting basic information for a lead like, FirstPage (VF page) and I am inserting into the lead object. Now FirstPage is calling SecondPage and which is asking to enter some more info and now I want to informaiton from SecondPage to be insertred in the same lead of the FirstPage (I have leadid).

Could anyone please tell me how to do that? My code is below.

<apex:page controller="FirstController">
    <apex:sectionHeader title="signup form" />
    <apex:form >
        <apex:pageBlock title="Create a New formr">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Volunteer Information" columns="1">
                <apex:inputField id="firstName" value="{!Lead.FirstName}" required="true"/>
                <apex:inputField id="lastName" value="{!Lead.LastName}"/>                 
                <apex:inputField id="Company" value="{!Lead.Company}" required="true"/>     
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

--------------------------------------------------------------------- SecondPage ----------------

<apex:page controller="FirstController">
    <apex:sectionHeader title="signup form details" />
    <apex:form >   
        <apex:pageBlock >     
            <apex:pageBlockButtons >
                <apex:commandButton action="{!Mysave}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Contact Inforamtion" columns="1">
                <apex:inputField id="Street" value="{!Lead.Street}" style="width:200px" required="false"/>              
                <apex:inputField id="City" value="{!Lead.City}" required="false"/>
                <apex:inputField id="State" value="{!Lead.State}" required="false"/>
                <apex:inputField id="Country" value="{!Lead.Country}" required="false"/>
                <apex:inputField id="PostalCode" value="{!Lead.PostalCode}" required="false"/>
            </apex:pageBlockSection>              
        </apex:pageBlock>
    </apex:form>
</apex:page>


------------------------------------------------- Controller -------------------------------------------------------------------------------

public class VolunteerInformationController { 
      
    Lead lead;
    String leadId;
    
    public VolunteerInformationController () {
        leadId = ApexPages.currentPage().getParameters().get('leadId');
    }
           
    public VolunteerInformationController (ApexPages.StandardController controller) {
        leadId = ApexPages.currentPage().getParameters().get('leadId');
    }
    
    public Lead getLead() {
        if(lead == null) lead = new Lead();
        return lead;
    }


    public PageReference save() {
        // Add the lead to the database. 
        insert lead;
        // Send the user to the detail page for the new lead.
        //PageReference leadPage = new ApexPages.Thankyou
        PageReference leadPage = new PageReference('/apex/Volunteer_Initial_Signup2');
        leadPage.getParameters().put('leadId', lead.Id);
        leadPage.setRedirect(true);
        return leadPage;
    }
    
    public PageReference Mysave() {
        
       //not able to figureout how to insert rest of the information for that lead id
        PageReference pageRef = ApexPages.currentPage();        
        return pageRef;
    }

}
Hi there ,

I have written an Inbound Email service of salesforce . I am sending excel file to this salesforce service . Below is ocde in my method of InboundEmailHandler class :

     Messaging.Inboundemail.Binaryattachment[] binaryAttachement = email.binaryAttachments;
        
         if(binaryAttachement !=null && binaryAttachement.size() > 0)
         {
        for(Messaging.Inboundemail.Binaryattachment bAttach :binaryAttachement )
            {
                if(bAttach.filename.endsWith('.xls'))
                {
                        String bodyEncoded = EncodingUtil.base64Encode(bAttach.body);
                        system.debug('&&&&&&&&bodyEncoded'+bodyEncoded);
                        Blob decoded4Bytes = EncodingUtil.base64Decode(bodyEncoded );
                       system.debug('&&&&&&&&bodyEncoded'+decoded4Bytes.toString() );
                }
            }
         }

I am getting exception "BLOB is not a valid UTF-8 string"  while converting this binary data into string :(In system.debug)

Excel file always gives body in binary format . I want to parse/get contents of the excel file . Is there any way to get the contents of excel file ? Has anyone written parser for excel body ?

Thanks ,
 Ajay


Hi, 

  I am getting error while saving trigger in below line 37. Please suggest me how to fix this issue. 

trigger Temp_Asset2_Opp on Temp_Assets__c (after insert )
{
  List<Temp_Assets__c> CurrentAsset = [Select Id, Name, Serial_Number__c, AccountId__c, Product__c, Service_Start_Date__c,
                                              Service_End_Date__c ,Install_Date__c ,Reseller__c,Distributor__c ,
                                              Incumbent_Reseller__c,Education__c,Expiry_Date__c,Existing_Opportunity__c,
                                              New_Opportunity__c,Expiry_Term__c,Bundle_Support__c 
                                       From Temp_Assets__c];

 
  for ( Temp_Assets__c TA : CurrentAsset )
  {
      // If New Opportunity is Created 
     if ( TA.Existing_Opportunity__c == NULL && TA.New_Opportunity__c != NULL )   
      {
         // Insert Opportunity with all mandatory fields
         Opportunity Opp = new Opportunity();
         Opp.Name      = [SELECT New_Opportunity__c From Temp_Assets__c Limit 1].New_Opportunity__c;            
         Opp.Type      = 'Existing Customer';
         Opp.AccountId = [SELECT AccountId__c From Temp_Assets__c Limit 1].AccountId__c;
         Opp.CloseDate = [SELECT Expiry_Date__c From Temp_Assets__c Limit 1].Expiry_Date__c;
         Opp.Government_Contract__c = 'None';
         Opp.StageName = 'Renewal';
         Opp.Lost_Reason__c = 'Other';
         Opp.Primary_Competitor__c = 'No Competitor';
         Opp.ForecastCategoryName = 'Pipeline';
         Opp.LeadSource = 'Renewal';
         Opp.Primary_Reseller__c    = [SELECT Reseller__c From Temp_Assets__c Limit 1].Reseller__c;
         Opp.Primary_Distributor__c = [SELECT Distributor__c From Temp_Assets__c Limit 1].Distributor__c;
         Opp.Renewal_Incumbant_Reseller__c =  'None';
         Opp.Renewal_K_12__c   =  'No';
        
         Insert Opp;
        
        // Insert into Opportunity Lines
         OpportunityLineItem OppL = new OpportunityLineItem(
            OpportunityId = Opp.Id,
            Product2 = TA.Product__c
           
           
          );
         Insert OppL;                       
        } 
       
       //If Existing Opportunity is selected   
      else if ( TA.Existing_Opportunity__c != NULL && TA.New_Opportunity__c == NULL )   
      {
     
      }

    
  }  
 
 
 
 
}


Consider  a checkbox field as "abc" is checked on quote, I want to apply the change to all quote line items attached to it with the same change(I have the same checkbox field on both quote and quote line items). And similarly when the checkbox is unchecked and saved, It should do the same. I observed that I can't achieve this using field updates. Can Someone help me With how I can achieve this using apex trigger.

I am attaching my trigger that I have done sofar, but it has errors, Can some one help me to get it executed. 

trigger updateabc on Quote (after insert, after update){

    QuoteLineItem ql = [select abc__c from QuoteLineItem where Quote = :trigger.new[0].id ];

    for(Quote q: trigger.new){

        if(q.abc__c == true){

            ql.abc__c = true;
        }
        if(q.abc__c == false){

            ql.abc__c = false;

        }
    }

    update ql;
}
  • March 18, 2014
  • Like
  • 1
I can't understand why the trigger below is not working. All I am wanting to do is update a Contact checkbox when a Task is created with a custom picklist field has a specific value:

trigger UsefulActivity on Task (after insert, after update)
{
for(Task t : trigger.new)
{
  for(Contact c : [select Id, Had_Useful_Activity__c from Contact where Id=:t.WhatID])
  {
   if(t.Result__c == 'Meeting')
   {
    c.Had_Useful_Activity__c = true;
   }
  }
}
}
From Salesforce documentation, the order of execution says that there is no system validation run prior to the 'before insert' trigger if the request is coming from sources other than standard UI, and that these will run instead after the 'before insert' trigger is executed.

Apex Developers Guide reference: http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_triggers_order_of_execution.htm?SearchType=Stem (http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_triggers_order_of_execution.htm?SearchType=Stem" target="_blank)

I'm trying to catch and fix bad email values from an external system sync in a before insert trigger, but when I test this in the Developer console, the before trigger is not even started before I get a System.DmlException error with INVALID_EMAIL_ADDRESS.  I'm running the test through the Execute Anonymous Window so that it is not submitted through the standard UI.  Has anyone else found how to get around the system validation in order to get into a before insert trigger?
I have a Static Webservice Method defined in a Global class. That Webservice method has a string argument (Opportuinty ID) and It is retriving Oppotunity data withing the same method and send it out with Webservice callout and also I am doing some string manipulation and DML Operation in the same webserive method . I am Calling this class through  Custom List View Button on Opportunity.  It worked really well and does what I needed. But Now my biggest problem is how to test this webservice method or Global class using TestMethod.

1) I tried to do that and I got an Error "Methods defined as TestMethod do not support Web service callouts, test skipped"
2) I tried to create httpCallOutMock interface and It give me Error "System.CalloutException: You have uncommitted work pending. Please commit   or rollback before calling out"
3) I tried to Put my DML execution before test.StartTest() then I put Test.Mock()  to call webserive out and last Test.StopTest() but This did not work  even. I don't know now what to do.   I am going to paste my Webserive method and also test class to see if I could get any help from discussion board. Thanks Guys in advanced.

$$ APEX CLASS $$

global class sendToEncompass{
 
  // @future(callout=true)
// public String EncompassMSG;
   WebService static String basicCallout(String OppID){
 
     opportunity opp = [select id, Loan_Number__c,Borrower_SSN__c, Co_Borrower_First_Name__c, Co_Borrower_Last_Name__c, Co_Borrower_SSN__c, Borrower_Email__c, Borrower_First_Name__c, Borrower_Last_Name__c, owner.email, Subject_Property_Street__c, Subject_Property_City__c, Subject_Property_Zip__c, Processing_Notes__c from Opportunity where id =:OppID];
   
     HttpRequest req = new HttpRequest();
     req.setClientCertificateName('xxx');
     req.setEndpoint('https://api.xxx.yyy....');
     req.setMethod('POST');
     req.setHeader('Content-Type', 'application/xml');
     req.setTimeout(120000);
     req.setBody(
     '<LoanEntries xmlns="xxx">' +
  '<LoanData>' +
  '<LoanField>' +
      '<field_id>CX.SALESFORCELINKIDATE</field_id>' +
      '<field_value>'+System.now().format('MM/dd/yyyy')+'</field_value>' +
    '</LoanField>' +
   '<LoanField>' +
      '<field_id>LoanOfficer</field_id>' +
      '<field_value>'+opp.owner.email+'</field_value>' +
    '</LoanField>' +
    '<LoanField>' +
      '<field_id>36</field_id>' +
      '<field_value>'+opp.Borrower_First_Name__c+'</field_value>' +
    '</LoanField>' +
    '<LoanField>' +
      '<field_id>37</field_id>' +
      '<field_value>'+opp.Borrower_Last_Name__c+'</field_value>' +
    '</LoanField>' +
    '<LoanField>' +
      '<field_id>11</field_id>' +
      '<field_value>'+opp.Subject_Property_Street__c+'</field_value>' +
    '</LoanField>' +
    '<LoanField>' +
      '<field_id>12</field_id>' +
      '<field_value>'+opp.Subject_Property_City__c+'</field_value>' +
    '</LoanField>' +
    '<LoanField>' +
      '<field_id>15</field_id>' +
      '<field_value>'+opp.Subject_Property_Zip__c+'</field_value>' +
    '</LoanField>' +
    '<LoanField>' +
      '<field_id>364</field_id>' +
      '<field_value>'+opp.Loan_Number__c+'</field_value>' +
    '</LoanField>' +
    '<LoanField>' +
      '<field_id>65</field_id>' +
      '<field_value>'+opp.Borrower_SSN__c+'</field_value>' +
    '</LoanField>' +
    '<LoanField>' +
      '<field_id>68</field_id>' +
      '<field_value>'+opp.Co_Borrower_First_Name__c+'</field_value>' +
    '</LoanField>' +
    '<LoanField>' +
      '<field_id>69</field_id>' +
      '<field_value>'+opp.Co_Borrower_Last_Name__c+'</field_value>' +
    '</LoanField>' +
    '<LoanField>' +
      '<field_id>97</field_id>' +
      '<field_value>'+opp.Co_Borrower_SSN__c+'</field_value>' +
    '</LoanField>' +
    '<LoanField>' +
      '<field_id>1240</field_id>' +
      '<field_value>'+opp.Borrower_Email__c+'</field_value>' +
    '</LoanField>' +
  '</LoanData>' +
'</LoanEntries>'
     );

     // req.setBody('{"CX.SALESFORCELINKIDATE":"'+System.now().format('MM/dd/yyyy')+'","LoanOfficer":"'+opp.owner.email+'", "36":"'+opp.Borrower_First_Name__c+'","37":"'+opp.Borrower_Last_Name__c+'","11":"'+opp.Subject_Property_Street__c+'","12":"'+opp.Subject_Property_City__c+'","15":"'+opp.Subject_Property_Zip__c+'","364":"'+Opp.Loan_Number__c+'","65":"'+Opp.Borrower_SSN__c+'","68":"'+opp.Co_Borrower_First_Name__c+'","69":"'+opp.Co_Borrower_Last_Name__c+'","97":"'+opp.Co_Borrower_SSN__c+'","1240":"'+opp.Borrower_Email__c+'"}');
     
     //req.setEndpoint('https://xxxyyyy....xxxx');
     //req.setMethod('GET');

     Http http = new Http();
//     try{
     HTTPResponse res = http.send(req);
     //return res.getBody();
   //  System.debug(res.getBody());
     String loanID = res.getBody();
   //  return loanID;
     system.debug('My Returned Body: '+loanID);
     if(loanID.contains('Created')){
     loanID = loanID.split(':', 14)[2];
     loanID = (loanID.split('<',39)[0]).trim();
     system.debug(loanID);
     opp.GUID__c = loanID;
   //  EncompassMSG = 'Encompass loan record is successfully created, Click ok to continue';
     }
     else{
      loanID = loanID.split(':', 14)[2];
      loanID = (loanID.split('<',39)[0]).trim();
      system.debug(loanID);
      opp.GUID__c = 'Error: ' +loanID;
      //EncompassMSG = 'Error is occured while creating Encompass record, please try again or contact support';
     }
   
     update opp;
     if((opp.GUID__c).contains('Error')){
     return 'Error is occured while creating Encompass record, please try again or contact support';
     }else{
     return 'Encompass loan record is successfully created';
     }
//   }
//   catch(System.CalloutException e){
//    return 'Request time is out, Please try again';
//   }
   }
}


$$ Test Class $$


@isTest
global class MockHttpEncompassResponseGenerator implements HttpCalloutMock {
    // Implement this interface method
    global HTTPResponse respond(HTTPRequest req) {
        // Optionally, only send a mock response for a specific endpoint
        // and method.
      
       //sendToEncompass sE = new sendToEncompass();
     
    
     
    
      
        // Create a fake response
        HttpResponse res = new HttpResponse();
    
        res.setHeader('Content-Type', 'application/Xml');
     // res.setBody('{"CX.SALESFORCELINKIDATE":"'+System.now().format('MM/dd/yyyy')+'","LoanOfficer":"'+opp.owner.email+'", "36":"'+opp.Borrower_First_Name__c+'","37":"'+opp.Borrower_Last_Name__c+'","11":"'+opp.Subject_Property_Street__c+'","12":"'+opp.Subject_Property_City__c+'","15":"'+opp.Subject_Property_Zip__c+'","364":"'+Opp.Loan_Number__c+'","65":"'+Opp.Borrower_SSN__c+'","68":"'+opp.Co_Borrower_First_Name__c+'","69":"'+opp.Co_Borrower_Last_Name__c+'","97":"'+opp.Co_Borrower_SSN__c+'","1240":"'+opp.Borrower_Email__c+'","1222":"Loan Created:{8de3c840-cc26-4970-b10e-d441b090c50d}"}');
      //  res.setBody("":""'Loan Created :{8de3c840-cc26-4970-b10e-d441b090c50d}');
        res.setBody('{"Loan Created : ":"Loan Created :{8de3c840-cc26-4970-b10e-d441b090c50d}"}');
        System.debug('Body of webservice '+res.getBody());
       // res.setStatusCode(200); 
        return res;
    }

  @isTest static void testCallout() {
        
       Opportunity opp = new Opportunity(Name='demoTest',
                                        CloseDate=date.newInstance(2014, 4, 30),
                                        StageName='Active',
                                        Loan_Number__c='123456789101112',
                                        Borrower_SSN__c='8529518478',
                                        Co_Borrower_First_Name__c='FirstTest',
                                        Co_Borrower_Last_Name__c='LastTest',
                                        Co_Borrower_SSN__c='8526547458',
                                        Borrower_Email__c='demo@testemail.com',
                                        Borrower_First_Name__c='borrowerFirstName',
                                        Borrower_Last_Name__c='borrowerLastName',
                                        Subject_Property_Street__c='123 Main St',
                                        Subject_Property_City__c='Los Angeles',
                                        Subject_Property_Zip__c='98103',
                                        Processing_Notes__c='processingNotes');       
       Database.insert(opp);
       sendToEncompass.basicCallout(opp.id);
        
  
        // Set mock callout class
        Test.StartTest();
      
  Test.setMock(HttpCalloutMock.class, new MockHttpEncompassResponseGenerator());
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock.
     
    HttpRequest req = new HttpRequest();
        req.setClientCertificateName('xxx');
        req.setEndpoint('https://api.xxx/yyy');
        req.setMethod('POST');
        req.setTimeout(12000);
        Http h = new Http();
        HttpResponse res = h.send(req);
     
        String loanID = res.getBody();
        //System.debug('Response Body '+res.getBody());
        Test.stopTest();
    }
}
Hi,
 I have a custom button on a vf page, which will call the Webservie class (Note: webserice class doesn't make any webservice callouts) and i need to create a test class for the Webservice class inorder to create a package.
Now the problem is how to call the webservie method in my  test class?
The Webservice class looks like this:

Global class MyClass
{
      webservice static string insertRec(string Id)
     {
        -----------
        -----------
      }

}

I tried to call the webservice call in my testclss like this:

Myclass mc=new Myclass();
mc.insertRec();

ERROR: Method doesn't exist or incorrect signature [myclass].insertRec().

Any help would be much appreciated.
Hi,

when send email to customer add Email attachment, i know  add email attachment with visualforce page but how to add attachment with Email template, below code get only body of the email template but not images and merge fields. please guide me how to get merge fields and images in email file attachment.

My class:

Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
       
      EmailTemplate et=[Select id,Subject,body,HtmlValue from EmailTemplate where name=:'Gala Thank You Letter From Payment'];

       Blob b = Blob.valueOf(et.body);
      
       Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
       efa.setFileName('attachment.txt');
       efa.setBody(b);
      
       String addresses;
      
       addresses = pmnt.pymt__Contact__r.Email;
      
       String[] toAddresses = addresses.split(':', 0);
        email.setSubject( 'Thank You For Your Donation');
        email.setToAddresses( toAddresses );
        email.setPlainTextBody( 'Thank You .');
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
        email.setSaveAsActivity(true);
        Messaging.SendEmailResult [] r =
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});


Thanks.

Hi All,

 

Is it possible to access Bulk API through visualforce page? If so, kindly elobarate.

 

Thanks

Hi I am trying to integrate salesforce.com with Oracle Apps using BPEL. I have published my BPEL as a webservice in our test server and had created an apex class which calls this webservice. Later I am invoking this using an S-control button in Accounts tab.

But I am getting the following error when I invoke the button.

**
{faultcode:’soapenv”Client’, faultstring:’System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element ‘http://schemas.xmlsoap.org/soap/envelope/:Envelope’ but found ‘:html’

Class.wwwTrianzCom.Create_AccountPort.process: line 15, column 13
Class.AccountWrapper.CreateFunction: line 5, column 10
**

Please help me to figure out the problem.

Thank you, Aneesh