• Ravi kumar 292
  • NEWBIE
  • 40 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 37
    Replies
Hi All,

I have written a trigger on contact update. In this trigger, wrote some if conditions to check somme conditions as below.. Here am confused that how to cover this if contions in test class. Below is my if conditions.

If(con.Lead__r.Sector__c=='Developer'&& acc.Rating__c!=null){
                flag = true;       
                If(Condition){
                    con.Lead__r.Rate__c = x%;
                }else if(condition){
                    con.Lead__r.Rate__c =y%;
               and so on.......
                }
            }

Please give me some sample code to cover this if condition..

 
Hi All,

I am working on Java to Salesforce integration. I have given Date value (For example 10/10/1990) in java but its showing as 09/10/1990 in salesforce. Here i have changed the Date to Date and Time in java. Then its working fine in salesforce (I mean, able to get the correct value).

But i want to use the Date in java code.

How can i achieve this.. Please tel me asap.

 
Hi, 

I want to cover the json parsing in test class. how to do this.. based on the json response i am calling another method. So problem here is, am unable to cover the json parsing.

below is my screen shot.

User-added image
Hi All,

I want to cover the try block in test class. How to do this.
Below is my code.

Controller:

public with sharing class Controller { 
    Contact con;
    String rsession;
    String username;
    String password;
    String app='10003600';
    String ConId;
    String memSiteAccId;
    String  token;
    
    YodleeAPI y = new YodleeAPI();
    public YodleeFastLinkAccessController(ApexPages.StandardController controller) {
        try{
            ConId = ApexPages.CurrentPage().getparameters().get('id'); 
            con = [Select id, FirstName, LastName, PAN_ID__c from Contact where id=:ConId];
        }catch(Exception e){
            con = new Contact();
        }    
    }
    public String getRsession() {
        if(runningInASandbox()){
            // Sandbox
            username = username;
            password = password;
        }else{
            //Production
            username = username;
            password = password;          
        } 
        String cobSessionToken = y.cobLogin(username, password);
        try{
            rsession = y.Login(con.id,con.PAN_ID__c);        
            memSiteAccId = y.getAllSiteAccounts();
        }catch(exception e){}

        if(memSiteAccId!=null){
            String itemAccountId = y.getItemSummariesForSite(memSiteAccId);
            y.executeUserSearchRequest(cobSessionToken,rsession,'All','20','1','500','1','1','DataSearchService','INR',system.today().addMonths(-6).format(),system.today().format(),'ALL_TRANSACTION','True',itemAccountId);      
        }
        return rsession;
    }
    public String getToken() {
        try{
            token = y.GetToken(app);
        }catch(exception e){}
        return token;
    }
    public static Boolean runningInASandbox() {
        return [SELECT Id, IsSandbox FROM Organization LIMIT 1].IsSandbox;  
    }   
}

Test Class:

@isTest
public class YodleeAPI_Test{
     Public static testMethod void testcase(){
         Contact con = new Contact();
         con.LastName = 'ContactTest';
         con.PAN_ID__c = 'YTXPU1874H';
        // insert con;
         String conid = '003p0000006fMjCAAU';
         system.debug(conid);
         ApexPages.CurrentPage().getParameters().put('id',conid);
         ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(con);
         YodleeFastLinkAccessController yc= new YodleeFastLinkAccessController(sc);
         yc.getRsession();
         yc.getToken();
     }
}

In the above code Bold text is not covering in the test class..

Please help on this.. 
Hi,

I have created one visualforce with standardcontroller and extensions. Here Am giving some input values and clicking on submit button then it will redirect to the some page. There am doing some operations. After completing it will redirect to the contact page. Here i want to redirect to particular contact. For this i need to pass the contact id to the callback url. I fetching the contact details from controller. How to pass this value. 

Below is my code..

<apex:page standardController="Contact" extensions="YodleeFastLinkAccessController" >
    <HTML> 
        <HEAD>
        </HEAD>
        <BODY>
            <form action="https://yieapnodestage.yodlee.com/authenticate/private-sandbox230/?channelAppName=yisandbox"  method="POST" id="rsessionPost"><br/><br/>  
                
                Finapp Id
                <input type="text" name="app" value="10003600" /><br/><br/> 
                
                rsession
                <input type="text" name="rsession"  value="{!rsession}" placeholder="Resession"/> <br/><br/>
                
                token
                <input type="text" name="token" value="{!token}" placeholder="Token"/><br/><br/>
                
                Redirect Required 
                <input type="text" name="redirectReq" placeholder="true" value="True"/><br/><br/>
                    
                <!--  <script>document.getElementById('rsessionPost').submit();</script> -->
                Extra Parameters
                <input type='text' name='extraParams' placeholder='Extra Params' value='callback=https://c.cs6.visual.force.com/apex/YodleeSuccessPage?id=i want to pass contact id here'/> <br/><br/>
                <input type="submit" name="submit" />
    </form>
