• JWykel
  • NEWBIE
  • 165 Points
  • Member since 2012

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 40
    Replies
Hi All plz tell me how to write test class for bellow method


public PageReference AccNext() {                  if(Account.CIS_No_new__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter CIS number');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;         }         if(Account.Salutation__c == Null){           ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Salutation for primary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;          }         if(Account.LastName__c== Null){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Primary customer Lastname');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;         }                       //====================== new logic added for salutation and gender matching for Primary/Secondary Customer=====================         if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Mrs.' && Account.Sex__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }         if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Mr.' && Account.Sex__c == 'F'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Male under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }        if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Ms' && Account.Sex__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }                                    //========================================= end of new logic ===============================================================================================         if(Account.Marital_Status__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer marital status');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Account.Education1__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Education');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }                  if(Account.IdentityProof__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer ID type1');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.IdentityProofNo__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Identity No');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;                  }         //updated for new id proof details         if(Account.IdentityProof_coborr__c==Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer ID type2');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.IdentityProofNo1__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Identity No2');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;                  }// updation end -         if(Account.Aadhar_Card__c=='Yes' && (Account.Aadhar_Card_No__c==null || Account.Aadhar_Card_No__c=='')){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Aadhar card Number');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Name== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer First name');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Last_Name__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer Last name');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Salutation__c == Null)         {           ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Salutation for secondary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;          }          if(Account.Name == Secondary.Name && Account.LastName__c ==   Secondary.Last_Name__c){             ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Primary and Secondary customer name should not be same');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;         }         if(Secondary.Date_of_Birtht__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary Customer Date of Birth');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(((Secondary.FH_FirstName__c == Null || Secondary.FH_LastNames__c == Null) && (Secondary.Spouse_First_Name_SC__c== Null || Secondary.Spouse_Last_Name_SC__c == Null)) && Account.Opted_for_NPS_Lite__c == 'No')  {            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Fathers/Spouse first name and last name of Secondary Customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;                  }                  if( (Secondary.FH_FirstName__c== Null || Secondary.FH_LastNames__c == Null)&& Account.Opted_for_NPS_Lite__c == 'Yes'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Fathers first and last name of Secondary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;                  }         /*  Logi for Gender and Salutation  */         if(Secondary.Gender__c != Null && Secondary.Salutation__c != Null && Secondary.Salutation__c == 'Mr.' && Secondary.Gender__c == 'F'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Male under Secondary Customer Details');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;                     }           if(Secondary.Gender__c != Null && Secondary.Salutation__c != Null && Secondary.Salutation__c == 'Mrs.' && Secondary.Gender__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Secondary Customer Details');            ApexPages.addMessage(Msg);             if(!test.isrunningTest())            return null;                     }                            if(Secondary.Marital_Statuss__c== Null ){                 ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Marital Status');                 ApexPages.addMessage(msg);                 if(!test.isrunningTest())                  return null;             }         */          if(Secondary.Educations__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer Education');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Identity_Proofs__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer ID Type');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }         if(Secondary.Identity_ProofNo__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Identity Proof No');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Gender__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer SEX');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Nature_of_Employment__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Nature of Employement');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Account.Caste__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Caste');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.Religion__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Religion');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }                     else         {                       try{                                  Upsert(Account);                 Account StdaccListfmly = new Account();                             RecordType SecondaryRt= [SELECT DeveloperName,Id,Name FROM RecordType where DeveloperName='For_DEO' and sobjectType='Secondary_Customer_Details__c'];                                  Secondary.RecordtypeId=SecondaryRt.Id;                 StdaccListfmly=[Select id, Name,Age_of_Borrower1__c,Natureofemployment__c from Account where Id =:account.Id limit 1];                 Secondary.Account__c= StdaccListfmly.id;                 upsert(Secondary);//Database.upsert(Secondary); commented by bhanu to catch dml exception - 3 dec                 Secondary_Customer_Details__c SecListfmly = new Secondary_Customer_Details__c();                 SecListfmly=[Select id,Nature_of_Employment__c,Type_of_Relation__c,Length_of_Business_Service_Years__c ,Relationdhip_with_Secondary_Customer__c,Name,Age_of_Co_Borrower__c from Secondary_Customer_Details__c where Id =:Secondary.Id limit 1];                 system.debug('**********Relationdhip_with_Secondary_Customer__c***********'+SecListfmly.Relationdhip_with_Secondary_Customer__c);                 system.debug('**********Type_of_Relation__c***********'+SecListfmly.Type_of_Relation__c);                 String nextTabValue = 'ContactDetails';                   if(nextTabValue != null){                    currentTab = nextTabValue;                         Opportunity.Account__c= account.id;                      Opportunity.Secondary_Customer_Details__c=secondary.Id;                                                          }            }            catch(DmlException e){                 ApexPages.addMessages(e);                 LogsExceptionClass.insertLog(e.getMessage(),e.getLineNumber(),e.getTypeName(),String.valueOf(e.getcause()),e.getStackTraceString());            }        }        return null;     }

 
  • March 06, 2015
  • Like
  • 0

