• Sandeep001
  • NEWBIE
  • 300 Points
  • Member since 2008

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 98
    Replies
I found this trigger and it seems that one of the past developer is doing an update  of an opportunity within the trigger instead with the class.

From what I understood, that the class will still be executing eventhough after the record page has been updated and reloaded for the end-user? Never experience this before, how about anyone here?

trigger Opp on Opportunity (after update) {
    for (Integer i = 0; i < Trigger.old.size(); i++) {
        Opportunity old = Trigger.old[i];
        Opportunity nw = Trigger.new[i];
        Boolean man = false;
      
        if ((nw.Probability == 100) && (old.Probability != nw.Probability)) {
      
            oppClose.createCase(nw.Id, man);
            //Clone statuses indicate different follow-up actions for people.
            if (nw.Clone_Status__c != 'Completed' && nw.Clone_Status__c != 'Non-renewable' && nw.Clone_Status__c != 'Exception') {
            oppClose.cloneOpp(nw.Id);
          
            /*Clone Status field is updated from the trigger instead of the the class. The class runs asynchronsously (ie. in the future)
            * so the results do not show up immediatley in the Opp after closing it won and returning to the saved record.
            * By updating the field in the trigger a flag is set to alert the user and to prevent a subsequent update from
            * triggering the class again if the async execution is delayed.
            */
            Opportunity opp = new Opportunity(
            Id = nw.Id,
            Clone_Status__c = 'Completed');
            update opp;
            }
        }
    }
I was wondering if there was any more customizing we can do for Salesforce. We would like to change the color schemes, the tabs at the top, etc. Is there a way to do that or is it kind of set in stone.

So I've come to realize that there are two errors that I am learning to dislike very much...

1)  Easilly the one I dislike the most is:  "System.NullPointerException: Attempt to de-reference a null object"

2) The second has become:  Save error: Constructor not defined: [ApexPages.StandardController].<Constructor>(xxxxx)

 

I've just written a half dozen or more Test Classes using the same syntax for creating the constructor in my test method but for some reason, this one is giving me a fit.

 

This class is an extension class.  Is there something I need to do different? The constructors in all my classes are set up almost identically so I would assume creating them in my test class would be as well.

 

public with sharing class taskMyDelegatedView {
	
	public Id tskId {get;set;}	
	public Id uID {get;set;}
	public String iView {get;set;}
	
	
	private ApexPages.StandardController controller;
	public taskMyDelegatedView(ApexPages.StandardController stdController) {
      controller = stdController;
   }
	
	Id currentUserId = userinfo.getUserId();	
	   
	public List<Task> getMyDelegatedTasks() {
        return [SELECT id, Subject, Description, Status, WhatId, What.Name, Owner.Name, OwnerId, CreatedBy.Name, CreatedById, ActivityDate, Task_Due_Date__c, LastModifiedDate FROM Task WHERE CreatedById =: currentUserId ORDER BY LastModifiedDate];        
    }
    
   
   String result='Click on a task subject to preview the latest notes.';
   public String getFetchedData() {
   		return result;
   } 
   
   public PageReference invokeService() {
   		Id id = System.currentPageReference().getParameters().get('id');
   		result = [SELECT Description FROM Task WHERE Id=:id].Description;
   		return null;   	
   }
   

    public static Task testTsk;
    public static taskMyDelegatedView testTaskMDV;
    public static Task_Informed_Users__c testInformedUser;
    public static User testUserId;
        
    static testMethod void informedUserListTest() {    	
    	Test.startTest();    		
    		
	    	testUserId = [SELECT ID FROM User WHERE LastName=: 'User2'];
	    	System.Debug(testUserId);
	    	
	        testTsk = new Task(Subject='testTask', description='ABC', ownerId=testUserId.Id); 
	        insert testTsk;
	        System.Debug(testTsk.Id);	        
	       	        
	            
	        testInformedUser = new Task_Informed_Users__c(Informed_user__c=testUserId.Id, Task_ID__c=testTsk.Id, Chatter_Notification__c=FALSE, Send_Email__c=FALSE);
	        insert testInformedUser;
	        System.Debug(testInformedUser.Id);

	        
	        Test.setCurrentPage(Page.delegatedTaskView);
		ApexPages.currentPage().getParameters().put('Id',testTsk.Id);
			
		ApexPages.Standardcontroller con = new ApexPages.Standardcontroller(testTaskMDV); //ERROR HAPPENING HERE
		taskMyDelegatedView tTMDV = new taskMyDelegatedView(con);
	        
	        system.runas(testUserId) {
				

		}
        
        Test.stopTest();        
    }


}

 

Hello,

 

I have a trigger on the Asset object which inserts two Account IDs into two Lists.  One ID is for a Business Account, the other is for a Consumer Account.  Both are correct when looking at the debug log.  The issue I am facing Is I when I go to select an External ID from using the SOQL statement below, it only returns unique values.  An example would be if I have a total of 20 new Assets coming in, with 3 distinct Business Account IDs and 15 distinct Consumer Account IDs, the List of Accounts will only have the 3 and 15 values.  I need it to be populated with all Accounts being updated/inserted.

 

 