</BODY>
</HTML>
</apex:page>

Controller..

public with sharing class YodleeFastLinkAccessController { 
    Contact con;
    String rsession;
    String username = username;
    String password = password;
    String app=app;
    String ConId;
    String memSiteAccId;
    String  token;
    YodleeAPI y = new YodleeAPI();
    public YodleeFastLinkAccessController(ApexPages.StandardController controller) {
        try{
            ConId = ApexPages.CurrentPage().getparameters().get('id'); 
            con = [Select id, FirstName, LastName, PAN_ID__c from Contact where id=:ConId];
            system.debug('PanId--'+con.PAN_ID__c);
        }catch(Exception e){
            con = new Contact();
        } 
    }
    public String getRsession() {
        String cobSessionToken = y.cobLogin(username, password);
        try{
        rsession = y.Login(con.id,con.PAN_ID__c);        
        memSiteAccId = y.getAllSiteAccounts();
        }catch(exception e){}
        if(memSiteAccId!=null){
        String itemAccountId = y.getItemSummariesForSite();
        y.executeUserSearchRequest();
        system.debug('rsession*****'+rsession);
        }
        return rsession;
    }
    public String getToken() {
        try{
        token = y.GetToken(app);
        }catch(exception e){}
        system.debug('token*****'+token);
        return token;
    }   
}

Any help will be appriciate 
Hi All,

I have created two visualforce pages. One with command button. When i click on button it will redirect to the second vf page. In first vf page controller am fetching the contact fields. Now i want to use those contact fields in second vf page controller. How to do this.. below is my vf pages and its controllers.

VF Page : 1
<apex:page standardController="Contact" extensions="TestController">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
            <apex:commandButton value="Login" action="{!Login}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller : 1
public with sharing class TestController {
    Private Contact con;
    public YodleeController(ApexPages.StandardController controller) {
        String ConId = ApexPages.CurrentPage().getparameters().get('id');
        Contact con = [Select id, FirstName, LastName, PAN_ID__c from Contact where id=:ConId];
        system.debug('conId--'+con.id);
        system.debug('conPAN---'+con.PAN_ID__c);
    }
    public PageReference Login() {
        PageReference page = new PageReference('/apex/LinkAccess');
        page.setRedirect(true);
        return page;
    }  
}

VF Page : 2

<apex:page controller="LinkAccessController">
    <HTML>
        <HEAD>
        </HEAD>
        <BODY>
            <form action="https://test.com/"  method="POST" id="sessionPost"><br/><br/>  
               
                app Id
                <input type="text" name="app"  /><br/><br/> 
                
                session
                <input type="text" name="rsession"  /> <br/><br/>
                
                tokenID
                <input type="text" name="token"  /> <br/><br/>
                
                Redirect Required 
                <input type="text" name="redirectReq" placeholder="true" value="True"/><br/><br/>
                
                <script>document.getElementById('sessionPost').submit();</script>
                </form>
            </BODY>
        </HTML>
</apex:page>


Controller : 2
public with sharing class LinkAccessController {
// Some code is there..
// Here i want use the contact fields from first controller to do some operation
}


 
Hi all,

I want to hit the URL whenever a contact record is updated. How to do this. Please give some odea on this.

Thanks
Hi all,

I have a requirement. I need to write a code based on a custom field of custom object. Custom object(XYZ__c) is lookup to Contact object and Contact is lookup to Lead Object.. for example

