• Natalie Jane Hodson
  • NEWBIE
  • 10 Points
  • Member since 2017
  • Salesforce Admin
  • Ideal Health Consultants

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
Hi, 

I'm using the DLRS tool and need to change the direction that concatenated data is being order by. 
I'm doing this off of a custom Date field and have tried
Date__c DESC
but this throws up an error that my field does not exist.

I'm not sure if I am using DESC correctly within the tool? 

Thanks,

Natalie
Hi,

I have a list button on a related list called Resource Allocation against my Opportunity object. I have created a mass create record visualforce page that is related to the button. I am pulling my Master Detail Relationship onto my Table, and want to pre-populate it with the Current Record ID of the Opportunity record I selected my button from.

Piecing together elements I found online I was able to create an extension to get the Opp ID, however when I use the button I recieve the following error.
Invalid conversion from runtime type Resource_Allocation__c to Opportunity 
Not sure how I recieve this as there was no error when saving the apex class or visualforce page. I may have just written jibberish as I am new to Apex.

Any Help would be appreciated on this!

<<<<<<<<Related apex below>>>>>>>

Visualforce Page
<apex:page standardcontroller="Resource_Allocation__c" recordSetVar="Resource Allocations" tabstyle="Resource_Allocation__c" extensions="ManageListController,OppExtension" >
<apex:form >
   <apex:pageBlock title="Bulk Resource Allocation Create">
      <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
         <apex:column headerValue="Ident">
            <apex:outputText value="{!wrapper.ident}"/>
         </apex:column>
        <apex:column headervalue="Opportunity">
        <apex:inputField id="OppsID" value="{!wrapper.RA.Opportunity__c}"/>
        </apex:column>
        <apex:column headerValue="Resource Name or Role">
         <apex:inputField value="{!wrapper.RA.Resource_Name_or_Role__c}"/>
                 </apex:column>
        <apex:column headerValue="Start">
            <apex:inputField value="{!wrapper.RA.Start_Date__c}"/>
        </apex:column>
         <apex:column headerValue="End">
            <apex:inputField value="{!wrapper.RA.End_Date__c}"/>
         </apex:column>
         <apex:column headerValue="Est Pay">
            <apex:inputField value="{!wrapper.RA.Resource_Est_Pay__c}"/>
         </apex:column>
         <apex:column headerValue="Est Charge">
            <apex:inputField value="{!wrapper.RA.Resource_Est_Charge__c}"/>
         </apex:column>
        <apex:column headerValue="Max Days Contracted">
        <apex:inputfield value="{!wrapper.RA.Max_Days_Contracted__c}"/>
               </apex:column>
         <apex:column headervalue="Daily Expense Allowance">
               <apex:inputField value=" {!wrapper.RA.Daily_Expense_Allowance__c}"/>
               </apex:column>
         <apex:column headerValue="Action">
            <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">
               <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>
            </apex:commandButton>
         </apex:column>
      </apex:pageBlockTable>
      <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="5" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Save" action="{!save}"/>
   </apex:pageBlock>
 </apex:form>
</apex:page>

Extension 1
public class ManageListController 
{
   private final Resource_Allocation__c RA;
     // The extension constructor initializes the private member
        // variable RA by using the getRecord method from the standard
        // controller.
        public ManageListController(ApexPages.StandardSetController stdController) {
            this.RA = (Resource_Allocation__c)stdController.getRecord();
            wrappers=new List<ResourceAllocationWrapper>();
        }

 public List<ResourceAllocationWrapper> wrappers {get; set;}
 public static Integer toDelIdent {get; set;}
 public static Integer addCount {get; set;}
 private Integer nextIdent=0;
  
 public ManageListController()
 {
  wrappers=new List<ResourceAllocationWrapper>();
  for (Integer idx=0; idx<1; idx++)
  {
   wrappers.add(new ResourceAllocationWrapper(nextIdent++));
  }
 }
  
 public void delWrapper()
 {
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
   
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
 }
  
 public void addRows()
 {
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new ResourceAllocationWrapper(nextIdent++));
  }
 }
  
 public PageReference save()
 {
  List<Resource_Allocation__c> RA=new List<Resource_Allocation__c>();
  for (ResourceAllocationWrapper wrap : wrappers)
  {
   RA.add(wrap.RA);
  }
   
  insert RA;
   
  return new PageReference('/' + Schema.getGlobalDescribe().get('Opportunity').getDescribe().getKeyPrefix() + '/o');
 }
  
 public class ResourceAllocationWrapper
 {
  public Resource_Allocation__c RA {get; private set;}
  public Integer ident {get; private set;}
   
  public ResourceAllocationWrapper(Integer inIdent)
  {
   ident=inIdent;
   RA=new Resource_Allocation__c(Name='RA' + ident);
  }
 }
}

 
Extension2
public class OppExtension {
 private final Opportunity Opps;
     // The extension constructor initializes the private member
        // variable Opps by using the getRecord method from the standard
        // controller.
        public OppExtension(ApexPages.StandardSetController stdController) {
            this.Opps = (Opportunity)stdController.getRecord();
                    }

     
        public Opportunity currentRecord{get; set;}
         