trigger Update_Registering_Dealer on Asset (after insert, after update)
{
    List<String> accIds = new List<String>();
    List<String> consIds= new List<String>();
    integer count = 0;
         
    for(Asset a : Trigger.new) 
    {      
            if (a.Type__c == 'Registration')
            accIds.add(a.AccountID);  
            system.debug('AccountID: ' + a.AccountID);
            consIds.add(a.Consumer__c);
            system.debug('Consumer: ' + a.Consumer__c);
            count ++;
    } 

List<Account> accsAssets = [Select a.Account_Number__c From Account a where a.Account_Status__c='Active' and Id IN :accIds];
List<Account> consumerAccount = [Select Registering_Dealer__c From Account where Account_Status__c ='Active' and Id IN :consIds];

 

The business goal here is to pull the External ID from the Business Account, onto the Consumer Account so we can identify where the Consumer purchased their last product.

 

Thank you in advance.

 

is it possible to not be able to query fields of a custom object?

when i run:   select Project_1__c from Leave_Application__c  ----it returns the id of the projects

but when i run:    select Project_1__r.name from Leave_Application__c  ----it doesnt return the name of the projects but the result of total rows are the same.


PS. i tried to run this in the query editor in developer console.

 

Hi,

 

I wrote the trigger for sending email with email template .


I need to send some persons as in CC address.

 

The Following is my trigger, Is there an possiblity to add ccaddress in that code. I also want to set orgWideAddress when it is equal to the value in CaseEmail__c.

 

Please help me.

trigger mailnotification on Case (after insert) {
for(case c:trigger.new){
EmailTemplate etc =[SELECT id from EmailTemplate where Name =:'Case Email to Customer'];
If((c.ContactId != null ) ||(c.SuppliedEmail != null)){
Messaging.SingleEmailMessage m = new Messaging.SingleEmailMessage();
m.setTemplateId(etc.id);
for( OrgWideEmailAddress owa : [select id, Address, DisplayName from OrgWideEmailAddress]){
If(owa.Address==c.CaseEmail__c)
m.setOrgWideEmailAddressId(owa.id);}
String userEmail = c.CaseEmail__c;  
m.setReplyTo(userEmail);
m.setTargetObjectId(c.contactId);
m.setWhatId(c.id);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { m });
}
}
}

 

I am new to writing VF pages. I have a VF page and Apex Class that I have written to override the NEW button for my custom object.  However, all that displays are the buttons at the top and bottom of the page, no fields.  Can anyone take a look and point me in the right direction to correct my issue?

 

Thank you

 

VF Page - 

<apex:page standardController="STG_Payment_Requests__c" extensions="ContentNewSTGPR">
<apex:sectionHeader title="STG Payment Request" subtitle="{!STG_Payment_Requests__c.name}"/>
<apex:form >
<apex:pageBlock title="New STG Payment Request">

<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Update" action="{!quicksave}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>

<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Update" action="{!quicksave}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>

<apex:pageBlockTable value="{!STGPR}" var="a" id="table">

<apex:pageBlockSection title="Information" columns="2">

<apex:outputField value="{!a.Account_Name__c}"/>
<apex:pageBlockSectionItem />
<apex:outputField value="{!a.Name}"/>
<apex:inputField value="{!a.Quantity__c}" required="true"/>
<apex:outputField value="{!a.STG_Promotion__c}"/>
<apex:outputField value="{!a.Payment_Amount__c}"/>
<apex:outputField value="{!a.Lane_Vendor_Number__c}"/>
<apex:inputField value="{!a.Reference_for_remittance__c}" required="false"/>
<apex:outputField value="{!a.Promoted_Brand__c}"/>
<apex:pageBlockSectionItem />
<apex:outputField value="{!a.Promotion_Type__c}"/>
<apex:pageBlockSectionItem />
<apex:outputField value="{!a.Promotional_Rate__c}"/>
<apex:inputField value="{!a.Comments__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Manager_Approved__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Senior_Manager_Approved__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Director_Approved__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.File_Attached_to_Payment_Request__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Paid__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:OutputField value="{!a.Paid_Date__c}"/>

</apex:pageBlockSection>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Apex Class -

public class ContentNewSTGPR {

public ContentNewSTGPR(ApexPages.StandardController controller) {

}


public List<STG_Payment_Requests__c> STGPR {get; set;}

public ContentNewSTGPR(){
STGPR = new List<STG_Payment_Requests__c>();
STGPR.add(new STG_Payment_Requests__c());
}

public void addrow(){
STGPR.add(new STG_Payment_Requests__c());
}

public PageReference save(){
insert STGPR;
PageReference home = new PageReference('/home/home.jsp');
home.setRedirect(true);
return home;
}
}

