• ttl
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 5
    Replies

Hi,

 

I am trying to access Customer portal through site,I have already done the required configuration on site and Customer portal level.Actual requirement is to access Site from external application using 'siteGuestuser' and then user should be redirected to customer Portal on corect page. when i am debugging and printing username,password and startURL, its getting printed correctly but site.login(UN,PW,StartURL) is returning null as page Reference e.g. UN:-abcd@gmail.com, PW:- Password@123  startURL:='/apex/programpage?proname=test program'. I am also encoding the startURL before passing it.Site domain is not having any prefix associated with it. Error is appearing like: Authentication failed: Authentication to Zone failed.

 

Apex code method are as below:-

      

        String startUrl = Encodingutil.urlDecode(Apexpages.currentPage().getParameters().get('startURL'), 'UTF-8');             
        system.debug('=========Login Is enabled for Site==========='+Site.isLoginEnabled());
        system.debug('=====Start URL========'+startUrl);
        system.debug('=====Portal User Name========'+Username);
        system.debug('=====Portal User Password========'+Password);
        
        PageReference ref = Site.login(Username, Password, startUrl);
                 
         if(ref == null){
            //Get the inaccesible url for the current site
            SiteSettings__c setting = SiteSettings__c.getValues(Site.getName());
            String url = setting == null ? null : setting.Inaccessible_url__c;
            
            System.debug('***Site '+ Site.getName() +' inaccssessible for user '+ setting.Name);           
            ApexPages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Access denied!'));
            
            return null;
         }

 

 

When i am trying with same username ,password to access directly its getting through .

Guys please help me out.Thanks in advance

 

Regards

PK

  • June 07, 2013
  • Like
  • 0

Hi Guys,

 

I have one controller which is working fine in sandbox now i want to deploy it to production,I write test method for this controller but the test coverge is only 59%. Guys I am not finding the way to write the test method which increase the  test coverage  for the controller .My controller code is as follow.

I darked the code which is not covered during execution.

 

public class Accountscorecard {

public String str{get;set;}

public List<Account_Spend__c> accountspend{get;set;}

Account_Spend__c objaccountspend{get;set;}

pagereference p1{get;set;}

 

public Accountscorecard(ApexPages.StandardController controller){

      str = ApexPages.currentPage().getParameters().get('id');

      accountspend=new List<Account_Spend__c>();

      accountspend=[select Account__c,Service_Provider__c,wireline_voice__c,wireless_data__c from Account_Spend__c where Account__c=:str];

     }

 

public Account_Spend__c getObjaccountspend(){

     if(objaccountspend==null){

      objaccountspend=new Account_Spend__c();

       objaccountspend.Account__c=str;

     }

     return objaccountspend;   

     }

 

public pageReference accountspendentry(){

    Account_Spend__c[] accspend= [select id from Account_Spend__c where Account__c=:objaccountspend.Account__c and Service_Provider__c = :objaccountspend.Service_Provider__c]; 

      if(objaccountspend.Service_Provider__c== null){

           objaccountspend.Service_Provider__c.addError('Please select the service provider,you cannot leave it Blank.');

          p1=page.accountspendentry;

          }

//guys this below part is not covering during execution

           else{

               if (accspend.size() > 0 ) {      

                objaccountspend.Service_Provider__c.addError(' This Service Provider already exists  with  this company.');

                p1=page.accountspendentry;

                }else{

                      try{

                          insert objaccountspend;

 

                         }catch(System.DMLException e) {

                               ApexPages.addMessages(e);

                                return null;

                         }

 

       this.accountspend=[select Account__c,Service_Provider__c,wireline_voice__c,wireless_data__c from Account_Spend__c where Account__c=:str];

 

  //this is update method which is called when any new record inserted and new updated value will display on the screen.

 

      accountspendupdate();

 

       p1=page.detailvf;

       p1.setRedirect(true);

       p1.getParameters().put('id',str);

 

       }

     }

      return p1;

  }

 

public pageReference accountspendupdate(){ 

    Double j1=0;Double j2=0;

    try{  update accountspend;

     }catch(System.DMLException e) {

      ApexPages.addMessages(e);

      return null;

      }

   this.accountspend=[select Account__c,Service_Provider__c,wireline_voice__c,wireless_data__c from Account_Spend__c where Account__c=:str];

    for(Account_Spend__c accspend:accountspend){

        j1+= accspend.wireline_voice__c ;

        j2+=accspend.wireless_data__c;

         }

 

      AccountCard__c acccard =[select wireline_voice__c,wireless_data__c from AccountCard__c where Account__c=:str Limit 1];

       acccard.Wireline_Voice__c=j1;acccard.Wireless_Data__c=j2;

       update acccard; 

     return page.detailvf;

 

    }

// test method……

static testMethod void accountscorecard_test(){

 

    Account acc= new Account(Name='Tata',RecordTypeId='012N00000004HgH');

    insert acc;

 

         Account_Spend__c accspend1= new Account_Spend__c (Name='Tcs',Account__c =acc.Id,   Service_Provider__c='TTL',  wireline_voice__c=1,wireless_data__c=1);

 

     insert accspend1;

 

  ApexPages.StandardController sc = new ApexPages.StandardController(acc);

   PageReference viewPageRef = Page.detailvf;

   Test.setCurrentPage(viewPageRef);

    System.CurrentPageReference().getParameters().put('id', acc.id);

    Accountscorecard controllerobj = new Accountscorecard(sc);

    controllerobj.getObjaccountspend();

     controllerobj.accountspendupdate();

     controllerobj.accountspendentry();

    }

 

}

 

 

 

 

