• Adam Marks
  • NEWBIE
  • 10 Points
  • Member since 2014
  • Salesforce Admin/Business Analyst
  • RTS Labs

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Hey all. Trying to write a test method that extends a zuora class. Basically trying to put default values into a VF page when it renders. I am at a loss on how to test for this. I am sure it's simple but so far it has eluded me. Here is the extension code:
 
global class DefaultValues extends zqu.CreateQuoteController.PopulateDefaultFieldValuePlugin{ 
   global override void populateDefaultFieldValue
      (SObject record, zqu.PropertyComponentController.ParentController pcc)
   {   
      super.populateDefaultFieldValue(record, pcc);   
      record.put('zqu__InitialTerm__c', 12);   
      record.put('zqu__RenewalTerm__c', 12); 
     /* String lPCP =  (String)record.get('Acct_PCP__c');
      if (lPCP=='Shah'){
      record.put('Physician__c','Is'); 
      }
      else
      {
         record.put('Physician__c','Not');       
      }*/
   }
}

Any help and guidance would be appreciated.
 
So I figured this would be pretty simple but so far the answer has eluded me. Basically I created a VF page for a very specific Task type that is a Question/Answer format. This page will only ever be launched from a Lead through a custom button but I cannot for the life of me determine how to populate the WhoId automatically. I found this solution (https://developer.salesforce.com/forums?id=906F0000000960aIAA) but I think it's missing something because it did not work for me. Hopefully it's a relatively easy solution, seems like it would be.
This is my VF code (don't laugh)
<apex:page StandardController="Task" extensions="LeadQuestionnaireController">
    <apex:form >
        <apex:pageBlock title="Lead Questionnaire" mode="edit">
            <apex:pageblockbuttons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
                </apex:pageblockbuttons>
                <apex:pageblocksection >
                <apex:inputfield value="{!Task.WhoId}"/>
                </apex:pageblocksection>
                
                <apex:pageBlockSection title="Please answer questions below" Columns="2">
                    
                    <apex:outputText value="1. Do you make the final decision when it comes to selecting a carrier for your upcoming shipment to XYZ event?">
                    </apex:outputText>
                    <apex:inputField label=" " value="{!Task.A1__c}"/>
                    <apex:outputText value="2. Do you typically ship more than 300 lbs to this event?  Or will be planning to ship this amount in the event this is their first time to the show.">
                    </apex:outputText>
                    <apex:inputField label=" " value="{!Task.A2__c}"/>
                    <apex:outputText value="3. How do you decide or what criteria do you use to choose a shipping service to handle your show shipments?">
                    </apex:outputText>
                    <apex:inputField label=" " value="{!Task.A3__c}" style="width: 300px; height: 40px;"/>
                    <apex:outputText value="4. Would you have any interest in considering our service for this upcoming event?">
                    </apex:outputText>
                    <apex:inputField label=" " value="{!Task.A4__c}"/>
                    <apex:outputText value="5. How many shows over a year do you typically ship to?">
                    </apex:outputText>
                    <apex:inputField label=" " value="{!Task.A5__c}"/>
            <apex:outputText value="6. If not interested at this time, when do you typically evaluate your carriers?">
            </apex:outputText>
            <apex:inputField label=" " value="{!Task.A6__c}" style="width: 300px; height: 40px;"/>
            </apex:pageblocksection>
            
            <apex:pageBlockSection title="Comments" Columns="1">
                <apex:inputtextarea label=" " value="{!Task.Description}" style="width: 500px; height: 150px;"/>
                
            </apex:pageblocksection>
          </apex:pageBlock>
        </apex:form>
</apex:page>

This is the Extension, which I know is wrong.
public with sharing class LeadQuestionnaireController{
Task task = new Task();
    
    public LeadQuestionnaireController(ApexPages.StandardController controller) {
      this.task = (Task)controller.getRecord();
      string strWhatId = ApexPages.currentPage().getParameters().get('oppIdd');
      string strOwnerId = ApexPages.currentPage().getParameters().get('ownerId');
      Task.WhatId = strWhatId ;
      Task.OwnerId = strOwnerId ;
        
    }

}
Thanks in advance.
Have another Trigger that is erroring out. Again, this is above my area of expertise. I can't see anything jumping out at me that would cause this to error , but I amm sure it's something simple. Also am I correct that this Trigger is simply updating the License lookup field on existing cases?

Trigger updateCasesByAccount on License__c (before update, before insert) {

  // To be SF Limit compliant we limit our sql calls by keeping as much as possible outside the loop
  Set< Id > licenseAccountIds = new Set< Id >();
  
  // Add each licenses related account id to the licenseAccountIds set
  // Also add each license to the licenses list
  Integer countC = 0;
  for (License__c lic:Trigger.new) {
    licenseAccountIds.add(lic.Account__c);
    countC  ++;
  }
  // Debug
  //trigger.new[0].Ship_Address1__c = 'Trigger found: ' + countC;
  
  // Get all cases related to the licenses based on account it
  List<Case> cases = [SELECT id, accountId, FPB_License__c, CaseNumber FROM Case WHERE accountId in: licenseAccountIds]; 
  
  // Create map of account id (key) to license id (value)
  Integer countM = 0;
  Map<Id,Id> oppmap = new Map<Id,Id>();
 for (License__c lic:Trigger.new) {
    oppmap.put(lic.Account__c, lic.Id);
    countM ++;
  }
  // Debug
  //trigger.new[0].Ship_City__c = 'Mapped: ' + countM;
  
  // Loop through csses and match to licenses using account id
  Integer countCA = 0;
  for (Case cas:cases) {
      // Use map ( basically hash table) to avoid more loops
        cas.FPB_License__c = oppmap.get(cas.accountId);
        
        countCA ++;
  }
  update cases;
  // Debug
  //trigger.new[0].Ship_City__c = 'Related Cases: ' + countCA;

}

Need some help with a Trigger Error. I am not a developer so my skills get stretched with things like this. Also, for whatever it's worth I did not write the Trigger but am in a position to support it. The user is getting the following error when they try and merge records: "AccountTrigger: execution of AfterDelete caused by: System.NullPointerException: Attempt to de-reference a null object: External entry point"."

See below Trigger syntax:
trigger AccountTrigger on Account (before insert, after insert, after update, after delete) {
    String PROSPECT_RT_ID = dao_Account.getInstance().getRecordTypeId('Prospect');
    User defaultOwner = dao_User.getInstance().getUserByName('Medical-Surgical IT Data');
    List<AccountTeamMember> atmInserts = new List<AccountTeamMember>();
    List<AccountShare> ashInserts = new List<AccountShare>();
    String LTC_REP = 'EC Long Term Care Rep';
    String HC_REP = 'EC Home Care DME Rep';     

    Map<Id, Searchable_Account__c> saMap = new Map<Id, Searchable_Account__c>();    
    for (Searchable_Account__c sa : [Select Id, Account__c, Account_Name_ExtId__c from Searchable_Account__c where Account__c in :trigger.new]){
        saMap.put(sa.Account__c, sa);
    }
    for (Account a : Trigger.new)
    {
        if (a.RecordTypeId == PROSPECT_RT_ID)
        {
            if (trigger.isBefore)
            {
                a.OwnerId = defaultOwner.Id;
            } else if (!trigger.isDelete){              
                User originalOwner = dao_User.getInstance().getUser(a.CreatedById);
                AccountTeamMember atm = new AccountTeamMember();
                AccountShare ash = new AccountShare();
                atm.AccountId = a.Id;
                atm.UserId = originalOwner.Id;
                if ( originalOwner.Profile.Name.contains('HomeCare') || (originalOwner.UserRoleId != null && originalOwner.UserRole.Name.startsWith('HC'))  )
                {
                    atm.TeamMemberRole = HC_REP;
                } else if ( originalOwner.Profile.Name.contains('LongTermCare')  || (originalOwner.UserRoleId != null && originalOwner.UserRole.Name.startsWith('LTC')) ) {
                    atm.TeamMemberRole = LTC_REP;
                }
                atmInserts.add(atm);
                
                ash.AccountAccessLevel = 'Edit';
                ash.AccountId = a.Id;
                ash.OpportunityAccessLevel = 'None';
                ash.UserOrGroupId = originalOwner.Id;
                ashInserts.add(ash);
                
            }
        } else if (trigger.isAfter) {           
            Searchable_Account__c sa = saMap.get(a.id);
            if (sa== null) sa = new Searchable_Account__c();
            sa.Account__c = a.Id;
            sa.Account_Name_ExtId__c = a.Name + ' | ' + a.AccountNumber;
            saMap.put(a.Id,sa);
        }                   
    }
    insert atmInserts;
    insert ashInserts;
    upsert saMap.values();
}
I understand what is happening, and to an extent why but I am at a loss as to how to fix it. Thanks in advance for any guidance.
Need some help with a Trigger Error. I am not a developer so my skills get stretched with things like this. Also, for whatever it's worth I did not write the Trigger but am in a position to support it. The user is getting the following error when they try and merge records: "AccountTrigger: execution of AfterDelete caused by: System.NullPointerException: Attempt to de-reference a null object: External entry point"."

See below Trigger syntax:
trigger AccountTrigger on Account (before insert, after insert, after update, after delete) {
    String PROSPECT_RT_ID = dao_Account.getInstance().getRecordTypeId('Prospect');
    User defaultOwner = dao_User.getInstance().getUserByName('Medical-Surgical IT Data');
    List<AccountTeamMember> atmInserts = new List<AccountTeamMember>();
    List<AccountShare> ashInserts = new List<AccountShare>();
    String LTC_REP = 'EC Long Term Care Rep';
    String HC_REP = 'EC Home Care DME Rep';     

    Map<Id, Searchable_Account__c> saMap = new Map<Id, Searchable_Account__c>();    
    for (Searchable_Account__c sa : [Select Id, Account__c, Account_Name_ExtId__c from Searchable_Account__c where Account__c in :trigger.new]){
        saMap.put(sa.Account__c, sa);
    }
    for (Account a : Trigger.new)
    {
        if (a.RecordTypeId == PROSPECT_RT_ID)
        {
            if (trigger.isBefore)
            {
                a.OwnerId = defaultOwner.Id;
            } else if (!trigger.isDelete){              
                User originalOwner = dao_User.getInstance().getUser(a.CreatedById);
                AccountTeamMember atm = new AccountTeamMember();
                AccountShare ash = new AccountShare();
                atm.AccountId = a.Id;
                atm.UserId = originalOwner.Id;
                if ( originalOwner.Profile.Name.contains('HomeCare') || (originalOwner.UserRoleId != null && originalOwner.UserRole.Name.startsWith('HC'))  )
                {
                    atm.TeamMemberRole = HC_REP;
                } else if ( originalOwner.Profile.Name.contains('LongTermCare')  || (originalOwner.UserRoleId != null && originalOwner.UserRole.Name.startsWith('LTC')) ) {
                    atm.TeamMemberRole = LTC_REP;
                }
                atmInserts.add(atm);
                
                ash.AccountAccessLevel = 'Edit';
                ash.AccountId = a.Id;
                ash.OpportunityAccessLevel = 'None';
                ash.UserOrGroupId = originalOwner.Id;
                ashInserts.add(ash);
                
            }
        } else if (trigger.isAfter) {           
            Searchable_Account__c sa = saMap.get(a.id);
            if (sa== null) sa = new Searchable_Account__c();
            sa.Account__c = a.Id;
            sa.Account_Name_ExtId__c = a.Name + ' | ' + a.AccountNumber;
            saMap.put(a.Id,sa);
        }                   
    }
    insert atmInserts;
    insert ashInserts;
    upsert saMap.values();
}
I understand what is happening, and to an extent why but I am at a loss as to how to fix it. Thanks in advance for any guidance.
Hey all. Trying to write a test method that extends a zuora class. Basically trying to put default values into a VF page when it renders. I am at a loss on how to test for this. I am sure it's simple but so far it has eluded me. Here is the extension code:
 
global class DefaultValues extends zqu.CreateQuoteController.PopulateDefaultFieldValuePlugin{ 
   global override void populateDefaultFieldValue
      (SObject record, zqu.PropertyComponentController.ParentController pcc)
   {   
      super.populateDefaultFieldValue(record, pcc);   
      record.put('zqu__InitialTerm__c', 12);   
      record.put('zqu__RenewalTerm__c', 12); 
     /* String lPCP =  (String)record.get('Acct_PCP__c');
      if (lPCP=='Shah'){
      record.put('Physician__c','Is'); 
      }
      else
      {
         record.put('Physician__c','Not');       
      }*/
   }
}

Any help and guidance would be appreciated.
 
So I figured this would be pretty simple but so far the answer has eluded me. Basically I created a VF page for a very specific Task type that is a Question/Answer format. This page will only ever be launched from a Lead through a custom button but I cannot for the life of me determine how to populate the WhoId automatically. I found this solution (https://developer.salesforce.com/forums?id=906F0000000960aIAA) but I think it's missing something because it did not work for me. Hopefully it's a relatively easy solution, seems like it would be.
This is my VF code (don't laugh)
<apex:page StandardController="Task" extensions="LeadQuestionnaireController">
    <apex:form >
        <apex:pageBlock title="Lead Questionnaire" mode="edit">
            <apex:pageblockbuttons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
                </apex:pageblockbuttons>
                <apex:pageblocksection >
                <apex:inputfield value="{!Task.WhoId}"/>
                </apex:pageblocksection>
                
                <apex:pageBlockSection title="Please answer questions below" Columns="2">
                    
                    <apex:outputText value="1. Do you make the final decision when it comes to selecting a carrier for your upcoming shipment to XYZ event?">
                    </apex:outputText>
                    <apex:inputField label=" " value="{!Task.A1__c}"/>
                    <apex:outputText value="2. Do you typically ship more than 300 lbs to this event?  Or will be planning to ship this amount in the event this is their first time to the show.">
                    </apex:outputText>
                    <apex:inputField label=" " value="{!Task.A2__c}"/>
                    <apex:outputText value="3. How do you decide or what criteria do you use to choose a shipping service to handle your show shipments?">
                    </apex:outputText>
                    <apex:inputField label=" " value="{!Task.A3__c}" style="width: 300px; height: 40px;"/>
                    <apex:outputText value="4. Would you have any interest in considering our service for this upcoming event?">
                    </apex:outputText>
                    <apex:inputField label=" " value="{!Task.A4__c}"/>
                    <apex:outputText value="5. How many shows over a year do you typically ship to?">
                    </apex:outputText>
                    <apex:inputField label=" " value="{!Task.A5__c}"/>
            <apex:outputText value="6. If not interested at this time, when do you typically evaluate your carriers?">
            </apex:outputText>
            <apex:inputField label=" " value="{!Task.A6__c}" style="width: 300px; height: 40px;"/>
            </apex:pageblocksection>
            
            <apex:pageBlockSection title="Comments" Columns="1">
                <apex:inputtextarea label=" " value="{!Task.Description}" style="width: 500px; height: 150px;"/>
                
            </apex:pageblocksection>
          </apex:pageBlock>
        </apex:form>
</apex:page>

This is the Extension, which I know is wrong.
public with sharing class LeadQuestionnaireController{
Task task = new Task();
    
    public LeadQuestionnaireController(ApexPages.StandardController controller) {
      this.task = (Task)controller.getRecord();
      string strWhatId = ApexPages.currentPage().getParameters().get('oppIdd');
      string strOwnerId = ApexPages.currentPage().getParameters().get('ownerId');
      Task.WhatId = strWhatId ;
      Task.OwnerId = strOwnerId ;
        
    }

}
Thanks in advance.
Need some help with a Trigger Error. I am not a developer so my skills get stretched with things like this. Also, for whatever it's worth I did not write the Trigger but am in a position to support it. The user is getting the following error when they try and merge records: "AccountTrigger: execution of AfterDelete caused by: System.NullPointerException: Attempt to de-reference a null object: External entry point"."

See below Trigger syntax:
trigger AccountTrigger on Account (before insert, after insert, after update, after delete) {
    String PROSPECT_RT_ID = dao_Account.getInstance().getRecordTypeId('Prospect');
    User defaultOwner = dao_User.getInstance().getUserByName('Medical-Surgical IT Data');
    List<AccountTeamMember> atmInserts = new List<AccountTeamMember>();
    List<AccountShare> ashInserts = new List<AccountShare>();
    String LTC_REP = 'EC Long Term Care Rep';
    String HC_REP = 'EC Home Care DME Rep';     

    Map<Id, Searchable_Account__c> saMap = new Map<Id, Searchable_Account__c>();    
    for (Searchable_Account__c sa : [Select Id, Account__c, Account_Name_ExtId__c from Searchable_Account__c where Account__c in :trigger.new]){
        saMap.put(sa.Account__c, sa);
    }
    for (Account a : Trigger.new)
    {
        if (a.RecordTypeId == PROSPECT_RT_ID)
        {
            if (trigger.isBefore)
            {
                a.OwnerId = defaultOwner.Id;
            } else if (!trigger.isDelete){              
                User originalOwner = dao_User.getInstance().getUser(a.CreatedById);
                AccountTeamMember atm = new AccountTeamMember();
                AccountShare ash = new AccountShare();
                atm.AccountId = a.Id;
                atm.UserId = originalOwner.Id;
                if ( originalOwner.Profile.Name.contains('HomeCare') || (originalOwner.UserRoleId != null && originalOwner.UserRole.Name.startsWith('HC'))  )
                {
                    atm.TeamMemberRole = HC_REP;
                } else if ( originalOwner.Profile.Name.contains('LongTermCare')  || (originalOwner.UserRoleId != null && originalOwner.UserRole.Name.startsWith('LTC')) ) {
                    atm.TeamMemberRole = LTC_REP;
                }
                atmInserts.add(atm);
                
                ash.AccountAccessLevel = 'Edit';
                ash.AccountId = a.Id;
                ash.OpportunityAccessLevel = 'None';
                ash.UserOrGroupId = originalOwner.Id;
                ashInserts.add(ash);
                
            }
        } else if (trigger.isAfter) {           
            Searchable_Account__c sa = saMap.get(a.id);
            if (sa== null) sa = new Searchable_Account__c();
            sa.Account__c = a.Id;
            sa.Account_Name_ExtId__c = a.Name + ' | ' + a.AccountNumber;
            saMap.put(a.Id,sa);
        }                   
    }
    insert atmInserts;
    insert ashInserts;
    upsert saMap.values();
}
I understand what is happening, and to an extent why but I am at a loss as to how to fix it. Thanks in advance for any guidance.