• An_ja
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 9
    Replies

this is where I cannot get coverage

private boolean updateSystems()
    {
        boolean result=true;
        if (null!=systems)
           {
           //from here           
List<System__c> updSys=new List<System__c>(); try { update systems; } catch (Exception e) { String msg=e.getMessage(); integer pos; // if its field validation, this will be added to the messages by default if (-1==(pos=msg.indexOf('FIELD_CUSTOM_VALIDATION_EXCEPTION, '))) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, msg)); } result=false; } } return result; }

 

  • July 04, 2013
  • Like
  • 0
public class saveAndThanks 
{
                
        
      public Sponsorship_Request__c SpR{get;set;}
      private ApexPages.StandardController controller;
      public Blob upload {get; set;}
      public String contentType {get; set;}
      public String fileName {get; set;}
      public saveAndThanks(ApexPages.StandardController controller) 
        
        {
                //this.controller = controller;
                SpR = new Sponsorship_Request__c();
                this.SPR=(Sponsorship_Request__c)controller.getRecord();
                
        }
        
        
      public PageReference saveAndThanks2() 
        {        
                //OwnerId = '00GE0000000hCBH',
                SpR.RecordTypeId = '01250000000DvDq';
                SpR.Account__c = '0015000000ch107';
                
           try
           {
                insert SpR;
                system.debug('######'+SpR);
           }
        
           catch(DmlException ex)
           {
                ApexPages.addMessages(ex);
           }
        
           if(upload!=null)
           {
                Attachment attach=new Attachment();
                attach.Body=upload;
                attach.Name=filename;
                attach.ContentType=contentType;
                attach.ParentID=SPR.id;
    
             insert(attach);
              
       
          }
       
        PageReference thanksPage = new PageReference('/apex/saveAndThanks');
        thanksPage.setRedirect(true);
        return thanksPage;
      }
        
        
      public void saveAndThanks()
        {
        
        }
        
      public PageReference cancel()
        {
           PageReference refreshPage = new PageReference('/apex/Cancelled');
           refreshPage.setRedirect(true);
           return refreshPage;
        }
        
        
    static testMethod void testsaveAndThanks() 
    {

       
        Sponsorship_Request__c SpR = new Sponsorship_Request__c();
        
                
        SpR.Organization__c = 'Test Job';
        SpR.Account__c = '0015000000ch107';
        SpR.Contact_Name__c = 'test spr name';
        SpR.Event_Project_Name__c = 'test event';
        SpR.Request_Amount__c = 5;
        SpR.Potential_Referral_Source__c = 'No';
        SpR.Options__c = 'test project name';
        insert SpR;
        
        saveAndThanks controller = new saveAndThanks(new ApexPages.StandardController(SpR));
        
        
        Attachment attach= new Attachment();   
        attach.Name = 'Contact Picture';
        Blob bodyBlob = Blob.valueOf('upload');
        attach.body = bodyBlob;
        attach.ParentId = SpR.id;  
        
        insert attach;
               
        
        controller.saveAndThanks2();
        
        
        System.debug('the current page is...' +ApexPages.currentPage() );

        System.assertEquals('test spr name', SpR.Contact_Name__c);
        
        System.assertEquals('Contact Picture', attach.Name);
        
        List<Attachment> attachments=[select id, name from Attachment where parent.id=:SpR.id];
        
        System.assertEquals(1, attachments.size());

        }
}

 

  • June 08, 2013
  • Like
  • 0

Here is the code:

 

trigger ContactSumTrigger on Contact (after insert, after update) 

{
  User blocked = new User();
    try
    {
      blocked = [Select Id From User Where User.Id = '00550000001qLmn'];
    }
    
    catch(Exception e)
    {
}
  
  Map<Id,Account> updateAccounts = new Map<Id,Account>();
  Set<Id> updateAccountIds = new Set<Id>();
  
  // If we are inserting, updating, or undeleting, use the new ID values
  if(Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete&& blocked.Id!=null && Trigger.new[0].LastModifiedById != blocked.Id)
    for(Contact contact:Trigger.new)
      updateAccountIds.add(contact.AccountId);
  
  // If we are updating, some contacts might change, so include that as well as deletes
  if(Trigger.isUpdate || Trigger.isDelete && blocked.Id!=null && Trigger.old[0].LastModifiedById != blocked.Id )
    for(Contact contact:Trigger.old)
      updateAccountIds.add(contact.AccountId);
  
  // Do not create a record for null field
  updateAccountIds.remove(null);
  
  // Create in-memory copies for all accounts that will be affected
  if(blocked.Id!=null && Trigger.new[0].LastModifiedById != blocked.Id)
  for(Id accountId:updateAccountIds)
    updateAccounts.put(accountId,new Account(id=accountId,Number_of_Physicians__c=0));
    
  
  // Run an optimized query that looks for all contacts that meet the if/then criteria
  if(blocked.Id!=null && Trigger.new[0].LastModifiedById != blocked.Id)
  for(Contact contact:[select id, AccountId from contact where AccountId in :updateAccountIds and RecordTypeID = '01250000000DXGT'Limit 100])
    updateAccounts.get(contact.AccountId).Number_of_Physicians__c++;
  
  

    
  try
   {
    // Update all the accounts with new values.
    Database.update(updateAccounts.values());
   }
  
  catch(Exception e)
    {
    System.debug(e);
    trigger.new[0].addError('There was an error on a record related to this contact: Please contact to your system administrator by sending an email to support');
       
    }


}

 

  • March 06, 2013
  • Like
  • 0

We are looking for a Salesforce.com administrator to join our team in either Orange County, CA or Calverton, MD to provide customer service and customized solutions to our Salesforce.com users.

 

Key Responsibilities

  • Training and on-boarding of new users
  • Interacting with SF users to identify needs and implement solutions
  • Customization of database that includes: field creation, validation rules, workflows, custom objects
  • User management: Creation and customization of roles, profiles, layouts, access and sharing rules
  • Analytics creation and maintenance of reports, dashboards and notifications

 

 

Required experience:

  • Salesforce.com Admin certification and/or 1-3 yrs equivalent experience
  • Customer service
  • Project management and implementation of Salesforce.com solutions
  • Supporting custom Salesforce.com applications
  • Usage of Data Loader

 

 

Required skills

  • Excellent Communication
  • Teamwork
  • Multitasking
  • Flexibility to meet continuously changing priorities and challenges
  • Excellent interpersonal skills
  • Ability to drive things to completion
  • Detail oriented
  • Strong analytic skills / advanced Excel / Access

 

Desired Experience (Nice to have)

  • Data migration with different platforms, Oracle, Sequel etc
  • Experience with complex implementations, multiple user groups in 1 org, multiple orgs
  • Experience with implementing SalesCloud, ServiceCloud, Data.com
  • Salesforce Integration with other third party solutions
  • Apex/Triggers/Visualforce
  • Sites
  • Java/HTML
  • Crystal Reports

 This position is full-time employment  (no contract or 1099)

 

  • January 24, 2013
  • Like
  • 0

I am looking for a way to add conditional filtering to the "ctx.add( " portions below.

 

trigger OppRollup on Opportunity (after insert, after update, 
                                        after delete, after undelete) {
      // modified objects whose parent records should be updated
     Opportunity[] objects = null;   

     if (Trigger.isDelete) {
         objects = Trigger.old;
     } else {
        /*
            Handle any filtering required, specially on Trigger.isUpdate event. If the rolled up fields
            are not changed, then please make sure you skip the rollup operation.
            We are not adding that for sake of similicity of this illustration.
        */ 
        objects = Trigger.new;
     }

     /*
      First step is to create a context for LREngine, by specifying parent and child objects and
      lookup relationship field name
     */
     LREngine.Context ctx = new LREngine.Context(Account.SobjectType, // parent object
                                            Opportunity.SobjectType,  // child object
                                            Schema.SObjectType.Opportunity.fields.AccountId // relationship field name
                                            );     
     /*
      Next, one can add multiple rollup fields on the above relationship. 
      Here specify 
       1. The field to aggregate in child object
       2. The field to which aggregated value will be saved in master/parent object
       3. The aggregate operation to be done i.e. SUM, AVG, COUNT, MIN/MAX
     */
     ctx.add(
            new LREngine.RollupSummaryField(
                                            Schema.SObjectType.Account.fields.AnnualRevenue,
                                            Schema.SObjectType.Opportunity.fields.Amount,
                                            LREngine.RollupOperation.Sum 
                                         )); 
     ctx.add(
            new LREngine.RollupSummaryField(
                                            Schema.SObjectType.Account.fields.SLAExpirationDate__c,
                                               Schema.SObjectType.Opportunity.fields.CloseDate,
                                               LREngine.RollupOperation.Max
                                         ));                                       

     /* 
      Calling rollup method returns in memory master objects with aggregated values in them. 
      Please note these master records are not persisted back, so that client gets a chance 
      to post process them after rollup
      */ 
     Sobject[] masters = LREngine.rollUp(ctx, objects);    

     // Persiste the changes in master
     update masters;
}

 

  • January 01, 2013
  • Like
  • 0
trigger calculateDMDTrigger on Contact (after delete, after insert, after undelete, after update) 
{

    Contact[] cons;
    if (Trigger.isDelete) 
        cons = Trigger.old;
    else
        cons = Trigger.new;

    // get list of accounts
    Set<ID> acctIds = new Set<ID>();
    for (Contact con : cons) 
    {
            acctIds.add(con.AccountId);
    }
    
    Map<ID, Contact> contactsForAccounts = new Map<ID, Contact>([select Id,
                                              	AccountId
                                              	from Contact
                                              	where AccountId IN :acctIds and Sub_Type__c 
                                              	IN ('DMD', 
                                              	'DCD')]); //

    Map<ID, Account> acctsToUpdate = new Map<ID, Account>([select Id,
                                                Active_DVA_DCD__c 
                                                from Account
                                                where Id IN :acctIds]);
                                                                 
    for (Account acct : acctsToUpdate.values()) 
    {
        Set<ID> conIds = new Set<ID>();
        for (Contact con : contactsForAccounts.values()) 
        {
            if (con.AccountId == acct.Id)
                conIds.add(con.Id);
        }
        if (acct.Active_DVA_DCD__c != conIds.size())
            acct.Active_DVA_DCD__c = conIds.size();
    }

    update acctsToUpdate.values();

}

 

 

 

  • July 31, 2012
  • Like
  • 0

 value (picklist) & div are fields on record

 

                    value1      value2      TOTAL

division1   #records    #records    #records

division2   #records    #records    #records

division3   #records    #records    #records

division4   #records    #records    #records

division5   #records    #records    #records

TOTAL       #records    #records    #records

  • July 12, 2012
  • Like
  • 0

public with sharing class DashboardSnippetController
{
public DashBoardSnippetController()
{}

public string getDashboardHtml()
{
PageReference dbPage = new PageReference('https://cs4.salesforce.com/01ZP00000008goB');
Blob pageBlob = dbPage.getContent();
return pageBlob.toString();
}



@isTest


static void testDashboardSnippetController()
{
PageReference pageRef = Page.HomeDS;
Test.setCurrentPage(pageRef);

DashboardSnippetController controller = new DashboardSnippetController();
String nextPage = controller.getDashboardHtml();

// Verify that page fails without parameters

System.assertEquals('/apex/failure?error=noParam', nextPage);

// Add parameters to page URL

ApexPages.currentPage().getParameters().put('pageBlob', '');

// Instantiate a new controller with all parameters in the page

controller = new DashboardSnippetController();
nextPage = controller.getDashboardHtml();

// Verify that the success page displays

System.assertEquals('/apex/HomeDS', nextPage);


}

}

  • May 28, 2012
  • Like
  • 0

this does not display in my sites page

 

<apex:inputTextarea id="Details" value="{!SpR.Details__c}" richText="true" />

  • April 13, 2012
  • Like
  • 0

public class saveAndThanks
{
String Account = ApexPages.currentPage().getParameters().get('Unknown Account CSR');
Sponsorship_Request__c SR;
private ApexPages.StandardController controller;
public saveAndThanks(ApexPages.StandardController controller)

{
this.controller = controller;
}


public PageReference saveAndThanks()
{
Sponsorship_Request__c SpR = new Sponsorship_Request__c
(

//OwnerId = '00GE0000000hCBH',
RecordTypeId = '01250000000DvDq',
Account__c = '0015000000ch107'

);

try
{
insert SpR;
}

catch(DmlException ex)
{
ApexPages.addMessages(ex);
}

PageReference thanksPage = new PageReference('http://www.sample.com/index.html');
thanksPage.setRedirect(true);
return thanksPage;
}



static testMethod void testsaveAndThanks() {

//Use the PageReference Apex class to instantiate a page

PageReference pageRef = Page.SampleSponsorship;

//In this case, the Visualforce page named 'SampleSponsorship' is the starting point of this test method.

Test.setCurrentPage(pageRef);

//set the field values of job details
//values entered in VF page can be set here
Sponsorship_Request__c SR = new Sponsorship_Request__c(
Account__c = '0015000000ch107',
Organization__c = 'Test Job',
Contact_Name__c = 'test name',
Options__c = 'test project name');

//Instantiate and construct the controller class.


ApexPages.StandardController thecontroller = new ApexPages.StandardController(SR);

saveAndThanks controller = new saveAndThanks(thecontroller);
//The .getURL will return the page url the Save() method returns.

String nextPage = controller.saveAndThanks().getUrl();

//Check that the save() method returns the proper URL.

System.assertEquals('http://www.sample.com/index.html', nextPage);

 

 

}
}

  • April 05, 2012
  • Like
  • 0
public class saveAndThanks 
{
                
        
      public Sponsorship_Request__c SpR{get;set;}
      private ApexPages.StandardController controller;
      public Blob upload {get; set;}
      public String contentType {get; set;}
      public String fileName {get; set;}
      public saveAndThanks(ApexPages.StandardController controller) 
        
        {
                //this.controller = controller;
                SpR = new Sponsorship_Request__c();
                this.SPR=(Sponsorship_Request__c)controller.getRecord();
                
        }
        
        
      public PageReference saveAndThanks2() 
        {        
                //OwnerId = '00GE0000000hCBH',
                SpR.RecordTypeId = '01250000000DvDq';
                SpR.Account__c = '0015000000ch107';
                
           try
           {
                insert SpR;
                system.debug('######'+SpR);
           }
        
           catch(DmlException ex)
           {
                ApexPages.addMessages(ex);
           }
        
           if(upload!=null)
           {
                Attachment attach=new Attachment();
                attach.Body=upload;
                attach.Name=filename;
                attach.ContentType=contentType;
                attach.ParentID=SPR.id;
    
             insert(attach);
              
       
          }
       
        PageReference thanksPage = new PageReference('/apex/saveAndThanks');
        thanksPage.setRedirect(true);
        return thanksPage;
      }
        
        
      public void saveAndThanks()
        {
        
        }
        
      public PageReference cancel()
        {
           PageReference refreshPage = new PageReference('/apex/Cancelled');
           refreshPage.setRedirect(true);
           return refreshPage;
        }
        
        
    static testMethod void testsaveAndThanks() 
    {

       
        Sponsorship_Request__c SpR = new Sponsorship_Request__c();
        
                
        SpR.Organization__c = 'Test Job';
        SpR.Account__c = '0015000000ch107';
        SpR.Contact_Name__c = 'test spr name';
        SpR.Event_Project_Name__c = 'test event';
        SpR.Request_Amount__c = 5;
        SpR.Potential_Referral_Source__c = 'No';
        SpR.Options__c = 'test project name';
        insert SpR;
        
        saveAndThanks controller = new saveAndThanks(new ApexPages.StandardController(SpR));
        
        
        Attachment attach= new Attachment();   
        attach.Name = 'Contact Picture';
        Blob bodyBlob = Blob.valueOf('upload');
        attach.body = bodyBlob;
        attach.ParentId = SpR.id;  
        
        insert attach;
               
        
        controller.saveAndThanks2();
        
        
        System.debug('the current page is...' +ApexPages.currentPage() );

        System.assertEquals('test spr name', SpR.Contact_Name__c);
        
        System.assertEquals('Contact Picture', attach.Name);
        
        List<Attachment> attachments=[select id, name from Attachment where parent.id=:SpR.id];
        
        System.assertEquals(1, attachments.size());

        }
}

 

  • June 08, 2013
  • Like
  • 0

We are looking for a Salesforce.com administrator to join our team in either Orange County, CA or Calverton, MD to provide customer service and customized solutions to our Salesforce.com users.

 

Key Responsibilities

  • Training and on-boarding of new users
  • Interacting with SF users to identify needs and implement solutions
  • Customization of database that includes: field creation, validation rules, workflows, custom objects
  • User management: Creation and customization of roles, profiles, layouts, access and sharing rules
  • Analytics creation and maintenance of reports, dashboards and notifications

 

 

Required experience:

  • Salesforce.com Admin certification and/or 1-3 yrs equivalent experience
  • Customer service
  • Project management and implementation of Salesforce.com solutions
  • Supporting custom Salesforce.com applications
  • Usage of Data Loader

 

 

Required skills

  • Excellent Communication
  • Teamwork
  • Multitasking
  • Flexibility to meet continuously changing priorities and challenges
  • Excellent interpersonal skills
  • Ability to drive things to completion
  • Detail oriented
  • Strong analytic skills / advanced Excel / Access

 

Desired Experience (Nice to have)

  • Data migration with different platforms, Oracle, Sequel etc
  • Experience with complex implementations, multiple user groups in 1 org, multiple orgs
  • Experience with implementing SalesCloud, ServiceCloud, Data.com
  • Salesforce Integration with other third party solutions
  • Apex/Triggers/Visualforce
  • Sites
  • Java/HTML
  • Crystal Reports

 This position is full-time employment  (no contract or 1099)

 

  • January 24, 2013
  • Like
  • 0

I am looking for a way to add conditional filtering to the "ctx.add( " portions below.

 

trigger OppRollup on Opportunity (after insert, after update, 
                                        after delete, after undelete) {
      // modified objects whose parent records should be updated
     Opportunity[] objects = null;   

     if (Trigger.isDelete) {
         objects = Trigger.old;
     } else {
        /*
            Handle any filtering required, specially on Trigger.isUpdate event. If the rolled up fields
            are not changed, then please make sure you skip the rollup operation.
            We are not adding that for sake of similicity of this illustration.
        */ 
        objects = Trigger.new;
     }

     /*
      First step is to create a context for LREngine, by specifying parent and child objects and
      lookup relationship field name
     */
     LREngine.Context ctx = new LREngine.Context(Account.SobjectType, // parent object
                                            Opportunity.SobjectType,  // child object
                                            Schema.SObjectType.Opportunity.fields.AccountId // relationship field name
                                            );     
     /*
      Next, one can add multiple rollup fields on the above relationship. 
      Here specify 
       1. The field to aggregate in child object
       2. The field to which aggregated value will be saved in master/parent object
       3. The aggregate operation to be done i.e. SUM, AVG, COUNT, MIN/MAX
     */
     ctx.add(
            new LREngine.RollupSummaryField(
                                            Schema.SObjectType.Account.fields.AnnualRevenue,
                                            Schema.SObjectType.Opportunity.fields.Amount,
                                            LREngine.RollupOperation.Sum 
                                         )); 
     ctx.add(
            new LREngine.RollupSummaryField(
                                            Schema.SObjectType.Account.fields.SLAExpirationDate__c,
                                               Schema.SObjectType.Opportunity.fields.CloseDate,
                                               LREngine.RollupOperation.Max
                                         ));                                       

     /* 
      Calling rollup method returns in memory master objects with aggregated values in them. 
      Please note these master records are not persisted back, so that client gets a chance 
      to post process them after rollup
      */ 
     Sobject[] masters = LREngine.rollUp(ctx, objects);    

     // Persiste the changes in master
     update masters;
}

 

  • January 01, 2013
  • Like
  • 0

public with sharing class DashboardSnippetController
{
public DashBoardSnippetController()
{}

public string getDashboardHtml()
{
PageReference dbPage = new PageReference('https://cs4.salesforce.com/01ZP00000008goB');
Blob pageBlob = dbPage.getContent();
return pageBlob.toString();
}



@isTest


static void testDashboardSnippetController()
{
PageReference pageRef = Page.HomeDS;
Test.setCurrentPage(pageRef);

DashboardSnippetController controller = new DashboardSnippetController();
String nextPage = controller.getDashboardHtml();

// Verify that page fails without parameters

System.assertEquals('/apex/failure?error=noParam', nextPage);

// Add parameters to page URL

ApexPages.currentPage().getParameters().put('pageBlob', '');

// Instantiate a new controller with all parameters in the page

controller = new DashboardSnippetController();
nextPage = controller.getDashboardHtml();

// Verify that the success page displays

System.assertEquals('/apex/HomeDS', nextPage);


}

}

  • May 28, 2012
  • Like
  • 0

this does not display in my sites page

 

<apex:inputTextarea id="Details" value="{!SpR.Details__c}" richText="true" />

  • April 13, 2012
  • Like
  • 0