if(picklist field == 'test'){
    if(custom field == text value){
       String text ='done';
}

Here am confused that how to take the custom filed with relation..

Please help on this..
Hi all,

I have a scenario. I have created a custom button with URL. When ever i click on the custom button i will hit the client URL. Now i want to use that functionality in APex class or Trigger. How can i do this.

Please help on this.
Thanks in advance.

 
Hi all,

I have a scenario.. I have a Picklist Some__c. based on the Picklist value i need to display the Interest Rates like 10%, 11%, 12%, etc.. Here i need to display for one Picklist there are different interest rates.. For Example: For 'A' picklist value i need to display 10% and 12%.

How can i achieve this.

Help on this. Thanks in advance.. 
Hi all,

I want to hit the client URL with Query parameters without giving Username and Password ib the Apex class. Is it possible??

Help on this.

 
Hi all,

I want to hit the URL(http://test.com/callback.ashx?lead_id=ld121212&contact_id=234234&application_id=IL2342343&status=Approved&amount=100000) when i click on a custom button. How can i do this. Please help.

Thanks 
Hi all,

This is my code.

String LeadId=ApexPages.currentPage().getParameters().get('id'); 
            Lead l =[select id,Amount_in_Rs__c,Status,Application_Id__c from Lead where id=:LeadId];
            system.debug('Lead id--'+l.id); 
           Contact c = [select id,FirstName,LastName from Contact where id=:l.id];
           system.debug('contact id --'+c.id);

I am getting the Lead id from the lead query but am not getting the contact id which is related to the lead. I have one contact for the lead.

Help on this.

Thanks,
Hi all,

I want to pass the Parameters(Status and Amount) to the service endpoint URL. How can i do this. Please help.
Whenever i click on Custom Button i will redirect to the vf page. and call the class.

Below is my code..

VF page:
<apex:page standardController="Lead" extensions="LDController" action="{!CallBack}" >
</apex:page>

Class:

public with sharing class LDController {
    public String LeadId {get;set;}
    
    public LDController(ApexPages.StandardController controller) {
        LeadId=ApexPages.currentPage().getParameters().get('id');
        system.debug('LeadId  '+LeadId);       
    }
    
    public void getAndParse(String POST) {
        String body ='LeadId='+LeadId+'';

        system.debug('------'+body);
        // Get the XML document from the external server
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://test.com/');
        req.setMethod('POST');
        req.setbody(body);
        HttpResponse res = http.send(req);
        
        String response=res.getBody();
        System.debug('Response '+response);
    }
    public Void CallBack(){
        getAndParse('POST');   
    
    }
   
}

Thanks in advance...
Hi all,

I have a scenario. Whenever i click on a custom button it will call the apex class. The class consists of some webservice call. That means when i click on button it will call the webservice end point.. We can achieve this by creating VF page and Apex class but i dont want to create a VF page.


How to do this..
Help on this.. 
Hi all,

How to cover the for loop and if condition in test class. This is mode.

 for(i=0; i<c.Size();i++){
            if (c[i].Borrower_Type__c == 'Borrower'){
                Borrower.FirstName = c[i].FirstName;
                Borrower.LastName = c[i].LastName;
                Borrower.Birthdate = c[i].Birthdate;
                Borrower.Gender__c = c[i].Gender__c;
                Borrower.PAN_ID__c = c[i].PAN_ID__c;
                // Borrower.Age1__c =c[i].Age1__c;
                Borrower.phone =  c[i].phone;
                Borrower.Annual_Income_Gross__c = c[i].Annual_Income_Gross__c;
                Borrower.Marital_Status__c =c[i].Marital_Status__c;
                Borrower.Email = c[i].Email;
                Borrower.MobilePhone = c[i].MobilePhone;
                // Borrower.Sector__c = c[i].Sector__c;
                Borrower.MailingStreet = c[i].MailingStreet;
                Borrower.MailingCity = c[i].MailingCity;
                Borrower.MailingState = c[i].MailingState; 
                Borrower.MailingCountry = c[i].MailingCountry;   
                Borrower.MailingPostalCode = c[i].MailingPostalCode;
                Borrower.Residence_Type__c = c[i].Residence_Type__c;
                Borrower.Organisation__c = c[i].Organisation__c;
                
                date datetoday = system.today();
                Integer todayyr = datetoday.year(); 
                Integer birthyr = c[i].Birthdate.year();
                Age = (Todayyr - birthyr); 
                system.debug('Age :' + Age);
                dateInStringString = string.valueOfGmt(c[i].Birthdate);
                system.debug('dateInStringString :' +dateInStringString);
                MM = dateInStringString.substring(5, 7); 
                system.debug('MM :' +MM);
                DD = dateInStringString.substring(8, 10);
                system.debug('DD :' +DD);
                YYYY = dateInStringString.substring(0, 4);
                system.debug('YYYY :' +YYYY);
                // insert Borrower;
                // bankfacility = [Select Bank_Account_Number__c from Bank_Facilities__c where Id = :c[i].id limit 1];
            }
            else if (c[i].Borrower_Type__c == 'Co-Borrower'){
                CoBorrower.FirstName = c[i].FirstName;
                CoBorrower.LastName = c[i].LastName;
                CoBorrower.Birthdate = c[i].Birthdate;
                CoBorrower.Gender__c = c[i].Gender__c;
                CoBorrower.PAN_ID__c = c[i].PAN_ID__c;
                CoBorrower.phone = c[i].phone;
                CoBorrower.Annual_Income_Gross__c =c[i].Annual_Income_Gross__c;
                CoBorrower.Marital_Status__c =c[i].Marital_Status__c;
                CoBorrower.Email =c[i].Email;
                CoBorrower.MobilePhone = c[i].MobilePhone;
                CoBorrower.MailingStreet = c[i].MailingStreet;
                CoBorrower.MailingCity = c[i].MailingCity;
                CoBorrower.MailingState = c[i].MailingState; 
                CoBorrower.MailingCountry = c[i].MailingCountry;   
                CoBorrower.MailingPostalCode = c[i].MailingPostalCode;
                CoBorrower.Residence_Type__c = c[i].Residence_Type__c;
                CoBorrower.Organisation__c = c[i].Organisation__c; 
                //insert CoBorrower;          
            }
            else if (c[i].Borrower_Type__c == 'Guarantor'){
                Guarantor.FirstName =c[i].FirstName;
                Guarantor.LastName = c[i].LastName;
                Guarantor.Birthdate =c[i].Birthdate;
                Guarantor.Gender__c = c[i].Gender__c;
                Guarantor.PAN_ID__c = c[i].PAN_ID__c;
                Guarantor.Phone =c[i].Phone;
                Guarantor.Annual_Income_Gross__c=c[i].Annual_Income_Gross__c;
                Guarantor.Marital_Status__c =c[i].Marital_Status__c;
                Guarantor.Email = c[i].Email;
                Guarantor.MobilePhone = c[i].MobilePhone;
                Guarantor.MailingStreet = c[i].MailingStreet;
                Guarantor.MailingCity = c[i].MailingCity;
                Guarantor.MailingState = c[i].MailingState; 
                Guarantor.MailingCountry = c[i].MailingCountry;   
                Guarantor.MailingPostalCode = c[i].MailingPostalCode;
                Guarantor.Residence_Type__c = c[i].Residence_Type__c;
                Guarantor.Organisation__c = c[i].Organisation__c;
                //  insert Guarantor;
            }
            else if(c[i].Borrower_Type__c =='Patient'){
                Patient.FirstName =c[i].FirstName;
                Patient.LastName =c[i].LastName;
                Patient.Birthdate =c[i].Birthdate;
                Patient.Gender__c = c[i].Gender__c;
                Patient.PAN_ID__c =c[i].PAN_ID__c;
                Patient.Phone =c[i].Phone;
                Patient.Annual_Income_Gross__c =c[i].Annual_Income_Gross__c;
                Patient.Marital_Status__c =c[i].Marital_Status__c;
                Patient.Email = c[i].Email;
                Patient.MobilePhone =c[i].MobilePhone;
                Patient.MailingStreet = c[i].MailingStreet;
                Patient.MailingCity = c[i].MailingCity;
                Patient.MailingState = c[i].MailingState; 
                Patient.MailingCountry = c[i].MailingCountry;   
                Patient.MailingPostalCode = c[i].MailingPostalCode;
                Patient.Residence_Type__c = c[i].Residence_Type__c;
                Patient.Organisation__c = c[i].Organisation__c;
                //  insert Patient;
            }
            
        }

please help on this.

Thanks in advance..
Hi all,

Help me how to bypass the webservice callout in a test class.

Code: 
WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '/ CodeCoverage/ReturnData',
              'http://www.abc.com/xyz/sampleSchema.xsd',
              ' Input_element',
              'http://www.abc.com/xyz/sampleSchema.xsd',
              ‘ResponseElement’,
              ' ResponseElement'}
            );