Hi, I wanted to know how these two version differ? I noticed that some of my apex classes use version 25 and some of my triggers 25 or 27? We are taking project from sandbox to production, so I'm thinking should I update these or ?

I want check if my object after changes it's fields values in code will fire workflow rule.
Is it possible?

i am able to save mutiple records at once but all the records are the same even if i selected/typed different values in each row. it is only saving the values from last row but the dates on the Leave_Date__c are working fine.

 

for example this is what i typed:

 

                Id                               Date           Remarks          Days Off

a3He00000000ktX            09-05-13              A                    Whole

a3He00000000ktX            09-06-13              B                    Half

a3He00000000ktX            09-07-13              C                    Quarter

 

 

these are the records saved:

                Id                               Date           Remarks          Days Off

a3He00000000ktX            09-05-13              C                    Quarter

a3He00000000ktX            09-06-13              C                    Quarter

a3He00000000ktX            09-07-13              C                    Quarter

 

 

 

codes:

<apex:pageBlockSection title="Details" columns="2" rendered="{!showDetails}">
  <apex:pageBlockTable value="{!listOfDates}" var="date" width="500px">
       <apex:column headerValue="LeaveDate"  style="padding: 0px 30px 0px 30px;">
             <apex:outputText value="{0,date,EEE  MM/dd/yyyy}">
                            <apex:param value="{!date}" />
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="With Pay">
                    <apex:inputField value="{!newleavedetail.WIth_Pay__c}"/>
                </apex:column>
                <apex:column headerValue="Leave Application Id">
                    <apex:outputText value="{!leave.id}"/>
                </apex:column>
                <apex:column headerValue="Day/s Off">
                    <apex:inputField value="{!newleavedetail.Day_s_Off__c}"/>
                </apex:column>
                <apex:column headerValue="Project">
                    <apex:inputField value="{!newleavedetail.Project__c}"/>
                </apex:column>
                <apex:column headerValue="Remarks">
                    <apex:inputField value="{!newleavedetail.Remarks__c}"/>
                </apex:column>
            </apex:pageBlockTable><br/><br/>
            <br />
           </apex:pageBlockSection> 

 

public List<Date> listOfDates{get;set;}

public lad__c newleavedetail {get; set;}
public la__c leave {
      get {
        if (leave == null)
          leave = new la__c();
        return leave;
      }
      set;
    }

public LeaveCC(ApexPages.StandardController controller) {
    listOfDates = new List<Date>();      
    newleavedetail = new lad__c();        //used for saving details
    }



public PageReference savedetail() {
        try {
            for(integer x=0;x < listOfDates.size();x++){
                Datetime d = listOfDates.get(x);
                lad__c leavedetail = new lad__c();
                leavedetail.Leave_Application__c = leave.Id;
                leavedetail.Day_s_Off__c = newleavedetail.Day_s_Off__c;
                leavedetail.WIth_Pay__c = newleavedetail.WIth_Pay__c;
                leavedetail.Project__c = newleavedetail.Project__c;
                leavedetail.remarks__c = newleavedetail.remarks__c;
                
                integer year = integer.valueof(d.format('yyyy'));
                integer month = integer.valueof(d.format('MM'));
                integer day = integer.valueof(d.format('dd'));
                leavedetail.Leave_date__c = date.newinstance(year, month, day); //listOfDates.get(x);
                leaveAppDetailList.add(leavedetail);
            }
            insert leaveAppDetailList;
            
        } catch(Exception e) {
            apexPages.addMessages(e);
        }
        PageReference leaveapppage = new PageReference('/'+leave.id);  
        leaveapppage.setRedirect(true);
        return leaveapppage;
    }

 

 

help!

Hi,

I'm haveing requriment like : There are two accounts A1 and A2,A1 having one open opportunity and A2 having one open opportunity when I try to merge A1 and A2 error should throws

 

for this i need to write trigger to merge account with conditions with custom button.

I am trying to create a test class for a new trigger and it involves a lookup to a user record.  In my test class, do i have to create a new user entry, or is there a way to to reference any existing users in the org for the test? 

I have this:

PageReference retPage = new PageReference('/' + changeID + '/e?00Na000000BA4Ip=Rejected&00Na000000BA4IU=True&00Na000000BA4IW=UserInfo.getName()&00Na000000BA4IV=');

 This needs to equal the current date and time.  How do I accomplish that?

00Na000000BA4IV=

Hi,

 

Is there any difference in:  between System.trigger.new and Trigger.new

 

-Kaity.

I've never built a Apex Service....  Below is a description of what I'm trying to do.  I will give kudos to anyone that contributes.

 

Do you have any info on Apex Services?

 

 

What I need is a way to look at the contracts and create a new contract 60 days before the previous contracts end date.

 

I have the code that will build the follow up contract, what I don't have is a way minus using Time Based Workflow to query all contracts that are in the window of renewal of Maint or expiration and create new contracts for those that are 60 days out from expiration.

 

Any ideas?

 

Thank you,

Steve Laycock