Hi Everybody,

 

I have a cross-object formula field, and my goal is to roll it up to the parent object.  Since roll-ups on those types of formula fields aren't allowed under standard SFDC practice, I thought I'd write a trigger that copies the field, after insert/update, to a separate blank field (currency type in my case) and use *that* field as the roll-up target.  I assume it has to be after-insert/update so the formual field can calculate.

 

This code worked fine for any given record, but I'm stuck at how to bulkify the trigger in case I need to mass insert/mass update.

 

Trigger CopyfromFormulaToBlankField on Custom__c (after insert, after update) {

    List<Custom__c> clist = [SELECT Non_Formula_Field_for_Rollup__c, Formula_Field__c FROM Custom__c WHERE Id IN: Trigger.newMap.keySet()];
    
    for (Custom__c c :clist){
    
        if(lh.Non_Formula_Field_for_Rollup__c != lh.Formula_Field__c){
        
            lh.Non_Formula_Field_for_Rollup__c = lh.Formula_Field__c;
            update lhlist;
        
        }
    }
}

 

 

Any ideas?

Thanks!

 

  • October 31, 2013
  • Like
  • 0

Hi internet,

 

I have a pretty simple query in a User Trigger that is supposed to determine all records in a custom object that are owned by the Users being updated in the Trigger.

 

 [select CreatedByID from CustomObject__c where CreatedByID in :Trigger.newMap.keyset()]

 

CustomObject__c has over 140,000 rows.  Trigger.newMap.keyset().size = 1.

 

Interestingly I am able to manually run this query through the developer console and it returns 0 rows (rather quickly too...)

 

What is the correct way to query a large table?  

 

Note I am aware that I cannot return more than 50,000 rows in a query but I do not expect this query to return more than a couple dozen ever.

 

Full error:

Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times

 

 

EDIT

Im doing some more research and found this

http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_VLSQ.htm

 

  • The following fields are indexed by default: primary keys (Id, Name and Owner fields), foreign keys (lookup or master-detail relationship fields), audit dates (such as LastModifiedDate), and custom fields marked as External ID or Unique.

The CreatedByID is the owner field of my custom object so according to SF docs my query should be fine??

Hi,

 

I  need a trigger when account owner changes,my customobject owner(Look up relationship) also changes .

 

Trigger updateowner on Account (after insert,after update) {

    set<Id> setOfAccoutOwnerChanged = new set<Id>();
    for(Account a : Trigger.new){
    if(a.OwnerId != Trigger.oldMap.get(a.Id).OwnerId)
    setOfAccoutOwnerChanged.add(a.Id);
    }
    if(!setOfAccoutOwnerChanged.isEmpty()) {
    List<Customobject__c> listOfCandidatesToUpdate = new List<Customobject__c>();
    
    Map<Id,Account> accountMap = new Map<Id,Account>();
//It error at this line.   
accountmap=[SELECT ID,OwnerId,(Select id,name,ownerid from Customobject__c) FROM Account WHERE Id =:setOfAccoutOwnerChanged]; } }

 

I am failing with my SOQL query...What am i missing.I feel this is similar to account-contact 

Hello there, I have created a domain in SF called www.mycustomdomain.com.  This works because my domain registrar (GoDaddy) allows me to specify a CNAME record for "www" as "www.mycustomdomain.com.0000000000000000.live.siteforce.com".  I can also forward traffic from mycustomdomain.com to www.mycustomdomain.com to get it to resolve using 302 codes in my registrar.  However, when I navigate to https://mycustomdomain.com it does not resolve to your servers.  GoDaddy said this is because you are not hosting mycustomdomain.com but host www.mycustomdomain.com.  There is a workaround but it will cost $$$ (i.e. create a separate dedicated site with an IP address; point the A Record to that address and foward all traffic to my www site using web page headers).  Please help!
  • January 06, 2017
  • Like
  • 0