Hi,

I have two classes A and B. While writing the test class am able to get the code coverage of Class A. But I was stucked at Class B.
Please help on this. Am getting the error as List Has No Row to Assign for SObject at line numer 5 in class B.

Class A:

public with sharing class A {
    
    public string rid {get; set;}
    public Opportunity o {get;set;}
    public Account a {get; set;}
    public Contact c {get;set;}
    private ApexPages.StandardController standardController;
    public A(ApexPages.StandardController standardController)
    {
        rid = ApexPages.CurrentPage().getparameters().get('id');
        this.standardController = standardController; 
        try{
            o=[Select id,Name,AccountId,Nationality__c,Purpose_of_Loan__c,Sanction_Amount__c,Application_Creation_Date__c,Original_Face__c,Loan_Tenor_in_Month__c,Other_Loan_Purpose__c from Opportunity where id= :rid];
            a=[Select Id,Loan_Amount__c, Sector__c from Account where id = :o.AccountId];
            c=[Select Id,FirstName,LastName,Birthdate,Borrower_Type__c,Name_of_Firm_Company_Establishment_In__c,Gender__c,Age1__c,PAN_ID__c,Residence_Type__c, Phone, Annual_Income_Gross__c,Organisation__c,MailingStreet, MailingCity,MailingState, MailingCountry,MailingPostalCode,Marital_Status__c,Email,MobilePhone From Contact where AccountId = :a.Id]; 
        }catch(Exception e){
            o = new Opportunity();
            a = new Account();
            c = new Contact();
        }    
    }
    
    public PageReference method(){
        B b1 = new B(); // instantiate Class
        b1.B(rid);                               
        return null;
    }   
}


Class B:

