+ Start a Discussion
SirTravSirTrav 

When talking to another developer today we came across a question that we can't find the answer to so I was hoping someone here knew the answer.  I know that you can create a visualforce page with more than one extension.  My questions are:

1. Why would you use more than one?

2. If you have more that one in what order does visualforce look for your method?

3. What happens if you have a method with the same name on different extensions?

Best Answer chosen by Admin (Salesforce Developers) 
nickwick76nickwick76

Hi,

 

  1. You want to extend a controller with different types of behaviour already implemented in separate Apex classes. Instead of creating one big class you extend them separately keeping it simple and easy to maintain
  2. left to right
  3. leftmost overrides

Read more here -> http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_extension.htm

 

HTH / Niklas

Marek Smerak (TH)Marek Smerak (TH) 
I've got an error from last challange in "Developer Console Basics":

"Challenge Not yet complete... here's what's wrong: 
Could not find the contact's name in the debug log. Be sure to run a query for your record, and to write your contact's name to the debug log using the System.debug() method."

But I'm sure that debog log include the correct lastname, first name as requested and use SOSL.

Does anyone else have the same issue?

 
Best Answer chosen by Marek Smerak (TH)
JorritDroogsmaJorritDroogsma
I've found the solution... 

It seems releated to older dev orgs where you execute the anonymous apex. I've created a new Trailhead Playground, inserted the contact and executed the same anonymous apex. Running the validation to this new playground was positve and I've got the badge!
Albert BarbieriAlbert Barbieri 
I am unable to validate the challenge for "Implement the Flow with Visualforce" in the new "Build an Account Reassignment Wizard" module.

I keep getting the error message "Challenge Not yet complete... here's what's wrong: Couldn't find two users in your org with a 'Salesforce' license. Check the instructions".

The instructions say to give one user a Salesforce license and the second user a Salesforce Platform license. I tried to give the second user a Salesforce license, but there is only one free Salesforce license as the environment only comes with two and one is automatically assigned to the created administrator account.

Can anyone tell me how I can resolve this issue?
Best Answer chosen by Albert Barbieri
John Stevens MVPJohn Stevens MVP
I have been able to get this to work but I'm not happy about it :)

My steps:
Create an unmanaged package, add the flow, and upload
Signup for a new developer org
Install the unmanged package
Activate the flow
Recreate the VF page, VF tab and add the two users in the new dev org.
Run the verification against the new org - it should pass.
Michael Markel JrMichael Markel Jr 
I have tried the recommendations from other posts on this topic. I have created a couple of new DEs to try this out in. I set up the permissions correctly for my account. I added the fields and attachments to be encrypted but when I go into a contact or case the fields are not encrypted. I double-checked to make sure that the System Administrator does not have View Encrypted Data checked and all permission sets assigned to my user also don't have that option checked but the fields are still not encrypted and the trailhead is not validating, I keep getting the error 'The contact mobile phone field does not appear to be encrypted.' I also tried adding new contacts and cases and editing existing ones but still not encrypted.
Best Answer chosen by Michael Markel Jr
Gustavo TandeciarzGustavo Tandeciarz
https://releasenotes.docs.salesforce.com/en-us/spring17/release-notes/rn_security_pe_masking.htm
S.TurbojetS.Turbojet 
Hello everyone, I'm getting confused on this module for the mobile section... the directions state to build the lens as follows:
  • Dataset: DTC Opportunity
  • Add Group: Opportunity Owner
  • Change Measure: Count of Rows to Sum of Amount
  • Sort by: Dsc (Descending)
  • Filter by: Industry Equals Engineering
  • Filter by: Won Equals True
  • Chart Type: Horizontal Bar
  • Lens Name: Top Engineering Sales
  • App: My Exploration
I have my criteria setup as follows:

User-added image
User-added imageUser-added imageUser-added imageUser-added image

I am just not sure where I am going wrong!  I've tried deleting it and reconstructing it, but every time I get the error "Challenge Not yet complete... here's what's wrong: The 'Top Engineering Sales' lens does not appear to have the correct query. Please check the requirements and ensure everything is setup correctly."

