• Amol Salve 14
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 11
    Replies
Hi All,


trigger SendNotification on Savings_Risk_Checklist__c (After insert,after update) {

   Savings_Risk_Checklist__c SCS = trigger.new[0]; 
  
  
  
  if (Trigger.IsInsert || Trigger.IsUpdate) { 
    if(SCS.Savings_Checklist_Form_Status__c =='Proposal Submitted'|| SCS.Savings_Checklist_Form_Status__c=='Final From Submitted') {
       Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
       
       
          EmailTemplate et=[Select id from EmailTemplate where Name=:'Savings Risk Check List Proposal Submittion'];
          //mail.setWhatId(SCS.ID);
          mail.setTargetObjectId(SCS.id);
          mail.setTemplateId(et.id);
          mail.setToAddresses(new List<String>{'putluruvishnu@gmail.com'});
          mail.setSaveAsActivity(false); 
          Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
            
      } 
    
i have Written above code on Custom Object to send an email. but i am Getting Below Error

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger SendNotification caused an unexpected exception, contact your administrator: SendNotification: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_TYPE_FOR_OPERATION, Only User, Contact, Lead, or Person objects are allowed for targetObjectId: 01I37000000kq3E.: [targetObjectId, 01I37000000kq3EEAQ]: Trigger.SendNotification: line 13, column 1

 
Hi, so I've been trying to save values from a custom select list called campusIdOptions for a custom objects edit page, the values have been displaying but not saving, I would greatly appriacate any input on this problem, I have attached the code below, thank you for your time 

<apex:page standardController="Facilities__c"   extensions="FacilitiesEditPageControllerExtension">
<apex:sectionHeader title="Edit Facility" subtitle="{!Facilities__c.Name}"/>
<apex:form >
    <apex:pageBlock title="Edit Facility" mode="edit"  >
        <apex:pageBlockSection title="Information" columns="2">
            <apex:pageBlockSection columns="1" />

                <!--apex:inputField value="{!Facilities__c.campus__c}"/-->
                <apex:selectList value="{!Facilities__c.campus__c}" size="1" >
                    <apex:selectOptions value="{!campusIdOptions}" />
                </apex:selectList>

            </apex:pageBlockSection>
        </apex:pageBlockSection>
           <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
            <apex:commandButton action="{!doSaveAndNew}" value="Save & New"/>
            <apex:commandButton action="{!Cancel}" value="Cancel"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form> 
</apex:page>

Controller:

public class FacilitiesEditPageControllerExtension 
{
       ApexPages.standardController m_sc = null;
    public static integer counter = 100000;
    Facilities__c fc;
    public SelectOption[] campusIdOptions{
        public get{ return campusIdOptions; }
        private set{ campusIdOptions = value; } 
    }
    
    
    
    public FacilitiesEditPageControllerExtension(ApexPages.StandardController controller)
    {
        fc = (Facilities__c) controller.getrecord();
        m_sc = controller;
        getOptionsForCampusIds();
        //this.campusIdOptions.add(Create_new());
    }
    
   
    
    public void getOptionsForCampusIds()
    {
        Id accId = fc.account__c;
        List<facilities__c> facilityList = [SELECT Name, campus__c, Account__r.id FROM facilities__c WHERE Account__r.id =: accId];
        List<Decimal> facility_campus_ids = new List<Decimal>();
        campusIdOptions = new List<SelectOption>();
        
        if (facilityList != null)
        {
          
            for (facilities__c s : facilityList)
            {
                if ( s.campus__c != null)
                {
                    Decimal campusNumber = s.campus__c;
                    System.debug(campusNumber.toPlainString());
                    //campusIdOptions.add(new SelectOption(campusNumber.toPlainString(), campusNumber.toPlainString()) );
                }
            }   
        }
    }
    
    
    public SelectOption Create_new()
    {
           List<facilities__c> facilityList = [SELECT id, campus__c
                                            FROM facilities__c 
                                            Where campus__c != null
                                               Order By campus__c Desc
                                            Limit 1
                                           ];
        return new SelectOption((facilityList[0].campus__c + 2).format(),'Create New');
    }
    
  public Pagereference doSaveAndNew()
  {
    SObject so = m_sc.getRecord();
    upsert so;
    string s = '/' + ('' + 'setup/ui/recordtypeselect.jsp?ent=01I44000000EElz&retURL=%2Fa0w%2Fo&save_new_url=%2Fa0w%2Fe%3FretURL%3D%252Fa0w%252Fo') + '/e?';
    ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.Info, s));
    return new Pagereference(s);
  }

}


 
I'm working with adding fields and then getting them into my compact layout. I've set up Account Name and Account Owner the same way as Lookup Relationship and Text fields.  However the challenge only picks up that one of them is not showing in my Compact Layout.  When I look at the page layouts, you'll see that both the Account Name and Account Owner fields are grayed out.  Does this have anything to do with it?  Or is that another issue altogether?