Public class B{
    
    public void B(string rid){ 
        
        Opportunity o=[Select id,Name,AccountId,Nationality__c,Purpose_of_Loan__c,Sanction_Amount__c,Application_Creation_Date__c,Original_Face__c,Loan_Tenor_in_Month__c,Other_Loan_Purpose__c from Opportunity where id= :rid];
        system.debug('print me account id'+o.AccountId);
        Account a=[Select Id,Loan_Amount__c, Sector__c from Account where id = :o.AccountId];
        system.debug('Print me account id'+a.id);
        List<Contact> c=[Select Id,FirstName,LastName,Birthdate,Borrower_Type__c,Name_of_Firm_Company_Establishment_In__c,Gender__c,Age1__c,PAN_ID__c,Residence_Type__c, Phone, Annual_Income_Gross__c,Organisation__c,MailingStreet, MailingCity,MailingState, MailingCountry,MailingPostalCode,Marital_Status__c,Email,MobilePhone From Contact where AccountId = :a.Id]; 
        system.debug('Contact' + c);
   .
   .
.
.
.
.
.

}
}

Test Class:

@isTest
Public class AB_Test{

    Public static testMethod void testcase(){
        
     
        Opportunity opp = new Opportunity();
        opp.Name = 'Test';
        opp.StageName = 'Rejected';
        opp.Collateral_Type__c = 'Other';
        
        insert opp;
        
       String rid = opp.id;
       system.debug('-----'+rid);
        
        
        ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(opp);
        A hc = new A(sc);
        hc.method();
        
      B hc1 = new B();
      hc1.B(rid);
     
        
        
    }
}

Please help on this... Thanks in advance..
 
Hi all,

I have two classes say A and B. Pagereference method is in class B. Now i want to call the method in the class A.

exp:

Public class A{
    //i want to call the method here
}