Please help me guys to complete my test coverage ,it's urgent for me to deploy it .

Any suggestion would be heartly appreciated.

 

Thanks,

Prince

  • March 03, 2011
  • Like
  • 0

Hi guys,

 

I am getting error: Unknown property 'Accountscore_card.AccountSum.total1'  in my visualforce page.

My VisualForce page is as follow:-

 

<apex:page controller="Accountscore_card">

  <apex:form >

   <apex:pageBlock title="Account's spend on Telecom (Rs. Crore)">

   <apex:pageBlockSection title="Details" Id="NewCard">        

<apex:dataTable value="{!accountSumlist}" var="test" border="1" style="height:20;float: left;" id="stable">

          <apex:column headerValue="Wireline Voice" width="5px">

             <apex:outputText value="{!test.total1}" style="align: center" />

          </apex:column>

          <apex:column headerValue="Wireline Data" width="5px" >

              <apex:outputText value="{!test.total2}"/>

          </apex:column>

                    <apex:column headerValue="Wireless Voice" width="5px" >

             <apex:outputText value="{!test.total3}"/>

          </apex:column>

          <apex:column headerValue="Wireless Data" width="5px" >

             <apex:outputText value="{!test.total4}"/>

          </apex:column>

          <apex:column headerValue="Enterprise Solutions" width="5px" >

              <apex:outputText value="{!test.total5}"/>

          </apex:column>

     </apex:dataTable>

    </apex:pageBlockSection>

  </apex:pageBlock>

</apex:form>

</apex:page>

 

Controller is,

 

 

public class AccountScore_card{

public Double sum1{get;set;}  

public AggregateResult SumResults =

      [SELECT SUM(Account_Score__c.wireline_voice__c) total1,

        SUM(Account_Score__c.wireline_data__c) total2,

        SUM(Account_Score__c.wireless_voice__c) total3,

        SUM(Account_Score__c.wireless_data__c) total4,

        SUM(Account_Score__c.enterprise__c) total5

        FROM Account_Score__c where Account__c=:str];

 

    public class AccountSum {

 

     //public AccountSum(AggregateResult ar){} 

    } 

 public List<AccountSum> accountSumlist = new List<AccountSum>();

 public List<AccountSum> getAccountSumlist(){

    Map<String, String> KeyNames = new Map<String, String>();

    KeyNames.put('total1', 'wirelinevoice');

    KeyNames.put('total2', 'wirelinedata');

    KeyNames.put('total3', 'wirelessvoice');

    KeyNames.put('total4', 'wirelessdata');

    KeyNames.put('total5', 'enterprise');

 

    for (String key : KeyNames.keySet()) {

      AccountSum cs = new AccountSum();

      cs.sum1 = (Double) SumResults.get(key);

      accountSumList.add(cs);

      }

      return AccountSumList;

    }

}

 

 

guys please help me to resolve the issue.

any suggestion would be appreciated.

 

 

Thanks,

 

  • February 10, 2011
  • Like
  • 0

Hi Guys,

 