        public OppExtension(ApexPages.StandardController controller) {
            currentRecord = [SELECT Id, Name, Amount FROM Opportunity WHERE Id =:ApexPages.currentPage().getParameters().get('OppsId')];
        }
     
    }
Hi I have a Controller that dynamically adds Rows and new records through a Visual Force page. I had the page working perfectly as a detail button, however when I added in the elements to make it a list button, I recieve the following error on  Add Row execution:

Attempt to de-reference a null object
Error is in expression '{!addRows}' in component <apex:commandButton> in page resource_allocation: Class.ManageListController.addRows: line 46, column 1


Not sure what has changed since adding the List Button lines as the liones below haven't altered. Any help would be greatly appreciated!

Controller
public class ManageListController 
{
   private final Resource_Allocation__c RA;
     // The extension constructor initializes the private member
        // variable RA by using the getRecord method from the standard
        // controller.
        public ManageListController(ApexPages.StandardSetController stdController) {
            this.RA = (Resource_Allocation__c)stdController.getRecord();
        }

 public List<ResourceAllocationWrapper> wrappers {get; set;}
 public static Integer toDelIdent {get; set;}
 public static Integer addCount {get; set;}
 private Integer nextIdent=0;
  
 public ManageListController()
 {
  wrappers=new List<ResourceAllocationWrapper>();
  for (Integer idx=0; idx<1; idx++)
  {
   wrappers.add(new ResourceAllocationWrapper(nextIdent++));
  }
 }
  
 public void delWrapper()
 {
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
   
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
 }
  
 public void addRows()
 {
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new ResourceAllocationWrapper(nextIdent++));
  }
 }
  
 public PageReference save()
 {
  List<Resource_Allocation__c> RA=new List<Resource_Allocation__c>();
  for (ResourceAllocationWrapper wrap : wrappers)
  {
   RA.add(wrap.RA);
  }
   
  insert RA;
   
  return new PageReference('/' + Schema.getGlobalDescribe().get('Opportunity').getDescribe().getKeyPrefix() + '/o');
 }
  
 public class ResourceAllocationWrapper
 {
  public Resource_Allocation__c RA {get; private set;}
  public Integer ident {get; private set;}
   
  public ResourceAllocationWrapper(Integer inIdent)
  {
   ident=inIdent;
   RA=new Resource_Allocation__c(Name='RA' + ident);
  }
 }
}

VisualForce Pagew
<apex:page standardcontroller="Resource_Allocation__c" recordSetVar="Resource Allocations" tabstyle="Resource_Allocation__c" extensions="ManageListController" >
<apex:form >
   <apex:pageBlock title="Bulk Resource Allocation Create">
      <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
         <apex:column headerValue="Ident">
            <apex:outputText value="{!wrapper.ident}"/>
         </apex:column>
        <apex:column headervalue="Opportunity">
        <apex:inputField value="{!wrapper.RA.Opportunity__c}"/>
        </apex:column>
        <apex:column headerValue="Resource Name or Role">
         <apex:inputField value="{!wrapper.RA.Resource_Name_or_Role__c}"/>
                 </apex:column>
        <apex:column headerValue="Start">
            <apex:inputField value="{!wrapper.RA.Start_Date__c}"/>
        </apex:column>
         <apex:column headerValue="End">
            <apex:inputField value="{!wrapper.RA.End_Date__c}"/>
         </apex:column>
         <apex:column headerValue="Est Pay">
            <apex:inputField value="{!wrapper.RA.Resource_Est_Pay__c}"/>
         </apex:column>
         <apex:column headerValue="Est Charge">
            <apex:inputField value="{!wrapper.RA.Resource_Est_Charge__c}"/>
         </apex:column>
        <apex:column headerValue="Max Days Contracted">
        <apex:inputfield value="{!wrapper.RA.Max_Days_Contracted__c}"/>
               </apex:column>
         <apex:column headervalue="Daily Expense Allowance">
               <apex:inputField value=" {!wrapper.RA.Daily_Expense_Allowance__c}"/>
               </apex:column>
         <apex:column headerValue="Action">
            <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">
               <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>
            </apex:commandButton>
         </apex:column>
      </apex:pageBlockTable>
      <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="5" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Save" action="{!save}"/>
   </apex:pageBlock>
 </apex:form>
</apex:page>

