• Vishnu_SFDC
  • NEWBIE
  • 90 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 17
    Replies
I am new to Apex Coding / Triggers and I am stuck. I'm trying to create a trigger where when an event is created with a specific subject line, it automatically populates an "Appointment Date" custom field on the Opportunity object. Where do I begin? Thank you!
We would like to limit our users from proceeding to a certain stage if no products have been selected on an opportunity. RIght now, it doesn't appear there is a way. But it's important that products be mandated and fear they won't be used if there's no trigger to ensure they're selected. Is there a way around validation rule limitations that only work on object fields?
Hi - I do not have much Apex experience so please forgive me in advance.

I would like to have a cross object field update for 2 custom objects. I have a custom object called "Fund" which has a field called "service end date". Now i have another object called "Class" which is related to the Fund object. (You cannot have a class with out having a Fund"). What I would like to do is when a service end date is filled out at the fund level that it automatically updates the class end date.

Is this possible? Please let me know if I need to provide more information.

Thank you so much in advance!
Hello ,

Below is the code for which i am getting the error.
system.debug(slots.size());
for(Integer i =slots.size()-1;i>=0; i--)
      {
        system.debug(slots[i]);
        date d = Date.newinstance((slots[i].StartDateTime).year(),(slots[i].StartDateTime).month(),(slots[i].StartDateTime).day());
        for (event__c e : event)
        {
            system.debug(e);
            system.debug(today2);
            //date d2 = Date.newinstance((e.Start_Datetime__c).year(),(e.Start_Datetime__c).month(),(e.Start_Datetime__c).day());
            if(((slots[i].startDateTime<e.Start_Datetime__c && slots[i].StartDateTime.addminutes(apptmin)<e.Start_Datetime__c) || 
               (slots[i].startDateTime>e.End_Datetime__c && slots[i].startDateTime.addminutes(apptmin)>e.End_Datetime__c))   &&
                (e.Start_Datetime__c <=today2.addDays(6) && e.Start_DateTime__c >= today2.addDays(-1)))
            {
                
            }
            else
            {
                if(slots[i].userid == e.Event_Owner__c)
                {
                slots.remove(i);
                }
            }
      }
      }
When i debug the size i get size = 264.
but i get List index out of bounds: 263 error.
can someone help me out with this.

Thanks,
Vishnu

Hi Everyone,
Below is my visualforce page.

<apex:column headerValue="Select" >
     <apex:actionsupport event="onclick" > 
                        <input type="radio" />                   
                            <apex:param name="RepId" value="{!Item.id}">
                        </apex:param></apex:actionsupport>
       </apex:column>
     <apex:column headervalue="Name">
                        <apex:outputfield style="width:2500px" value="{!Item.User__c}">
                    </apex:outputfield></apex:column>
     <apex:column headervalue="Start DateTime">
                        <apex:outputfield value="{!Item.Start_DateTime__c}">
                    </apex:outputfield></apex:column>
      <apex:column headervalue="End DateTime">
                        <apex:outputfield value="{!Item.End_DateTime__c}">
                    </apex:outputfield></apex:column>
      <apex:column headervalue="Approximate Distance To Appointment">
                        <apex:outputfield value="{!Item.Distance__c}">
                    </apex:outputfield></apex:column>
      <apex:column headervalue="Number of events">
                        <apex:outputfield value="{!Item.Number_of_Events__c}">


How can i pass the value of of that row to the controller class.

Thanks in advance.
Hi
I have Active__C field and Expiration_Date__c field. If the active__c Flag is true, then the Expiration_Date__c must be greaterthan current date. 
I need to write Batch apex class for this requirement.This Batch apex class runs on thousands of records.
Please help me any one know how to write code for this.

Thanks
Babu
Hey,

I'm in the process of developing a custom button on Salesforce that is able to toggle a checkbox on and off.
At this point, I am using the Salesforce AJAX Toolkit in order to do the main backend functions of the custom button.
I have the backend working, but I was hoping I could have the custom button label toggle between "Start Process" and "End Process".
To do this, I assume I would need the custom button to change it's own label.
I attempted this by placing these lines in my code:
    var toggleButton = new sforce.SObject("Lead");
    var toggleButtonT ="{!Lead.Begin_Touch_Process}"; //my attempt to reference the button
    toggleButtonT.Id = "00bc0000000QoaE"; // my attempt to reference the button id
    toggleButtonT.Label = "test"; // entering new value for the button label
    result = sforce.connection.update([toggleButton]); // updating the button
NOTE:  {!RequireScript} is already mentioned in script.
It's also entirely possible that I cannot change the name of the button with the AJAX Toolkit.

I am very new to Salesforce and learning about this tool, so any ideas or suggestions will be greatly appreciated!


Thanks,
TF
ERROR: Attempt to de-reference a null object
Error is in expression '{!save}' in component <apex:commandButton> in page installer_view


My Visualforce page:
<apex:page standardController="Installers__c" showHeader="true" tabStyle="Installers__c" extensions="MultiAttachmentController">
<apex:sectionHeader subtitle="{!Installers__c.Name}" title="Installer"/>
<chatter:feedWithFollowers entityId="{!Installers__c.id}"/>
<br>
</br>
<apex:form >
<apex:actionRegion >
<apex:pageblock title="Installer Detail" mode="mainDetail">
<apex:pageBlockButtons >
<apex:commandButton value="Edit" action="{!Edit}" style="display: inline;"  />
<apex:commandButton value="Delete" action="{!Delete}"  />
<apex:commandButton action="{!URLFOR($Action.Installers__c.Upload_Documents,Installers__c.Id)}" value="Upload Documents"/>
<apex:commandButton Action="{!save}" id="saveButton" value="Save" />
<apex:commandButton Action="{!Cancel}" id="cancelButton" value="Cancel" style="display: None;" />
........

My Component
<apex:component controller="MultiAttachmentController" allowDML="true">
    <apex:attribute name="objId" type="String" description="The id of the object to manage attachments for" required="true" assignTo="{!sobjId}"/>
    <apex:form id="attForm">
        <apex:pageBlock title="Upload Attachments">
            <apex:repeat value="{!newAttachments}" var="newAtt">
                <apex:pageBlockSection columns="3">
                  <apex:outputLabel value="Title">            
                  <apex:selectList id="Title" value="{!Title}" size="1">
.......................

My Controller
public with sharing class MultiAttachmentController
{

    public String delet { get; set; }
  
    id token = ApexPages.currentPage().getParameters().get('_CONFIRMATIONTOKEN');
    Id attId = System.currentPageReference().getParameters().get('id');
  
    public MultiAttachmentController(ApexPages.StandardController stdcontroller2) {

    }

    // the parent object it
    public Id sobjId {get; set;}
  
    // list of existing attachments - populated on demand
    public List<Attachment> attachments ;
    public List<Note> Notes ;
  
    //list of picklist values
       public String Title {get; set;}
       
         
    // list of new attachments to add
    public List<Attachment> newAttachments {get; set;}
  
    // the number of new attachments to add to the list when the user clicks 'Add More'
    public static final Integer NUM_ATTACHMENTS_TO_ADD=5;

    // constructor
    public MultiAttachmentController()
    {
        // instantiate the list with a single attachment
        newAttachments=new List<Attachment>{new Attachment()};
    }
....................

I get this error in only View mode(Inline Editing). When i am in Edit mode i dont get this error.
I am trying to execute the following class from a button. when i set the limit to 9 it wors fine. When i remove limit on the 1st query it throws error on other triggers.

global class DERedistribute{
@future
webservice static void DERedistribute(){
List<Lead>  l = [SELECT Name,Times_The_Lead_Is_Distributed__c,Hawaii__c,SV_Priority_Hidden__c, Id, AssignToUserId_Hidden__c FROM Lead WHERE IsConverted =false and Hawaii__c = false and To_Be_Distributed__c=true and DE_Synched__c=true and Is_Distributed__c =True];
integer x=0;
List<Team1__c> L1 = [SELECT Name,CheckIn__c From Team1__c Where CheckIn__c = True]; 
  integer i = L1.size();
integer z=1;
  for(Team1__c L2 :[SELECT Name,CheckIn__c,UserId__c From Team1__c] )
  {
  If(L2.CheckIn__c == True)
    {
     L2.UserId__c = z++;
 
     }
  else
  {
  L2.UserId__c =0;

  }
    update L2; 
  }
  for(Lead e : l)
  {
   x++;
  decimal y =  e.Times_The_Lead_Is_Distributed__c;
  e.AssignToUserId_Hidden__c = math.MOD(x, i) + 1;
  e.Is_Distributed__c =True;
   e.Times_The_Lead_Is_Distributed__c = y +1;
   update e;
  }

}
}


Hi,

 

I am getting the above error when I am sharing a lead through apex.

 

Scenario: I am creating a lead by logging in as Partner User. When the assignment rule checkbox is checked the created lead get assigned to another user. I wanted to share that lead with the created user ID(Partner user).  For this purpose, I wrote trigger. When the trigger get fired it is throwing the above exception.

 

How can I resolve it??

 

Thanks in advance!!