I have Two Custom object  Account_Score__c and Account_Card__c ,Both Object are having some fields . Some field of Account_Card__c contains value of the sum of particular field of  Account_Score__c(Ex:-Revenue field of Account_Card__c  having the total sum of Revenue field of Account_Score__c which associated to ICICI).I have one controller on Account_Score__c and some visualforcepages .Guys now my requirment is to Populate Revenue and some field from Account_Card__c and put it in tabular format  along with the field of Account_Score__c,where Coulmn will be the field of Account_Score__c,Below this table I want to populate the Field of Account_Card__c in tabular format also .

 

I  am facing issue to Populate the Field of Account_Card__c ,Guys i have one method in controller which Fetch all required field of Account_Card__c and put it in one list.But when i try to reflect on Same visualforce pages then it showing error: Like Unknown Property.

 

 

Guys can u share some  code so that  taking help from this I can complete my requirment.

 

 

Thanks,

Prince

  • February 09, 2011
  • Like
  • 0

Hi Guys,

 

I Created one custom Object which have one Lookup Account field , Based on this Lookup field Value,i want to fetch all records of Custom Object and put it in tabular format using data table.

 

Guys I created two visualforce pages and one controller.First visualforce page is dispalying only the Account Lookup field ,when User click on Next  then the soql query should be executed and save in a list ,Using this list I want to display the value of all field in second Visualforce page using data table.

 

Guys My controller structure as

 

public class Accountscore_card {

public List<Account_Score__c> accList1= new List<Account_Score__c>();

public Account_Score__c acc1{get;set;}

public Accountscore_card (ApexPages.StandardController controller){

acclist1= [select f1,f2,f3...from Account_Score__c where f1=:acc1.f1];

}

public List<Account_Score__c> getAcclist1(){

if(acc1 == null) acc1 = new Account_Score__c();

return acclist1;

}

public PageReference method1(){

return page.recordpage1;

}

public Account_Score__c getAcc1(){

 return acc1;

}

 }

 

First Visual Force Page as

<apex:page standardController="Account_Card__c" extensions="Accountscore_card">

<apex:form >

<apex:pageBlock title="Account Selection">

<apex:inputField Value={!account1.Account__c}/>

<apex:commandButton title="selected account" action="{!method1}" value="Next"/>

</apex:pageBlock>

</apex:form>

</apex:page>

 

second Visual force page like

 

<apex:page standardController="Account_Score__c"  extensions="Accountscore_card">

  <apex:form >

   <apex:pageBlock title="Account's spend on Telecom (Rs. Crore)">

   <apex:pageBlockSection title="Details" Id="NewCard">

  

    <apex:dataTable value="{!acclist1}" var="test" border="1" style="height:20;float: left;" id="stable">

     <apex:column headerValue="Account Name" width="5px">

              <apex:outputField value="{!test.field1}" style="align: center" />

     </apex:column>

--------------------

--------------------

---------------------

  </apex:dataTable></apex:pageBlocksection> 

</apex:pageBlock>

</apex:form>

</apex:page>

 

Guys please help.....

 

Thanks

Prince

 

  • February 03, 2011
  • Like
  • 0

Hi Guys,

 I want to apply Validation rule such that if user once change the Opportunity stages from stage 1 to stage 2 or stage 3,then he cannot change the stage again from stage 3 to neither stage 2 nor stage 1.

 

Guys i used  the following fuction to validate but it's not working.

 

IF(OR(ISPICKVAL(Stagename,"Stage2"),ISPICKVAL(StageName,"stage3")), 

 

NOT(AND(ISCHANGED(StageName),ISPICKVALUE(StageName,"stage1"))),Null)

 

Guys Signature are like that I mentioned Only 3 because there are many stages ,which looks Very complex.

 

Please help,Any suggestion would be appreciate.

 

Thanks,

  • January 22, 2011
  • Like
  • 0

Hi Guys,

 

I want to customize my own Forecast category (Pipeline, Expected Closure and Closed won) instead of the (Quota,Pipeline,commit,Best case and Closed won).

All Opportunity which probability is 100% should come under Closed won and rest of the opportunity comes under Pipeline.

In Expected closure category the forecast revenue should be the multiplication of winning probability and Total Revenue generated from the opportunity.

 

What changes I have to make to complete this requirement .

Any suggestion would be appreciated.

 

Thanks,

 

 

  • January 13, 2011
  • Like
  • 0

Hi Guys,

 

I have one controller which is working fine in sandbox now i want to deploy it to production,I write test method for this controller but the test coverge is only 59%. Guys I am not finding the way to write the test method which increase the  test coverage  for the controller .My controller code is as follow.