I've created a custom URL for my site following the directions in this article (https://help.salesforce.com/apex/HTViewSolution?urlname=Setting-Up-Custom-Domains-for-Salesforce-Sites-and-Setting-up-HTTPS-Support-for-Branded-Custom-Domains&language=en_US).  However, it says in step #1 to point to a particular CNAME.  The problem is that when I type the CNAME into a browser the destination is unreachable - I don't want to setup a CNAME when the destination is unreachable because I believe this will take our website offline?  Also, when I followed step 3 of the article to add HTTPS support it does not work - the site still directed to Secure.Force.Com and does not have a custom URL.  Below are more details about my setup.  Do you guys know why the CNAME is unreachable?  Also, can you figure out why the custom URL is not working with SSL?

*** SALESFORCE SETUP ****

DOMAINS:
labrix.force.com [CANNOT EDIT]
labrix.secure.force.com [CANNOT EDIT]
www.labrix.com [CAN EDIT; HAS www.labrix.com CERT INSTALLED]

SITES
http://labrix.force.com [CAN EDIT [SET TO Require Secure Connections (HTTPS)]]

CUSTOM URLS
labrix.force.com [CANNOT DELETE [SET TO Require Secure Connections (HTTPS)]]
labrix.secure.force.com [CANNOT DELETE [SET TO Require Secure Connections (HTTPS)]]
www.labrix.com [SET TO Primary Custom URL]

*** DOMAIN REGISTRAR SETUP ****

REGISTERED DOMAIN:  labrix.com

HOST
@ => 174.129.25.170 (wwwizer.com)

CNAMES
www => labrix.force.com

TXT
salesforceid => {our unique key}
Why does using GROUP BY ROLLUP multiply the number of query rows returned by the number of fields you are rolling up + 1?

Example: I have 3408 records in the database. If I run:
[SELECT Sex__c, IsLow__c, COUNT(Id) FROM MyObject__c GROUP BY Sex__c, IsLow__c]
I get the number of query rows as 3408. If I run:
[SELECT Sex__c, IsLow__c, COUNT(Id) FROM MyObject__c GROUP BY ROLLUP(Sex__c, IsLow__c)]
I get the number of query rows as 10224.

It seems that the ROLLUP is 'touching' each record for each grouping field and then again for a total.
Is this the case? If so, how can I get around it when I have to run the query on larger data sets?
Is this documented anywhere?
  • March 06, 2015
  • Like
  • 0
I have this bit of code:
public AccountSummary__c Summary{ 
        get{
            if(AccountId == null){
                return new AccountSummary__c();
            }
            
            AccountTrigger.ProcessAccountSummary(AccountId); //Processes and upserts the record
            //SELECT the record that was processed and upserted above
            return Database.query('SELECT ' + SelectStar + ' FROM AccountSummary__c WHERE AccountId__c = :AccountId');
        }
    }
The page that uses this Summary record looks something like this:
<apex:pageBlock >
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem ><apex:outputLabel value="Tests {!MonthNames[15]}"/><apex:outputText value="{!Summary.T15MA__c}"/></apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem ><apex:outputLabel value="Patients {!MonthNames[15]}"/><apex:outputText value="{!Summary.P15MA__c}"/></apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem ><apex:outputLabel value="Tests {!MonthNames[14]}"/><apex:outputText value="{!Summary.T14MA__c}"/></apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem ><apex:outputLabel value="Patients {!MonthNames[14]}"/><apex:outputText value="{!Summary.P14MA__c}"/></apex:pageBlockSectionItem>
...

When I open the page, all fields are correctly calculated and viewed. I view the debug logs and it shows 1 DML statement/row and shows the upsert with no errors. The fact that it does the upsert and then does a SELECT from the database for the record would lead me to believe the record was updated in the database.

However, this is not the case! When I view the record directly or via a report, the fields are not updated; they remain at their previous values.

If I run the AccountTrigger.ProcessAccountSummary(AccountId); via Execute Anonymous, the record gets updated correctly and shows in reports/view correctly.

Has anyone else experienced this? Does it have something to do with 'when' this code is called, in that it is called in a 'get' of a property for a VF page? How can that 'get' SELECT from the database the correct values when the database does not appear to get updated with correct values?
  • February 20, 2015
  • Like
  • 0