Any help would be appreciated!
Best Answer chosen by S.Turbojet
pchoipchoi
Folks, here's an update: The challenge for Explore Insights on the Go is still not working. The validation code behind the challenge is faulty. Really sorry about that. We're going to fix it sometime next week, we hope. In the mean time, here's a workaround so you don't have to wait for the fix: create the lens for the challenge on your computer instead of your phone. I know, I know, it's sacrilege to suggest that for a mobile unit -- but we want you to earn your badge. You definitely deserve it after the trouble you went through with this challenge.

When we release the update next week, you'll be required to use the mobile app to create the lens to pass the challenge. For now, create that same lens on desktop and you should be good to go. Here's what it looks like. Don't forget to sort!

User-added image

Thank you so much for your patience. My apologies for the poor experience. Pro Tip: Wave mobile app uses compact form for its queries, which is ever-so-slightly different from desktop. Lesson learned. :) Also, if you haven't already noticed, we just released five new Analytics modules this week -- including dashboard navigation, data integration, dashboard designer, Wave admin, and a new product called Smart Data Discovery!
Andy123Andy123 

I'm just learning, so please bear with me.  I'm making a case-merge application.  The user selects cases to be merged and presses a list button.  This launches a VF page that displays the selected cases in an apex:pageBlockTable.

 

I would now like to add a number of summary columns to this table.  The summary columns show how many emails, tasks, attachments, etc.. each of the cases to be merged has.

 

In my VF page I have:

 

<apex:pageBlockTable value="{!SelectedCases}" var="item">

  <apex:column value="{!item.CaseNumber}"/>

  <apex:column value="{!item.Subject}"/>

  ...etc...

</apex:pageBlockTable>

 

In my class I have:

 

public Case[] getSelectedCases() {

  Set<Id> selectedCaseIds = new Set<Id>();

  for (SObject c : setCon.getSelected()) {

     selectedCaseIds.add(c.Id);

  }

  SObject[] items = [SELECT c.Id, c.CaseNumber, c.Subject, c.Contact.Name, c.Account.Name, 

    c.CreatedDate, c.Origin, c.LastModifiedDate FROM Case c WHERE Id IN :selectedCaseIds];

  return items;

}

 

 

I now would like to add a number columns to my table that are the results of queries like:

SELECT count() FROM CaseComment cc WHERE cc.ParentId = EACH CASE ID IN THE ABOVE SET;

 

so my ultimate display shows

 

<apex:pageBlockTable value="{!SelectedCases}" var="item">

  <apex:column value="{!item.CaseNumber}"/>

  <apex:column value="{!item.Subject}"/>

  <apex:column value="{!item.CountOfCaseComments}" />

  ...etc...

</apex:pageBlockTable>

How do I make a 'custom' object that will be rendered in the pageBlockTable where I can add attributes from various sources?

 

Thanks!

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You can't pass parameters back from the page to getters I'm afraid.

 

If it were me, I'd create a custom class that contains the case sobject and any associated total information.  Rather than returning a list of cases, your getter would construct a list of instances of the custom class. Then change the column output in the VF page to pull the appropriate data.

 

E.g. if your custom class contains a getCase() method to retrieve the case info, and a getTotal to retrieve the total, you'd have something like:

 

 

<apex:pageBlockTable value="{!SelectedCases}" var="item">
  <apex:column value="{!item.case.Subject}"/>
  <apex:column headerValue="Contact Name" value="{!item.case.Contact.Name}"/>
  ...etc...
  <apex:column value="{!item.total}"/>
</apex:pageBlockTable>

 

 

supriya Goresupriya Gore 
component:
<aura:component implements="force:appHostable" controller="FetchRegistrations" >
    <aura:attribute name="reg" type="Registration__c[]"/>
    <ui:button label="Get Registrations" press="{!c.myAction}"/>
    <aura:iteration var="r" items="{!v.reg}" >
    <p>{!r.name}</p>
    </aura:iteration>
</aura:component>