(Code credit to http://bobbuzzard.blogspot.com/2011/07/managing-list-of-new-records-in.html)

 
Hi,

A developer created a piece of apex code back in 2015 that is blocking a current deployment. For some reason it has only just started to fail, and without knowing the reason why, I (a non-developer) need to address the errors within the class.

The Apex class keeps updates of a portal user in sync with its corresponding contact. As far as I can see, as part of the Test, the code is creating a new portal user and contact record based on the Current Users details.

Unfortunately due to a flow triggered by contact creation, the class and subsequent trigger are not firing.The flow is looking for the account record of the contact that is being created, to update fields within the contact record. 

Is their a way to capture within the apex class the current user's related contact detail, to pull the account record to satisfy the flow? 
Hi, 

I'm using the DLRS tool and need to change the direction that concatenated data is being order by. 
I'm doing this off of a custom Date field and have tried
Date__c DESC
but this throws up an error that my field does not exist.

I'm not sure if I am using DESC correctly within the tool? 

Thanks,

Natalie
Hi I have a Controller that dynamically adds Rows and new records through a Visual Force page. I had the page working perfectly as a detail button, however when I added in the elements to make it a list button, I recieve the following error on  Add Row execution:

Attempt to de-reference a null object
Error is in expression '{!addRows}' in component <apex:commandButton> in page resource_allocation: Class.ManageListController.addRows: line 46, column 1


Not sure what has changed since adding the List Button lines as the liones below haven't altered. Any help would be greatly appreciated!

Controller
public class ManageListController 
{
   private final Resource_Allocation__c RA;
     // The extension constructor initializes the private member
        // variable RA by using the getRecord method from the standard
        // controller.
        public ManageListController(ApexPages.StandardSetController stdController) {
            this.RA = (Resource_Allocation__c)stdController.getRecord();
        }

 public List<ResourceAllocationWrapper> wrappers {get; set;}
 public static Integer toDelIdent {get; set;}
 public static Integer addCount {get; set;}
 private Integer nextIdent=0;
  
 public ManageListController()
 {
  wrappers=new List<ResourceAllocationWrapper>();
  for (Integer idx=0; idx<1; idx++)
  {
   wrappers.add(new ResourceAllocationWrapper(nextIdent++));
  }
 }
  
 public void delWrapper()
 {
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
   
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
 }
  
 public void addRows()
 {
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new ResourceAllocationWrapper(nextIdent++));
  }
 }
  
 public PageReference save()
 {
  List<Resource_Allocation__c> RA=new List<Resource_Allocation__c>();
  for (ResourceAllocationWrapper wrap : wrappers)
  {
   RA.add(wrap.RA);
  }
   
  insert RA;
   
  return new PageReference('/' + Schema.getGlobalDescribe().get('Opportunity').getDescribe().getKeyPrefix() + '/o');
 }
  
 public class ResourceAllocationWrapper
 {
  public Resource_Allocation__c RA {get; private set;}
  public Integer ident {get; private set;}
   
  public ResourceAllocationWrapper(Integer inIdent)
  {
   ident=inIdent;
   RA=new Resource_Allocation__c(Name='RA' + ident);
  }
 }
}

VisualForce Pagew
<apex:page standardcontroller="Resource_Allocation__c" recordSetVar="Resource Allocations" tabstyle="Resource_Allocation__c" extensions="ManageListController" >
<apex:form >
   <apex:pageBlock title="Bulk Resource Allocation Create">
      <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
         <apex:column headerValue="Ident">
            <apex:outputText value="{!wrapper.ident}"/>
         </apex:column>
        <apex:column headervalue="Opportunity">
        <apex:inputField value="{!wrapper.RA.Opportunity__c}"/>
        </apex:column>
        <apex:column headerValue="Resource Name or Role">
         <apex:inputField value="{!wrapper.RA.Resource_Name_or_Role__c}"/>
                 </apex:column>
        <apex:column headerValue="Start">
            <apex:inputField value="{!wrapper.RA.Start_Date__c}"/>
        </apex:column>
         <apex:column headerValue="End">
            <apex:inputField value="{!wrapper.RA.End_Date__c}"/>
         </apex:column>
         <apex:column headerValue="Est Pay">
            <apex:inputField value="{!wrapper.RA.Resource_Est_Pay__c}"/>
         </apex:column>
         <apex:column headerValue="Est Charge">
            <apex:inputField value="{!wrapper.RA.Resource_Est_Charge__c}"/>
         </apex:column>
        <apex:column headerValue="Max Days Contracted">
        <apex:inputfield value="{!wrapper.RA.Max_Days_Contracted__c}"/>
               </apex:column>
         <apex:column headervalue="Daily Expense Allowance">
               <apex:inputField value=" {!wrapper.RA.Daily_Expense_Allowance__c}"/>
               </apex:column>
         <apex:column headerValue="Action">
            <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">
               <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>
            </apex:commandButton>
         </apex:column>
      </apex:pageBlockTable>
      <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="5" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Save" action="{!save}"/>
   </apex:pageBlock>
 </apex:form>
</apex:page>

(Code credit to http://bobbuzzard.blogspot.com/2011/07/managing-list-of-new-records-in.html)