Since the sandbox update to Spring '15, our sandbox has been unable to save in the Developer Console. We can open items (classes, pages, etc) but when we try to save them, we get "Failed to create createContainerMember for containerId=undefined: null is not a valid containerId" errors and they do not save.

We have tried the resolution found in this solution: https://help.salesforce.com/apex/HTViewSolution?id=000204953&language=en_US
but creating a new Workspace does not work (as in the Workspace is not created) and it does not fix the save issue. 
We have also tried switching workspaces, which also does not work.

We have cleared cache and tried on multiple computers from multiple networks.
  • January 23, 2015
  • Like
  • 0
We have a couple of people that work on the weekends and the particular VisualForce pages they access continuously time out for them, especially during the first load.  The people working during the week do not have this issue working on the same pages.  Is there any way we can find out what is causing this to happen only on weekends?  Regular SalesForce pages open and load just fine during the time, but when they try to go into our custom pages, it times out.
  • October 13, 2014
  • Like
  • 0

I attempted SF Support twice to fix this issue, which has failed to resolve the issue.  So, I wanted to take it to the developer community to see if it is a problem with only us or if it's something larger.

 

We have a couple of classes that give the functionaly to change the users' passwords by calling System.setPassword(<UserId>, <Password);  These classes have been unchanged for many months and we have been deploying other code just fine.  This was the case until the Winter '14 update.  Ever since that update we have not been able to deploy *any* code due to those two classes erroring out with an Unexpected_Exception.  This happens even if we try to deploy an empty class.  If we comment out the lines (thus removing that functionality), the deployments are successful. 

One more oddity about this is that the test methods for these classed succeed if they are ran; it only fails during a deploy.

 

So, does anyone use this functionality/call?  Are they experiencing problems deploying?

  • October 31, 2013
  • Like
  • 0

I found this thread:  Link 

It sounds like what I am experiencing, but I could not figure anything out from the answer at the bottom.  

I have a desktop application using a Web Reference with the Enterprise WSDL.  The initial connection (login) takes anywhere between 8 and 20 seconds; every subsequent request is very quick.  Is there any way to eliminate this long delay upon the first connection?

 

My Googling has failed finding any settings that the post mentioned or even more generalized searches trying to figure out why the initial connection might take so long or how to fix.

 

Any help would be greatly appreciated!  

Thanks.

  • September 20, 2013
  • Like
  • 0

I read here that CMSForce can make use of static resources in the pageitem.  Is this correct?  And, if so, how do you reference them in the pageitem block?

I'll give an example:

Visualforce:  <img src="{!URLFOR($Resource.ContentImages, 'PatientHomepage/AdrenalDysfunctionText.png')}"/>

 

What would be the equivalant CMSForce code to make that happen?  I've tried exactly that...it, of course, put '{!URLFOR($Resource.ContentImages, 'PatientHomepage/AdrenalDysfunctionText.png')}' as the source, not mapping to the actual resource.

Hello there, I have created a domain in SF called www.mycustomdomain.com.  This works because my domain registrar (GoDaddy) allows me to specify a CNAME record for "www" as "www.mycustomdomain.com.0000000000000000.live.siteforce.com".  I can also forward traffic from mycustomdomain.com to www.mycustomdomain.com to get it to resolve using 302 codes in my registrar.  However, when I navigate to https://mycustomdomain.com it does not resolve to your servers.  GoDaddy said this is because you are not hosting mycustomdomain.com but host www.mycustomdomain.com.  There is a workaround but it will cost $$$ (i.e. create a separate dedicated site with an IP address; point the A Record to that address and foward all traffic to my www site using web page headers).  Please help!
  • January 06, 2017
  • Like
  • 0
I've created a custom URL for my site following the directions in this article (https://help.salesforce.com/apex/HTViewSolution?urlname=Setting-Up-Custom-Domains-for-Salesforce-Sites-and-Setting-up-HTTPS-Support-for-Branded-Custom-Domains&language=en_US).  However, it says in step #1 to point to a particular CNAME.  The problem is that when I type the CNAME into a browser the destination is unreachable - I don't want to setup a CNAME when the destination is unreachable because I believe this will take our website offline?  Also, when I followed step 3 of the article to add HTTPS support it does not work - the site still directed to Secure.Force.Com and does not have a custom URL.  Below are more details about my setup.  Do you guys know why the CNAME is unreachable?  Also, can you figure out why the custom URL is not working with SSL?

*** SALESFORCE SETUP ****