Controller:
({
   myAction : function(component, event, helper) {
        var action = component.get("c.getAllregistrations");
        action.setCallback(this, function(response){
            var name = response.getState();
            if (name === "SUCCESS") {
                component.set("v.reg", response.getReturnValue());
            }
        });
     $A.enqueueAction(action);
    }
})

Apex:
global with sharing class FetchRegistrations {
@auraEnabled
    public static List<Registration__c> getAllregistrations()
    {
     List<Registration__c> reg=new LIST<Registration__c>();  
        reg=[select id,name,Email__c from Registration__c];
        return reg;
    } 
    public Registration__c getSelectedregistrations(Id id)
    {    
      Registration__c  reg=[select id,name,Email__c from Registration__c where id=:id];
        return reg;
    } 
   
}
Best Answer chosen by supriya Gore
Prajyot KerkarPrajyot Kerkar
Change {!r.name} to {!r.Name} as javascript is case-sensitive name & Name are different
BegginerBegginer 



Hi all, 

I'm learning triggers in salesforce and want some advice on understanding how to write a trigger for below scenario. what is the approach?
There are two objects Object1_c(Parent) and Object__c(child) having look-up relationship.

Summary:
Object__c has record types namely  "A" and "B".
Object__c has a field (currency) --> Myamount__c
Object__c has 2 picklislts --> Picklist_a__c and Pciklist_b__c
object1__c has a field(curreny_ --> amount__c

Scenario:

when amount__c(on Object1__c) is blank or null, and if record type is either A||B and Picklst_a__c and picklist__b is selected then Myamount__c should be required show be the error.

Thanks in advance.
 
Best Answer chosen by Begginer
rajat Maheshwari 6rajat Maheshwari 6
trigger ObjectTrigger on ObjectPar__c(before update)
  {
     Set<Id> st_ParentId = new set<id>();

for(ObjectPar__c obj : Trigger.new)
   {
   
           st_ParentId.add(obj.lookupField);
   }

List<ObjectCh__c> lst_objCh = new List<ObjectCh__c>([Select id,lookupField from ObjectCh__c where lookupField IN:st_ParentId]);



if(lst_objCh!=null && lst_objCh.size()>0)
  {
    

for(ObjectPar__c obj : Trigger.new)
  {
    
        if(obj.Picklist_a__c!=null && obj.Picklist_b__c!=null && obj.Picklist_b__c=='Checked' && (obj.RecordTypeId==IdCorrespondingtoA || obj.RecordTypeId==IdCorrespondingtoB))

            {
                     obj.addError('My Name is Error');
            }
        }
  }



}


As per your scenario, when picklist b have value "Checked" and having child records related to that then trigger will fire to display error message , otherwise, No error will come.

Thanks

kuldeep paliwalkuldeep paliwal 
trigger updateProjectTeammember on opportunityTeamMember(after insert, after update, after delete){
        if(trigger.isInsert || trigger.isUpdate){
        
        Map<String,String> OppOtmfieldMap=new Map<String,String>();
               OppOtmfieldMap.put('Sr. Client Insights Manager','CEM_Assigned__c');
               OppOtmfieldMap.put('Client Insights Manager','CEM_2nd__c');
               OppOtmfieldMap.put('Data Manager','Ops_Owner__c');
               OppOtmfieldMap.put('Lead Consultant','Consultant_assigned__c');
               OppOtmfieldMap.put('Support Consultant','Consultant_2nd__c');
               OppOtmfieldMap.put('Analysis Support','Analysis_Support__c');
               OppOtmfieldMap.put('BD/Development Partner','BD_Development_Partner__c');
        
        Map<String,String> projOtmfieldMap=new Map<String,String>();
               projOtmfieldMap.put('Sr. Client Insights Manager','Sr_Client_Insights_Manager__c');
               projOtmfieldMap.put('Client Insights Manager','Client_Insights_Manager__c');
               projOtmfieldMap.put('Data Manager','Ops_Manager__c');
               projOtmfieldMap.put('Lead Consultant','Lead_Consultant__c');
               projOtmfieldMap.put('Support Consultant','Support_Consultant__c');
               projOtmfieldMap.put('Analysis Support','Analysis_Support__c');
               projOtmfieldMap.put('BD/Development Partner','BD_Development_Partner__c');
        
            list<id> oppoIdList = new list<id>();
            map<id, id> oppoOtmMap = new map<id, id>();
            list<id> proMemList = new list<id>();
            map<id, id> oppIdProIdMap = new map<id, id>();
            list<id> proId = new list<id>();
            Map<Id,Opportunity> oppIdMap = new Map<Id,Opportunity>();
            Map<id, id> oppIdAccIdMap = new Map<id, id> ();
            Set<id> accId=new Set<Id>();
            
        for(OpportunityTeamMember otm : trigger.new){
                        OppoIdList.add(otm.OpportunityId);
                        oppoOtmMap.put(otm.Id, otm.OpportunityId);
            }
        
        map<id, list<Project__c>> oppIdProjectListMap = new map<id, list<Project__c>>();
        list<Opportunity> oppoList = [select Id, accountId, Project__c, (Select Id, Name from Project__r) From opportunity Where Id In: oppoIdList];
        system.debug('--oppoIdList--' +oppoIdList);
        for(Opportunity op : oppoList){
            proId.add(op.id);
            oppIdMap.put(op.id,op);
            accId.add(op.accountId);
            oppIdAccIdMap.put(op.id, op.accountId);
           // oppIdProIdMap.put(op.id, op.Project__c);
            oppIdProjectListMap.put(op.id, op.Project__r);
            }
                
        list<Project_Team__c> ptmListForInsert = new list<Project_Team__c>();
        system.debug('--proId--' +proId);
        system.debug('--accId--' +accId);
        system.debug('--oppIdProIdMap--' +oppIdProIdMap);
        system.debug('--oppIdAccIdMap--' +oppIdAccIdMap); 
        
        list<Project_Team__c> ptmList = [Select id, Account__c, Project__c, Member_Role__c, Team_Member__c From Project_Team__c Where Id In: proId];
        map<id, list<Project_Team__c>> proPtmMap = new map<id, list<Project_Team__c>>();
        
        for(project_Team__c ptm : ptmList){
        
            list<project_Team__c> tempList = proPtmMap.get(ptm.Project__c);
            
            if(templist!= null && templist.Size()>0){
                tempList.add(ptm);
                }else{
                        tempList = new list<project_Team__c>();
                        tempList.add(ptm);
                }
                proPtmMap.put(ptm.Project__c, tempList);
            }
        
        for(OpportunityTeamMember otm : trigger.new){
        
            Boolean flag = false;
           
            List<project__c> listOfProj = oppIdProjectListMap.get(otm.OpportunityId);
            
            for(Project__c pro : listOfProj){
            List<project_team__c> listOfPrjTm = proPtmMap.get(pro.id);
            
            
            if(listOfPrjTm!= null){
                for(Project_Team__c ptm : listOfPrjTm){
                    if(otm.userId == ptm.Team_Member__c){
                        flag =true;
                        }
                    }
                }
                if(flag ==true){
                }else{
                    Project_Team__c ptm1 = new Project_Team__c();
                    ptm1.Team_Member__c= otm.userId;
                    ptm1.Member_Role__c = otm.TeamMemberRole;
                    ptm1.Account__c = oppIdAccIdMap.get(otm.OpportunityId);
                    ptm1.Project__c = proPtmMap.get(otm.OpportunityId);
                    ptmListForInsert.add(ptm1);
                    system.debug('--ptm1--' +ptm1);
                    }
            }}
        if(ptmListForInsert.size()>0){

        insert ptmListForInsert;
            }
            
  }
}
Best Answer chosen by kuldeep paliwal
HemantJain0206HemantJain0206
 You have declare Map of type, map<id, list<Project_Team__c>> proPtmMap, So when you do proPtmMap.get(otm.OpportunityId) on line 93, it will return you with a list of project_team__c as you have done on line 77: List<project_team__c> listOfPrjTm = proPtmMap.get(pro.id);

Now on line 93: you are trying to assing Project__c(Id filed) to List<project_team__c>, hence the error due to type mismatch.