• Lindsay Tackett
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 0
    Replies
Hello All,

We are attempting to create a visualforce selectlist where our sales consultants can pick an approved lender (custom object Lender__c) for a custom object (Job__c).  These lenders have to be 'Approved' and be in the same 'Division' as the user.  I've gotten far enough as to where the list shows up on the page layout, and there is a save button but I cannot get the value they select from the dropdown to actually save.  

I think I'm okay up to the 'public PageReference save(){' but I am failing to figure out how to save the value the user selects.  Any help or direction is much appriciated.

Also, I'm terrible at all this visualfroce/apex stuff so if there are any suggestions on improving the code or better methods please let me know.  Thanks all!

VF Page:
<apex:page standardController="Job__c" extensions="selectoptions" tabStyle="Job__c">
<apex:form >
<apex:pageblock mode="edit">
<apex:outputLabel style="font-weight:Bold" value="Select a Lender :" />
<apex:SelectList size="1" value="{!lst}" multiselect="false">
<apex:selectOptions value="{!items}"/>
</apex:SelectList>
<br /><br />
<apex:pageBlockButtons location="bottom"> <apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:page>

Controller:

public with sharing class selectoptions
{
    public List<lender__c> lst
    {get;set;}
    public selectoptions(ApexPages.StandardController sc){}
    {
        lst = [select Name from Lender__c WHERE Lender_Status__c = 'Approved' AND My_Division_Lender__c = 1];
    }
    public List<SelectOption> getItems()
    {      
        List<SelectOption> options = new List<SelectOption>();
                   options.add(new SelectOption('','-Select-'));
        for(Integer i=0; i < lst.size(); i++)
        {
            options.add(new SelectOption(lst[i].Name,lst[i].Name));
        }
        return options;
    }
    public PageReference save(){
    update lst;
     return null;
    }
 }
Hello!

We have a trigger that was updated we need deployed into Production but do not have a test class for it - can anyone help?

trigger SH_Opportunity_Set_Contingency_And_Release_Dates on Opportunity (before insert, before update)
{
    for (Opportunity o : Trigger.New)
    {
        if(o.StageName == 'Contingent' | o.StageName == 'Pending Contingent')
        {
            if(o.Contingency_Date__c == NULL)
            {
                o.Contingency_Date__c = Date.today();
            }
            
            o.Contingency_Release_Date__c = NULL;
        }
        else
        {
            if(o.Contingency_Date__c != NULL)
            {
                if(o.Contingency_Release_Date__c == NULL)
                {
                    o.Contingency_Release_Date__c = Date.today();
                }
            }
        }
    }
}
Good Morning All!

In my organization, we have created an Approval Process on a custom object (Job) which gets automatically submited to a specific role (GM) 50 days after "Contract Date."  The business has now requested that after 3 days, if the GM has not approved or declined the request, that it is automatically marked as approved.

Is there anyway to create an Apex Class or trigger with these requirements?  I was thinking to add a step to my Process Builder with that criteria to fire an Apex Class if the GM Approved and GM Declined date are both blank after 3 days of the approval process start date but not sure how to approve via that Apex Class.  I've found a lot of posts about submitting and then approving a request but having trouble locating anything about approving a pending request.

Thanks for any help!
Hi all,

Our Salesforce stopped sending notification emails when an account has been transferred (even if the 'Send Notificaiton Email' checkbox is marked) so I am trying to create an Apex Trigger that will send an email to the old and new account owner and I almost have it although I can't figure out how to pull in the Account Name so that they both know which account has been transferred.  The original emails send from Salesforce also included a link to the account record which would be nice but not neseccary.  

Here's what I have:
 
trigger Sampleemailtrigger on Account (after update) {
  
  List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
  List<ID>ownerids=new List<ID>();
  
  List<String> sendTo = new List<String>();
  List<User>users=new List<User>();
  
  for (Account myacc : Trigger.new) {
  
    Account oldcon = Trigger.oldMap.get(myacc.Id);
    if (myacc.ownerid != oldcon.ownerid ) {
    
       ownerids.add(myacc.ownerid) ;  
       ownerids.add(oldcon.ownerid) ;
       
      
    }
    }
    
    if(ownerids.size()>0 ){
      
    users=[select name,id,email from user where id in:ownerids];
    system.debug('-------------users------'+users);
    if(users.size()>0){
     for(User u:users){
      sendTo.add(u.Email);
    }
    
     Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
     //mail.setReplyTo('ramanisetti@gmail.com');
      mail.setSenderDisplayName('Email alert');

      mail.setSubject('Household Owner Transfer   ');
      String body = 'The following Household has been transferred:';
      mail.setToAddresses(sendTo);
      mail.setHtmlBody(body);
      mails.add(mail);
      try{
      Messaging.sendEmail(mails);
      }
      catch(Exception e){
      system.debug('-------------exception------'+e);
       
      }
    
    }
    
    }
  
}

If anyone could help me include the Account Name (household for us), and a link to the account record that would be great!  Thanks!