DOMAINS:
labrix.force.com [CANNOT EDIT]
labrix.secure.force.com [CANNOT EDIT]
www.labrix.com [CAN EDIT; HAS www.labrix.com CERT INSTALLED]

SITES
http://labrix.force.com [CAN EDIT [SET TO Require Secure Connections (HTTPS)]]

CUSTOM URLS
labrix.force.com [CANNOT DELETE [SET TO Require Secure Connections (HTTPS)]]
labrix.secure.force.com [CANNOT DELETE [SET TO Require Secure Connections (HTTPS)]]
www.labrix.com [SET TO Primary Custom URL]

*** DOMAIN REGISTRAR SETUP ****

REGISTERED DOMAIN:  labrix.com

HOST
@ => 174.129.25.170 (wwwizer.com)

CNAMES
www => labrix.force.com

TXT
salesforceid => {our unique key}
Why does using GROUP BY ROLLUP multiply the number of query rows returned by the number of fields you are rolling up + 1?

Example: I have 3408 records in the database. If I run:
[SELECT Sex__c, IsLow__c, COUNT(Id) FROM MyObject__c GROUP BY Sex__c, IsLow__c]
I get the number of query rows as 3408. If I run:
[SELECT Sex__c, IsLow__c, COUNT(Id) FROM MyObject__c GROUP BY ROLLUP(Sex__c, IsLow__c)]
I get the number of query rows as 10224.

It seems that the ROLLUP is 'touching' each record for each grouping field and then again for a total.
Is this the case? If so, how can I get around it when I have to run the query on larger data sets?
Is this documented anywhere?
  • March 06, 2015
  • Like
  • 0
Hello Everyone,

I need to compare the Trigger.Old and Trigger.new Values in Apex Callout 
My code goes here 

if(Trigger.IsUpdate && Trigger.isBefore)
    {
        Jcoreutil.JcoreAdd(trigger.newMap.keyset());
        contactHandler.onQCCSupervisor(Trigger.New);
    }