I darked the code which is not covered during execution.

 

public class Accountscorecard {

public String str{get;set;}

public List<Account_Spend__c> accountspend{get;set;}

Account_Spend__c objaccountspend{get;set;}

pagereference p1{get;set;}

 

public Accountscorecard(ApexPages.StandardController controller){

      str = ApexPages.currentPage().getParameters().get('id');

      accountspend=new List<Account_Spend__c>();

      accountspend=[select Account__c,Service_Provider__c,wireline_voice__c,wireless_data__c from Account_Spend__c where Account__c=:str];

     }

 

public Account_Spend__c getObjaccountspend(){

     if(objaccountspend==null){

      objaccountspend=new Account_Spend__c();

       objaccountspend.Account__c=str;

     }

     return objaccountspend;   

     }

 

public pageReference accountspendentry(){

    Account_Spend__c[] accspend= [select id from Account_Spend__c where Account__c=:objaccountspend.Account__c and Service_Provider__c = :objaccountspend.Service_Provider__c]; 

      if(objaccountspend.Service_Provider__c== null){

           objaccountspend.Service_Provider__c.addError('Please select the service provider,you cannot leave it Blank.');

          p1=page.accountspendentry;

          }

//guys this below part is not covering during execution

           else{

               if (accspend.size() > 0 ) {      

                objaccountspend.Service_Provider__c.addError(' This Service Provider already exists  with  this company.');

                p1=page.accountspendentry;

                }else{

                      try{

                          insert objaccountspend;

 

                         }catch(System.DMLException e) {

                               ApexPages.addMessages(e);

                                return null;

                         }

 

       this.accountspend=[select Account__c,Service_Provider__c,wireline_voice__c,wireless_data__c from Account_Spend__c where Account__c=:str];

 

  //this is update method which is called when any new record inserted and new updated value will display on the screen.

 

      accountspendupdate();

 

       p1=page.detailvf;

       p1.setRedirect(true);

       p1.getParameters().put('id',str);

 

       }

     }

      return p1;

  }

 

public pageReference accountspendupdate(){ 

    Double j1=0;Double j2=0;

    try{  update accountspend;

     }catch(System.DMLException e) {

      ApexPages.addMessages(e);

      return null;

      }

   this.accountspend=[select Account__c,Service_Provider__c,wireline_voice__c,wireless_data__c from Account_Spend__c where Account__c=:str];

    for(Account_Spend__c accspend:accountspend){

        j1+= accspend.wireline_voice__c ;

        j2+=accspend.wireless_data__c;

         }

 

      AccountCard__c acccard =[select wireline_voice__c,wireless_data__c from AccountCard__c where Account__c=:str Limit 1];

       acccard.Wireline_Voice__c=j1;acccard.Wireless_Data__c=j2;

       update acccard; 

     return page.detailvf;

 

    }

// test method……

static testMethod void accountscorecard_test(){

 

    Account acc= new Account(Name='Tata',RecordTypeId='012N00000004HgH');

    insert acc;

 

         Account_Spend__c accspend1= new Account_Spend__c (Name='Tcs',Account__c =acc.Id,   Service_Provider__c='TTL',  wireline_voice__c=1,wireless_data__c=1);

 

     insert accspend1;

 

  ApexPages.StandardController sc = new ApexPages.StandardController(acc);

   PageReference viewPageRef = Page.detailvf;

   Test.setCurrentPage(viewPageRef);

    System.CurrentPageReference().getParameters().put('id', acc.id);

    Accountscorecard controllerobj = new Accountscorecard(sc);

    controllerobj.getObjaccountspend();

     controllerobj.accountspendupdate();

     controllerobj.accountspendentry();

    }

 

}

 

 

 

 

Please help me guys to complete my test coverage ,it's urgent for me to deploy it .

Any suggestion would be heartly appreciated.

 

Thanks,

Prince

  • March 03, 2011
  • Like
  • 0

Hi guys,

 

I am getting error: Unknown property 'Accountscore_card.AccountSum.total1'  in my visualforce page.

My VisualForce page is as follow:-

 

<apex:page controller="Accountscore_card">

  <apex:form >

   <apex:pageBlock title="Account's spend on Telecom (Rs. Crore)">

   <apex:pageBlockSection title="Details" Id="NewCard">        