Public class B{
  Public Pagereference C(){
    //some data

}


Please help me on this
Thanks in advance..
Hi all,

I have a scenario, i am using <apex:outputText> to display the custom object fields on a vf page like, FirstName, LastName, DOB, Mobile etc..
My requirement is, i want to display the mandatory field on the vf page.

For example FirstName* or Firstname|(red vertical bar).

Please help on this..

Thanks in advance.

 
Hi all,

I have a scenario.. I have a Picklist Some__c. based on the Picklist value i need to display the Interest Rates like 10%, 11%, 12%, etc.. Here i need to display for one Picklist there are different interest rates.. For Example: For 'A' picklist value i need to display 10% and 12%.

How can i achieve this.

Help on this. Thanks in advance.. 
I have Created a custom picklist field on opportunity with items(Stage-1, Stage-2, Stage-3, Stage-4), Included to page layout.

Now my requirement is Write a trigger on Opportunity to validate this Stage value with below conditions,

1. while record updating, Stage can be null/Previous Stage/Same Stage/Next stage(Stage-1 to Stage-2).
2. But stage value should not be skipped to Current Stage + 2 Stages.

Thanks in advance
Hi All,

I have written a trigger on contact update. In this trigger, wrote some if conditions to check somme conditions as below.. Here am confused that how to cover this if contions in test class. Below is my if conditions.

If(con.Lead__r.Sector__c=='Developer'&& acc.Rating__c!=null){
                flag = true;       
                If(Condition){
                    con.Lead__r.Rate__c = x%;
                }else if(condition){
                    con.Lead__r.Rate__c =y%;
               and so on.......
                }
            }

Please give me some sample code to cover this if condition..

 
Hi All,

I want to cover the try block in test class. How to do this.
Below is my code.

Controller:

public with sharing class Controller { 
    Contact con;
    String rsession;
    String username;
    String password;
    String app='10003600';
    String ConId;
    String memSiteAccId;
    String  token;
    
    YodleeAPI y = new YodleeAPI();
    public YodleeFastLinkAccessController(ApexPages.StandardController controller) {
        try{
            ConId = ApexPages.CurrentPage().getparameters().get('id'); 
            con = [Select id, FirstName, LastName, PAN_ID__c from Contact where id=:ConId];
        }catch(Exception e){
            con = new Contact();
        }    
    }
    public String getRsession() {
        if(runningInASandbox()){
            // Sandbox
            username = username;
            password = password;
        }else{
            //Production
            username = username;
            password = password;          
        } 
        String cobSessionToken = y.cobLogin(username, password);
        try{
            rsession = y.Login(con.id,con.PAN_ID__c);        
            memSiteAccId = y.getAllSiteAccounts();
        }catch(exception e){}

        if(memSiteAccId!=null){
            String itemAccountId = y.getItemSummariesForSite(memSiteAccId);
            y.executeUserSearchRequest(cobSessionToken,rsession,'All','20','1','500','1','1','DataSearchService','INR',system.today().addMonths(-6).format(),system.today().format(),'ALL_TRANSACTION','True',itemAccountId);      
        }
        return rsession;
    }
    public String getToken() {
        try{
            token = y.GetToken(app);
        }catch(exception e){}
        return token;
    }
    public static Boolean runningInASandbox() {
        return [SELECT Id, IsSandbox FROM Organization LIMIT 1].IsSandbox;  
    }   
}

Test Class:

@isTest
public class YodleeAPI_Test{
     Public static testMethod void testcase(){
         Contact con = new Contact();
         con.LastName = 'ContactTest';
         con.PAN_ID__c = 'YTXPU1874H';
        // insert con;
         String conid = '003p0000006fMjCAAU';
         system.debug(conid);
         ApexPages.CurrentPage().getParameters().put('id',conid);
         ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(con);
         YodleeFastLinkAccessController yc= new YodleeFastLinkAccessController(sc);
         yc.getRsession();
         yc.getToken();
     }
}

In the above code Bold text is not covering in the test class..

Please help on this.. 
Hi,

I have created one visualforce with standardcontroller and extensions. Here Am giving some input values and clicking on submit button then it will redirect to the some page. There am doing some operations. After completing it will redirect to the contact page. Here i want to redirect to particular contact. For this i need to pass the contact id to the callback url. I fetching the contact details from controller. How to pass this value. 

Below is my code..

<apex:page standardController="Contact" extensions="YodleeFastLinkAccessController" >
    <HTML> 
        <HEAD>
        </HEAD>
        <BODY>
            <form action="https://yieapnodestage.yodlee.com/authenticate/private-sandbox230/?channelAppName=yisandbox"  method="POST" id="rsessionPost"><br/><br/>  
                
                Finapp Id
                <input type="text" name="app" value="10003600" /><br/><br/> 
                
                rsession
                <input type="text" name="rsession"  value="{!rsession}" placeholder="Resession"/> <br/><br/>
                
                token
                <input type="text" name="token" value="{!token}" placeholder="Token"/><br/><br/>
                
                Redirect Required 
                <input type="text" name="redirectReq" placeholder="true" value="True"/><br/><br/>
                    
                <!--  <script>document.getElementById('rsessionPost').submit();</script> -->
                Extra Parameters
                <input type='text' name='extraParams' placeholder='Extra Params' value='callback=https://c.cs6.visual.force.com/apex/YodleeSuccessPage?id=i want to pass contact id here'/> <br/><br/>
                <input type="submit" name="submit" />
    </form>
</BODY>
</HTML>
</apex:page>

Controller..

public with sharing class YodleeFastLinkAccessController { 
    Contact con;
    String rsession;
    String username = username;
    String password = password;
    String app=app;
    String ConId;
    String memSiteAccId;
    String  token;
    YodleeAPI y = new YodleeAPI();
    public YodleeFastLinkAccessController(ApexPages.StandardController controller) {
        try{
            ConId = ApexPages.CurrentPage().getparameters().get('id'); 
            con = [Select id, FirstName, LastName, PAN_ID__c from Contact where id=:ConId];
            system.debug('PanId--'+con.PAN_ID__c);
        }catch(Exception e){
            con = new Contact();
        } 
    }
    public String getRsession() {
        String cobSessionToken = y.cobLogin(username, password);
        try{
        rsession = y.Login(con.id,con.PAN_ID__c);        
        memSiteAccId = y.getAllSiteAccounts();
        }catch(exception e){}
        if(memSiteAccId!=null){
        String itemAccountId = y.getItemSummariesForSite();
        y.executeUserSearchRequest();
        system.debug('rsession*****'+rsession);
        }
        return rsession;
    }
    public String getToken() {
        try{
        token = y.GetToken(app);
        }catch(exception e){}
        system.debug('token*****'+token);
        return token;
    }   
}

Any help will be appriciate 
Hi All,

I have created two visualforce pages. One with command button. When i click on button it will redirect to the second vf page. In first vf page controller am fetching the contact fields. Now i want to use those contact fields in second vf page controller. How to do this.. below is my vf pages and its controllers.

VF Page : 1
<apex:page standardController="Contact" extensions="TestController">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
            <apex:commandButton value="Login" action="{!Login}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller : 1
public with sharing class TestController {
    Private Contact con;
    public YodleeController(ApexPages.StandardController controller) {
        String ConId = ApexPages.CurrentPage().getparameters().get('id');
        Contact con = [Select id, FirstName, LastName, PAN_ID__c from Contact where id=:ConId];
        system.debug('conId--'+con.id);
        system.debug('conPAN---'+con.PAN_ID__c);
    }
    public PageReference Login() {
        PageReference page = new PageReference('/apex/LinkAccess');
        page.setRedirect(true);
        return page;
    }  
}

VF Page : 2

<apex:page controller="LinkAccessController">
    <HTML>
        <HEAD>
        </HEAD>
        <BODY>
            <form action="https://test.com/"  method="POST" id="sessionPost"><br/><br/>  
               
                app Id
                <input type="text" name="app"  /><br/><br/> 
                
                session
                <input type="text" name="rsession"  /> <br/><br/>
                
                tokenID
                <input type="text" name="token"  /> <br/><br/>
                
                Redirect Required 
                <input type="text" name="redirectReq" placeholder="true" value="True"/><br/><br/>
                
                <script>document.getElementById('sessionPost').submit();</script>
                </form>
            </BODY>
        </HTML>
</apex:page>


Controller : 2
public with sharing class LinkAccessController {
// Some code is there..
// Here i want use the contact fields from first controller to do some operation
}


 
Hi all,

I have a requirement. I need to write a code based on a custom field of custom object. Custom object(XYZ__c) is lookup to Contact object and Contact is lookup to Lead Object.. for example

if(picklist field == 'test'){
    if(custom field == text value){
       String text ='done';
}

Here am confused that how to take the custom filed with relation..

Please help on this..
Hi all,

I have a scenario. I have created a custom button with URL. When ever i click on the custom button i will hit the client URL. Now i want to use that functionality in APex class or Trigger. How can i do this.

Please help on this.
Thanks in advance.

 
Hi all,

I have a scenario.. I have a Picklist Some__c. based on the Picklist value i need to display the Interest Rates like 10%, 11%, 12%, etc.. Here i need to display for one Picklist there are different interest rates.. For Example: For 'A' picklist value i need to display 10% and 12%.

How can i achieve this.

Help on this. Thanks in advance.. 
Hi all,

I want to hit the client URL with Query parameters without giving Username and Password ib the Apex class. Is it possible??

Help on this.

 
Hi all,

I want to hit the URL(http://test.com/callback.ashx?lead_id=ld121212&contact_id=234234&application_id=IL2342343&status=Approved&amount=100000) when i click on a custom button. How can i do this. Please help.

Thanks 
Hi all,

How to cover the for loop and if condition in test class. This is mode.

 for(i=0; i<c.Size();i++){
            if (c[i].Borrower_Type__c == 'Borrower'){
                Borrower.FirstName = c[i].FirstName;
                Borrower.LastName = c[i].LastName;
                Borrower.Birthdate = c[i].Birthdate;
                Borrower.Gender__c = c[i].Gender__c;
                Borrower.PAN_ID__c = c[i].PAN_ID__c;
                // Borrower.Age1__c =c[i].Age1__c;
                Borrower.phone =  c[i].phone;
                Borrower.Annual_Income_Gross__c = c[i].Annual_Income_Gross__c;
                Borrower.Marital_Status__c =c[i].Marital_Status__c;
                Borrower.Email = c[i].Email;
                Borrower.MobilePhone = c[i].MobilePhone;
                // Borrower.Sector__c = c[i].Sector__c;
                Borrower.MailingStreet = c[i].MailingStreet;
                Borrower.MailingCity = c[i].MailingCity;
                Borrower.MailingState = c[i].MailingState; 
                Borrower.MailingCountry = c[i].MailingCountry;   
                Borrower.MailingPostalCode = c[i].MailingPostalCode;
                Borrower.Residence_Type__c = c[i].Residence_Type__c;
                Borrower.Organisation__c = c[i].Organisation__c;
                
                date datetoday = system.today();
                Integer todayyr = datetoday.year(); 
                Integer birthyr = c[i].Birthdate.year();
                Age = (Todayyr - birthyr); 
                system.debug('Age :' + Age);
                dateInStringString = string.valueOfGmt(c[i].Birthdate);
                system.debug('dateInStringString :' +dateInStringString);
                MM = dateInStringString.substring(5, 7); 
                system.debug('MM :' +MM);
                DD = dateInStringString.substring(8, 10);
                system.debug('DD :' +DD);
                YYYY = dateInStringString.substring(0, 4);
                system.debug('YYYY :' +YYYY);
                // insert Borrower;
                // bankfacility = [Select Bank_Account_Number__c from Bank_Facilities__c where Id = :c[i].id limit 1];
            }
            else if (c[i].Borrower_Type__c == 'Co-Borrower'){
                CoBorrower.FirstName = c[i].FirstName;
                CoBorrower.LastName = c[i].LastName;
                CoBorrower.Birthdate = c[i].Birthdate;
                CoBorrower.Gender__c = c[i].Gender__c;
                CoBorrower.PAN_ID__c = c[i].PAN_ID__c;
                CoBorrower.phone = c[i].phone;
                CoBorrower.Annual_Income_Gross__c =c[i].Annual_Income_Gross__c;
                CoBorrower.Marital_Status__c =c[i].Marital_Status__c;
                CoBorrower.Email =c[i].Email;
                CoBorrower.MobilePhone = c[i].MobilePhone;
                CoBorrower.MailingStreet = c[i].MailingStreet;
                CoBorrower.MailingCity = c[i].MailingCity;
                CoBorrower.MailingState = c[i].MailingState; 
                CoBorrower.MailingCountry = c[i].MailingCountry;   
                CoBorrower.MailingPostalCode = c[i].MailingPostalCode;
                CoBorrower.Residence_Type__c = c[i].Residence_Type__c;
                CoBorrower.Organisation__c = c[i].Organisation__c; 
                //insert CoBorrower;          
            }
            else if (c[i].Borrower_Type__c == 'Guarantor'){
                Guarantor.FirstName =c[i].FirstName;
                Guarantor.LastName = c[i].LastName;
                Guarantor.Birthdate =c[i].Birthdate;
                Guarantor.Gender__c = c[i].Gender__c;
                Guarantor.PAN_ID__c = c[i].PAN_ID__c;
                Guarantor.Phone =c[i].Phone;
                Guarantor.Annual_Income_Gross__c=c[i].Annual_Income_Gross__c;
                Guarantor.Marital_Status__c =c[i].Marital_Status__c;
                Guarantor.Email = c[i].Email;
                Guarantor.MobilePhone = c[i].MobilePhone;
                Guarantor.MailingStreet = c[i].MailingStreet;
                Guarantor.MailingCity = c[i].MailingCity;
                Guarantor.MailingState = c[i].MailingState; 
                Guarantor.MailingCountry = c[i].MailingCountry;   
                Guarantor.MailingPostalCode = c[i].MailingPostalCode;
                Guarantor.Residence_Type__c = c[i].Residence_Type__c;
                Guarantor.Organisation__c = c[i].Organisation__c;
                //  insert Guarantor;
            }
            else if(c[i].Borrower_Type__c =='Patient'){
                Patient.FirstName =c[i].FirstName;
                Patient.LastName =c[i].LastName;
                Patient.Birthdate =c[i].Birthdate;
                Patient.Gender__c = c[i].Gender__c;
                Patient.PAN_ID__c =c[i].PAN_ID__c;
                Patient.Phone =c[i].Phone;
                Patient.Annual_Income_Gross__c =c[i].Annual_Income_Gross__c;
                Patient.Marital_Status__c =c[i].Marital_Status__c;
                Patient.Email = c[i].Email;
                Patient.MobilePhone =c[i].MobilePhone;
                Patient.MailingStreet = c[i].MailingStreet;
                Patient.MailingCity = c[i].MailingCity;
                Patient.MailingState = c[i].MailingState; 
                Patient.MailingCountry = c[i].MailingCountry;   
                Patient.MailingPostalCode = c[i].MailingPostalCode;
                Patient.Residence_Type__c = c[i].Residence_Type__c;
                Patient.Organisation__c = c[i].Organisation__c;
                //  insert Patient;
            }
            
        }

please help on this.

Thanks in advance..
Hi all,

Help me how to bypass the webservice callout in a test class.

Code: 
WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '/ CodeCoverage/ReturnData',
              'http://www.abc.com/xyz/sampleSchema.xsd',
              ' Input_element',
              'http://www.abc.com/xyz/sampleSchema.xsd',
              ‘ResponseElement’,
              ' ResponseElement'}
            );

Hey guys, I'm a self-confessed Apex amateur and was wondering if I could get a hand with something.

 

I'm trying to get Salesforce to hit an external URL on Contact delete. Our site has a registration process which feeds SalesForce new Contacts. From that point on, the two entities in seperate databases (i.e. website.user and salesforce.contact) are synchronised. However, I want to make it so that when a Contact is deleted in SalesForce, their c.ID is pushed to the website by method of a URL suffix. This means that the website can simply 'listen' to SalesForce rather than scan the database for any missing Contact records.

 

This is probably horrendous - and low and behold doesn't work - but can someone give me a hand with this Apex class?:

 

public class ContactDeleteURL {
public static void hitTheServer(Contact[] con) {
for (Contact c:con){
HttpRequest req = new HttpRequest();
req.setEndpoint ('http://www.mywebsite.com/remove_contact?sfid=' + c.Id);
req.setMethod ('POST');
}
}
}

 ..and trigger:

trigger ContactRecordDelete on Contact (after delete) {
Contact[] con = Trigger.new;
ContactDeleteURL.hitTheServer(con);
}

 I'm getting the following error when I try to delete a Contact, if that helps:

 

ContactRecordDelete: execution of BeforeDelete

caused by: System.NullPointerException: Attempt to de-reference a null object

Class.ContactDeleteURL.hitTheServer: line 3, column 16
Trigger.ContactRecordDelete: line 3, column 1