public static void JcoreAdd(Set<Id> contactIdSet)
      {
        //if(!WorkFkowvalidatorclass.hasAlreadyDone()){
        Set<Id> TerminateCntId= new Set<Id>();
        Set<Id> RepIdsValue= new Set<Id>();
        List<Id> CntListIds= new List<Id>();
        List<contact> TerminateCntList= new List<contact>();
        
             String   RepHireDate;
          Datetime HireDate;
          Datetime Birthdate;
          String   BithdateRep;
          String   MobileNumber1;
          String   MobileNumber;
          String   HomeNumber1;
          String   HomeNumber;
          Datetime QAMDSPStartDate;
          Datetime QAMDSPEndDate;
          String  QAMDSPStartDateConversion;
          String  QAMDSPEndDateConversion;
          Datetime QCCDSPStartDate;
          Datetime QCCDSPEndDate;
          String QCCDSPStartDateConversion;
          List<Contact>  contactUpdate= new List<Contact>();
          String prospectRecType = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Rep').getRecordTypeId();
          List<Contact> LstCntQuery=[Select Id,Name,CRD__c,FirstName,LastName,Middle_name__c,Gender__c,Address_Type__c,
                                          MailingStreet,MailingCity,MailingState,MailingPostalCode,Email,MobilePhone,Alt_Email__c,
                                          QAM_DSP__r.Name,QAM_DSP__r.CRD__C,QCC_DSP__r.CRD__C,QAM_DSP__r.FirstName,
                                           QAM_DSP__r.LastName,QCC_DSP__r.FirstName,QCC_DSP__r.LastName,QCC_DSP__r.Start_Date__c,QCC_DSP__r.Term_Date__c,
                                            OtherCity,OtherPostalCode,OtherState,OtherStreet ,Birthdate,Rep_Status__c,QAM_DSP__r.Start_Date__c,QAM_DSP__r.Term_Date__c,
                                           QCC_DSP__c,RecordTypeId ,QAM_DSP_End_Date__c,QCC_DSP_Start_Date__c,QAM_DSP_Start_Date__c,Salutation,Term_Date__c,Start_Date__c,Jcore_Status__c,LastModifiedDate,HomePhone,Phone,OtherPhone
                                            from Contact where Id IN:contactIdSet];


I need to compare the fields QAM_DSP__r.CRD__C

Here is breif why i am going for that 
before update i am trying to update this value in another system.
I have Rep tied to a Manager 
First call out takes the Manager Name,Start date  and Insert the values.
after few days the Manager changes that time the Second Manager start date should be equal to FirsrManger End Date .
So i thought to compare the new an old values  
based on new and old values i need to control to populate the End Date Accordingly.

Please help me out.

Regards,
Jyo

 
Hi

Some where i am going wrong and i keep on getting tis error.
I am writing a batch apex and i just want to query opportunities whose stage is not WON.

This is what i had written and it gives me error saying 'execpted semi colon found something or other'

Here is my part of code.Please correct me .I used !=.
I tried using IN,Includes,Exculdes.
But no Luck.
global Database.QueryLocator start(Database.Batchablecontext BC){
    query='select id from Opportunity where stage != 'WON' ';
    return Database.getQueryLocator(query);

Thank you!
 
Hey guys,

So, my org has some older test classes that seem to obstruct me from launching new code (sometimes I can go disable 14 different validation rules as a workaround). I'm able to delete classes via Eclipse IDE. I'm very tempted to delete the obstructing test classes, but I want to make sure I'm not going to be causing irreversival damage.

I know this would bring down the organizational code coverage. Also, if there are any conflict with future code, this might not be evident during development. Anything else that you know this would affect?

Thanks in advance for your help!
Hi All plz tell me how to write test class for bellow method


public PageReference AccNext() {                  if(Account.CIS_No_new__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter CIS number');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;         }         if(Account.Salutation__c == Null){           ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Salutation for primary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;          }         if(Account.LastName__c== Null){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Primary customer Lastname');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;         }                       //====================== new logic added for salutation and gender matching for Primary/Secondary Customer=====================         if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Mrs.' && Account.Sex__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }         if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Mr.' && Account.Sex__c == 'F'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Male under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }        if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Ms' && Account.Sex__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }                                    //========================================= end of new logic ===============================================================================================         if(Account.Marital_Status__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer marital status');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Account.Education1__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Education');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }                  if(Account.IdentityProof__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer ID type1');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.IdentityProofNo__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Identity No');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;                  }         //updated for new id proof details         if(Account.IdentityProof_coborr__c==Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer ID type2');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.IdentityProofNo1__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Identity No2');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;                  }// updation end -         if(Account.Aadhar_Card__c=='Yes' && (Account.Aadhar_Card_No__c==null || Account.Aadhar_Card_No__c=='')){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Aadhar card Number');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Name== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer First name');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Last_Name__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer Last name');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Salutation__c == Null)         {           ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Salutation for secondary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;          }          if(Account.Name == Secondary.Name && Account.LastName__c ==   Secondary.Last_Name__c){             ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Primary and Secondary customer name should not be same');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;         }         if(Secondary.Date_of_Birtht__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary Customer Date of Birth');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(((Secondary.FH_FirstName__c == Null || Secondary.FH_LastNames__c == Null) && (Secondary.Spouse_First_Name_SC__c== Null || Secondary.Spouse_Last_Name_SC__c == Null)) && Account.Opted_for_NPS_Lite__c == 'No')  {            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Fathers/Spouse first name and last name of Secondary Customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;                  }                  if( (Secondary.FH_FirstName__c== Null || Secondary.FH_LastNames__c == Null)&& Account.Opted_for_NPS_Lite__c == 'Yes'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Fathers first and last name of Secondary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;                  }         /*  Logi for Gender and Salutation  */         if(Secondary.Gender__c != Null && Secondary.Salutation__c != Null && Secondary.Salutation__c == 'Mr.' && Secondary.Gender__c == 'F'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Male under Secondary Customer Details');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;                     }           if(Secondary.Gender__c != Null && Secondary.Salutation__c != Null && Secondary.Salutation__c == 'Mrs.' && Secondary.Gender__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Secondary Customer Details');            ApexPages.addMessage(Msg);             if(!test.isrunningTest())            return null;                     }                            if(Secondary.Marital_Statuss__c== Null ){                 ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Marital Status');                 ApexPages.addMessage(msg);                 if(!test.isrunningTest())                  return null;             }         */          if(Secondary.Educations__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer Education');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Identity_Proofs__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer ID Type');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }         if(Secondary.Identity_ProofNo__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Identity Proof No');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Gender__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer SEX');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Nature_of_Employment__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Nature of Employement');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Account.Caste__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Caste');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.Religion__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Religion');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }                     else         {                       try{                                  Upsert(Account);                 Account StdaccListfmly = new Account();                             RecordType SecondaryRt= [SELECT DeveloperName,Id,Name FROM RecordType where DeveloperName='For_DEO' and sobjectType='Secondary_Customer_Details__c'];                                  Secondary.RecordtypeId=SecondaryRt.Id;                 StdaccListfmly=[Select id, Name,Age_of_Borrower1__c,Natureofemployment__c from Account where Id =:account.Id limit 1];                 Secondary.Account__c= StdaccListfmly.id;                 upsert(Secondary);//Database.upsert(Secondary); commented by bhanu to catch dml exception - 3 dec                 Secondary_Customer_Details__c SecListfmly = new Secondary_Customer_Details__c();                 SecListfmly=[Select id,Nature_of_Employment__c,Type_of_Relation__c,Length_of_Business_Service_Years__c ,Relationdhip_with_Secondary_Customer__c,Name,Age_of_Co_Borrower__c from Secondary_Customer_Details__c where Id =:Secondary.Id limit 1];                 system.debug('**********Relationdhip_with_Secondary_Customer__c***********'+SecListfmly.Relationdhip_with_Secondary_Customer__c);                 system.debug('**********Type_of_Relation__c***********'+SecListfmly.Type_of_Relation__c);                 String nextTabValue = 'ContactDetails';                   if(nextTabValue != null){                    currentTab = nextTabValue;                         Opportunity.Account__c= account.id;                      Opportunity.Secondary_Customer_Details__c=secondary.Id;                                                          }            }            catch(DmlException e){                 ApexPages.addMessages(e);                 LogsExceptionClass.insertLog(e.getMessage(),e.getLineNumber(),e.getTypeName(),String.valueOf(e.getcause()),e.getStackTraceString());            }        }        return null;     }

 
  • March 06, 2015
  • Like
  • 0
Hi,

I am trying to develop a trigger to Update the Aprent Record and Delete the curretn record. We have a contract custom object and Offer custom object where Offer is the parent and COntract id the child. My requirement is once the COntract is submitted for cancellation(I customised approval process to cancellation process) and then its cancellation is approved then the Offer(parent Object) Status(custom Field in Offer) must be updated to Cancelled and the child contract record must be deleted.

so far I have developed the following trigger:
trigger Updateoffer on pba__Closing__c (after update) {
  
  Set<String> offerids= new Set<String>();
  
    for (pba__Closing__c cl : Trigger.new) 
    {
      if(cl.Cancellation_Approved__c == true){
      offerids.add(cl.pba__Offer__c);
  }}
  
  
     List<pba__Offer__c> offers= [SELECT Id,pba__SystemIsCancelled__c  FROM pba__Offer__c WHERE Id =: offerids];
    
     Map<String, pba__Closing__c> cprmap = new Map<String, pba__Closing__c>();
  
    for (pba__Closing__c c : Trigger.new){
      
       
          cprmap.put(c.pba__Offer__c, c);
        }
      
     
        
    for (pba__Offer__c o : offers) {
      if (cprmap.containsKey(o.Id)) 
      {
      
       
        {
        o.pba__SystemIsCancelled__c  =  true;
        }
        
        
      }
  }
  update offers;
  delete [select id from pba__Closing__c where id in :Trigger.new];
}
This trigger is deleting the newly created Contracts, i belive it is because there is no if condition for the select statement at the bottom. Can anyone suggest corrections for this.
Thanks in advance.
 
  • March 06, 2015
  • Like
  • 0
Hi Experts, 

I've created a test class like here. 

@isTest
class TestdeleteOldProcessedUserChangeEntries {
    // CRON expression: midnight on March 15.
    // Because this is a test, job executes
    // immediately after Test.stopTest().
    public static String CRON_EXP = '00 32 17 05 3 ? 2015'; //'0 0 0 15 3 ? 2022';
    static testmethod void test() {
        Test.startTest();
//     Assuming that there are no userchange entries put into the table during testing.. get the table count to compare before and after
  Integer initcount1 = [SELECT COUNT() FROM user_change__c];
system.debug('initcount1' + initcount1);
        // Schedule the test job
        String jobId = System.schedule('deleteOldProcessedUserChangeEntries',
                                       CRON_EXP,
                                       new deleteOldProcessedUserChangeEntries());
        // Get the information from the CronTrigger API object
        CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered,
                          NextFireTime
                          FROM CronTrigger WHERE id = :jobId];
        // Verify the expressions are the same
        System.assertEquals(CRON_EXP,
                            ct.CronExpression);
        // Verify the job has not run
        System.assertEquals(0, ct.TimesTriggered);
        // Verify the next time the job will run
        System.assertEquals('2022-03-15 00:00:00',
                            String.valueOf(ct.NextFireTime));
        // Verify the scheduled job hasn't run yet.
  Integer initcount2 = [SELECT COUNT() FROM user_change__c];
        system.debug('initcount2' +initcount2);
         System.assertEquals(initcount1, initcount2);
        Test.stopTest();
        // Now that the scheduled job has executed after Test.stopTest(),
        // fetch the new merchandise that got added.
  Integer initcount3 = [SELECT COUNT() FROM user_change__c];
        system.debug('initcount3' + initcount3);  
         System.assertEquals(initcount2-initcount3, 1);
    }
}

Select Count is not returning me any count...? any ideas. ?

Please advise. 
 
We are currently unable to deploy any change sets because our current code coverage is at 72%.  I have tested deploying just a single field on an almost untouched object and get the 72%. I'm wondering how can production get below 75% if all classes and test classes have to be deployed and they won't be deployed if it causes code coverage to go below 75%.  Is it possible that Flows or Process Builder, which can just be created in production, count towards code coverage? 
I have this bit of code:
public AccountSummary__c Summary{ 
        get{
            if(AccountId == null){
                return new AccountSummary__c();
            }
            
            AccountTrigger.ProcessAccountSummary(AccountId); //Processes and upserts the record
            //SELECT the record that was processed and upserted above
            return Database.query('SELECT ' + SelectStar + ' FROM AccountSummary__c WHERE AccountId__c = :AccountId');
        }
    }
The page that uses this Summary record looks something like this:
<apex:pageBlock >
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem ><apex:outputLabel value="Tests {!MonthNames[15]}"/><apex:outputText value="{!Summary.T15MA__c}"/></apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem ><apex:outputLabel value="Patients {!MonthNames[15]}"/><apex:outputText value="{!Summary.P15MA__c}"/></apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem ><apex:outputLabel value="Tests {!MonthNames[14]}"/><apex:outputText value="{!Summary.T14MA__c}"/></apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem ><apex:outputLabel value="Patients {!MonthNames[14]}"/><apex:outputText value="{!Summary.P14MA__c}"/></apex:pageBlockSectionItem>
...

When I open the page, all fields are correctly calculated and viewed. I view the debug logs and it shows 1 DML statement/row and shows the upsert with no errors. The fact that it does the upsert and then does a SELECT from the database for the record would lead me to believe the record was updated in the database.

However, this is not the case! When I view the record directly or via a report, the fields are not updated; they remain at their previous values.

If I run the AccountTrigger.ProcessAccountSummary(AccountId); via Execute Anonymous, the record gets updated correctly and shows in reports/view correctly.

Has anyone else experienced this? Does it have something to do with 'when' this code is called, in that it is called in a 'get' of a property for a VF page? How can that 'get' SELECT from the database the correct values when the database does not appear to get updated with correct values?
  • February 20, 2015
  • Like
  • 0
Since the sandbox update to Spring '15, our sandbox has been unable to save in the Developer Console. We can open items (classes, pages, etc) but when we try to save them, we get "Failed to create createContainerMember for containerId=undefined: null is not a valid containerId" errors and they do not save.

We have tried the resolution found in this solution: https://help.salesforce.com/apex/HTViewSolution?id=000204953&language=en_US
but creating a new Workspace does not work (as in the Workspace is not created) and it does not fix the save issue. 
We have also tried switching workspaces, which also does not work.

We have cleared cache and tried on multiple computers from multiple networks.
  • January 23, 2015
  • Like
  • 0
We have a couple of people that work on the weekends and the particular VisualForce pages they access continuously time out for them, especially during the first load.  The people working during the week do not have this issue working on the same pages.  Is there any way we can find out what is causing this to happen only on weekends?  Regular SalesForce pages open and load just fine during the time, but when they try to go into our custom pages, it times out.
  • October 13, 2014
  • Like
  • 0
Case Description: Frequent Salesforce API login issues in production and sandbox environments.

Inner Exception: SERVER_UNAVAILABLE: server temporarily unavailable

The wsdl is SFDC_Enterprise.wsdl

This has been reported twice via 2 another cases. Case 10239485 (This case was not roted to the appropriate party as I think the person helping on this case did not understand the real issue). Case 10291756 (This case ended up being not at all helpful. The person never responded.).

I need this case escalated to a high priority as this is happening intermittently in our production box.