<apex:dataTable value="{!accountSumlist}" var="test" border="1" style="height:20;float: left;" id="stable">

          <apex:column headerValue="Wireline Voice" width="5px">

             <apex:outputText value="{!test.total1}" style="align: center" />

          </apex:column>

          <apex:column headerValue="Wireline Data" width="5px" >

              <apex:outputText value="{!test.total2}"/>

          </apex:column>

                    <apex:column headerValue="Wireless Voice" width="5px" >

             <apex:outputText value="{!test.total3}"/>

          </apex:column>

          <apex:column headerValue="Wireless Data" width="5px" >

             <apex:outputText value="{!test.total4}"/>

          </apex:column>

          <apex:column headerValue="Enterprise Solutions" width="5px" >

              <apex:outputText value="{!test.total5}"/>

          </apex:column>

     </apex:dataTable>

    </apex:pageBlockSection>

  </apex:pageBlock>

</apex:form>

</apex:page>

 

Controller is,

 

 

public class AccountScore_card{

public Double sum1{get;set;}  

public AggregateResult SumResults =

      [SELECT SUM(Account_Score__c.wireline_voice__c) total1,

        SUM(Account_Score__c.wireline_data__c) total2,

        SUM(Account_Score__c.wireless_voice__c) total3,

        SUM(Account_Score__c.wireless_data__c) total4,

        SUM(Account_Score__c.enterprise__c) total5

        FROM Account_Score__c where Account__c=:str];

 

    public class AccountSum {

 

     //public AccountSum(AggregateResult ar){} 

    } 

 public List<AccountSum> accountSumlist = new List<AccountSum>();

 public List<AccountSum> getAccountSumlist(){

    Map<String, String> KeyNames = new Map<String, String>();

    KeyNames.put('total1', 'wirelinevoice');

    KeyNames.put('total2', 'wirelinedata');

    KeyNames.put('total3', 'wirelessvoice');

    KeyNames.put('total4', 'wirelessdata');

    KeyNames.put('total5', 'enterprise');

 

    for (String key : KeyNames.keySet()) {

      AccountSum cs = new AccountSum();

      cs.sum1 = (Double) SumResults.get(key);

      accountSumList.add(cs);

      }

      return AccountSumList;

    }

}

 

 

guys please help me to resolve the issue.

any suggestion would be appreciated.

 

 

Thanks,

 

  • February 10, 2011
  • Like
  • 0

Hi Guys,

 I want to apply Validation rule such that if user once change the Opportunity stages from stage 1 to stage 2 or stage 3,then he cannot change the stage again from stage 3 to neither stage 2 nor stage 1.

 

Guys i used  the following fuction to validate but it's not working.

 

IF(OR(ISPICKVAL(Stagename,"Stage2"),ISPICKVAL(StageName,"stage3")), 

 

NOT(AND(ISCHANGED(StageName),ISPICKVALUE(StageName,"stage1"))),Null)

 

Guys Signature are like that I mentioned Only 3 because there are many stages ,which looks Very complex.

 

Please help,Any suggestion would be appreciate.

 

Thanks,

  • January 22, 2011
  • Like
  • 0

I'm using AggregateResult in order to return sum of shipments for every combination of customeregion,productfamily and year,here is the query i'm using
apex code:
public AggregateResult[] queryResult { get {return queryResult ;} set{ queryResult = value ;} }
public AggregateResult[] getschemalist22()
{
 queryResult = [select sum(shp_4000__c) salesshipments,sum(shp_4010__c) inventoryshipments,sum(sos_5000__c) salesoutshipments,Time__r.Years__c years,
   Customer__r.Region__c regions, JaguarProduct__r.Family__c families from FACT_LL__c
   group by Time__r.Years__c, Customer__r.Region__c, JaguarProduct__r.Family__c];
 return queryResult;
}

Now i required to display this aggregateresult in my visualforce page pageblocktable like

Customerregion       Productfamily        Year          Measures                                values

ASIA                             prodfamily1             2010         salesshipments                      2000
                                                                                          inventoryshipments                340
                                                                                          salesoutshipments                1090

 

NORTH AMERICA     prodfamily1            2010         salesshipments                      6100
                                                                                          inventoryshipments                900
                                                                                          salesoutshipments                5600

 

which displays 2 records with "sum of shipments for region asia,productfamily1,year 2010" and"sum of shipments for region northamerica,productfamily1,year 2010".

 

please specify if this is the right way to get aggregateresult,if yes please let me know how to display it in visualforce page

as desired or is there any other way to display the result.

Any help is much appreciated.

 

Thanks & Regards,

Satya.