User-added image
User-added image

User-added image
Hi,

I need help on the following requirement below as follows,

1) I have a account object where contract is another object related to account

2) Contract object is having contract start date and end date which populates to account 

My scenario is 

3)If there are 2 active contract associcated to account and the dates contain

1st Active contracts dates are

start date :1.feb 2017
end date : 31st march 2017

2nd active contract dates are

start date : 1st march 2017
end date : 17th sep 2017

then in this scenatio the first active contract end date should be automatically backdated to the previous month below as follows to avoid overlapping between 2 contracts

1st active contract end date should automatically be changed to 

end date :28th feb 2017
start date should remain the same as 1 feb 2017.

basically both contracts end dates and start dates shouldnt fall in same range to avoid overlapping

Help me how to achieve this 

Thanks in advance
There are two buttons on lead. 1.Convert, 2. Do not send
Clicking on convert opens a visual force page, while do not send is a java script button.
The requirement is, when either of these buttons are pressed a validation need to fire if the picklist value is selected as "unknown" for the field "cx interested?" on lead.  This field has 3 picklist values: Yes/No/unknown. The validation should fire only when the value is selected as "Unknow"
Now pls tell me what changes i need to make in visual force page and java script button.
Thanks
Hello,

I'm working to build a simple, custom territory management solution for my org; other territory management tools don't quite do the trick. Basically, I need to assign accounts to territories based on the zip code value in the account's billing address.

First, some object details: I have a custom object for Territories and a custom object for Zip Codes. Each Zip Code record has a lookup field for a Territory record, which basically signifies that the zip code "belongs" to the related territory. I can go to each Territory record and see a related list of the associated Zip Code records. I also have a Territory lookup field on the account record. (I was told that I may need a Zip Code lookup on the account as well to serve as a junction, but I'm not sure about that one yet...)

Now, what I want to accomplish: I need to create an apex trigger that says, "if the value in the account's billing zip code matches the name of any existing Zip Code record, then 'Territory' (on the account) equals the Territory related to that matched Zip Code record."

I was hoping to accomplish this via process builder, but Salesforce Support informed me that this won't be possible... which brings me here. Can anyone help me get started on coding an apex trigger that can accomplish what I stated above? I'd appreciate any guidance you can provide.

Thank you!
I'm trying to update the data in an input text field using a button and javascript. I've tried using document.getElementByID but i get an error saying that isn't a function. Here is my code so far:

document.getElementByID("Case.Subject").value="Does this work?";

function CopySubject() {
var a = "{!Case.Subject}";
alert(a); 
}

function CopyCN() {
var b = "{!Case.CaseNumber}";
alert(b); 
}

CopySubject();
CopyCN();

Essentially, my code should put "Does this work?" into the subject of the case and then put out messages that contain the subject and case number. Any help is greatly appreciated!
Hi All,

on a vfpage i have a inputtext box and a insert button next to it. 

my requirement is when user types some text in the inputtextbox and presees insert button then a new row has to be added below with the text as outputtext. 

when the user again types some text in the input textbox and again pressed insert button then the previously added row should go down and the new row should be added with the text input 

Please let me know how to achieve. it will be more helpful if code can be shared for the same.

Best Regards,
Mohammad Yaseen.
Error is--- 

System.DmlException: Update failed. First exception on row 0 with id 00Q7F000001xDVEUA2; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Geolocation (Latitude), Geolocation (Longitude)]: [Geolocation (Latitude), Geolocation (Longitude)]
Error is in expression '{!Updatelocation}' in component <apex:commandButton> in page geolocation: Class.Geolocation.Updatelocation: line 13, column 1
Class.Geolocation.Updatelocation: line 13, column 1




My code is--- 

public with sharing class Geolocation {
    Public Decimal Lat {get; set;}
    Public Decimal lon {get; set;}
    Public Id lid {get; set;}
    public PageReference Updatelocation(){
       
         lid = ApexPages.currentPage().getParameters().get('id');
         Lead l= new Lead();
         
         l.id= lid;
         l.Geolocation__Latitude__s = lat;
         l.Geolocation__Longitude__s = lon;
        update l;
       
        return new PageReference('javascript:window.close()');
    }
}
Hi, How to display case records based on picklist slection using visualforce LIghting
I have 4 Picklist fields in case object, i have to display these 4 picklist fields in  visulaforce page and based on thsese picklist fileds selection need to display case records on page .this should be done  in visulaforce lighting.Please help me to complete it.i am new to salesforce :( help