• imutsav
  • SMARTIE
  • 750 Points
  • Member since 2013

  • Chatter
    Feed
  • 24
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 181
    Replies

I am getting an error "execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Class.DecalsController.OnAfterUpdate: line 39, column 1".. Below is my controller. Could someone please help?

 

Controller:

public with sharing class DecalsController {
    public DecalsController(boolean triggerIsExecuting, integer size){
    }
    public void OnAfterInsert(Payment__c[] newPayments){
        
      try{      
        For(Payment__c pa:newPayments)
        {   
        system.debug('**********id*********************'+pa.Decal__c);
         List<Payment__c> b = [select id ,Decal__c,Amount_Paid__c from Payment__c where Decal__c=:pa.Decal__c];    
         system.debug('**********payments*********************'+b);
          Decals__c dcc   = new Decals__c();
          dcc.id        = pa.Decal__c;
          Double A=0;
          for(Payment__c py : b){
        
          A= A + Integer.valueOf(py.amount_paid__c);
          dcc.Total_Amount_Paid__c = A;
          system.debug('*************Balance****************************'+A);
          }
          update dcc;
            }
      }catch(DMLexception e){}      
     
    }
    public void OnAfterUpdate(Payment__c[]oldpayments, payment__c[] updatePayments){
        
      try{      
        For(Payment__c pa:updatePayments)
        {   
        system.debug('**********id*********************'+pa.Decal__c);
         List<Payment__c> b = [select id ,Decal__c,Amount_Paid__c from Payment__c where Decal__c=:pa.Decal__c];
        
          Decals__c dcc   = new Decals__c();
          dcc.id        = pa.Decal__c;
          Double A=0;
          for(Payment__c py : b){
         
          A= A + Integer.valueof(py.amount_paid__c);
          dcc.Total_Amount_Paid__c = A;
         
          }
          update dcc;
            }
      }catch(DMLexception e){}      
     
    }
    }

 Trigger

trigger DecalsTrigger on Payment__c (after insert,after update) {

 DecalsController handler = new DecalsController(Trigger.isExecuting, Trigger.size);

 if(Trigger.isInsert && Trigger.isAfter){
 handler.OnAfterInsert(Trigger.new);
 }
 else if(Trigger.isUpdate && Trigger.isAfter){
 handler.OnAfterUpdate(Trigger.old, Trigger.new);
 }
 }

 

 

  • May 03, 2013
  • Like
  • 0

Greetings.

I have a custom object with a trigger after insert type, this object is called Policy__c once saved you must create a new custom object, Cetificate__c, the problem is that the trigger executes, but not created Certificate__c.

trigger applyCertificadosTrigger on Policy__c (after insert) {
   Policy__c[] policies = Trigger.new;
   createCert.applyCert(policies);

} 


public class createCert{


public static void applyCert(Policy__c[] policies ) {
 integer  cont=0;
 integer sip=policies.size(); 
 
   for (cont=0; cont<sip; cont++ ){
 
       Certificate__c cert= new Certificate__c(
                                        Comission__c=30.00,
                                        Description__c='123456'

                                             );
    insert cert;

}
 
}

}

 thanks.....

 

I tried the code Imutsav, not throw exceptions, I can' t  just insert the certificate, perform a test with the example http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_qs_trigger.htm
for object Policy__c, this worked, just not inserted.  I wish to attach the certificate in the policy.

 

thanks....

 

  • April 08, 2013
  • Like
  • 0

please any one tell the process of moving app sandbox to producction?  and how to create sandbox and production and change sets ?

in a visual force page the save should ensure the data to be be stored in current object as well as associated child object

Can we call web services through trigger?

Custom settings and labels adv?

 

What are the Attributes for apex:page

Can we Use triiger.newmap for before insert event or not?

how to get the recent deleted records using query?

Hi all

 

I have a new record type(appointed) in a custom object named DFS. I need to send the mass emails to that record type list. Please let me know if there are any ways.

 

Thanks

  • March 25, 2013
  • Like
  • 0

Hi,

 

I need to display an error message when one of the fields is null. 

 VF Page :

 

<apex:page controller="conAddmailsIds" sidebar="true" showHeader="true" >
<apex:pagemessages/>
<apex:pageBlock id="block">
<apex:pageBlockSection >
<apex:panelGroup >
<center>
<apex:selectList id="select" value="{!selectId}" size="1">
<apex:selectOptions value="{!autoRun}" />
</apex:selectList>

<apex:inputText id="searchText" value="{!searchText}"/>
<apex:commandButton value="Search" action="{!getAllEmployees}" rerender="searchResult" status="status"/>
</center>

<apex:commandButton value="Hierarchy" action="{!getEmpHierarchyData}" rerender="searchResult" status="status"/>

</apex:panelGroup>
</apex:pageBlockSection>
<apex:messages/>

<apex:actionStatus id="status" startText="Searching... please wait..."/>

--------

</apex:page>

 

Controller:

 

public PageReference getAllEmployees(){
if(searchText == '' || searchText == null){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Add your message here');
ApexPages.addMessage(myMsg);
return null;
}

......

 

I have tried with both apex:messages and apex:pagemessages, still nothing is working. Is there any page level settings to be done?

I am not able to figure out why the error message is not getting printed. Is there anything else i need to do here?

 

Thanks in advance!

 

Regards,

Manasa R

Hi, 

 

 There is a custom field called Deal Registration in oppertunities which is a lookup field, My Requirement is to make the field to read only. Please suggest me how to make to readonly. 

 

Thanks

Sudhir

Hi

 

    I am doing test method. I am struck with 65%. I am in need of help for the following

 

public string splashRun{
get{
Date dateValid = date.today();
Date todayDate = date.newInstance(dateValid.year(),dateValid.month(),dateValid.day());
string UserId = Userinfo.getUserId();
User userLogin = [select LastLoginDate from User where Id = :UserId];
DateTime lastLogin = userLogin.LastLoginDate;
Date loginDate = date.newInstance(lastLogin.year(),lastLogin.month(),lastLogin.day());

if(loginDate == todayDate){

splash = [select Name, Flag__c, Visit_Date__c from Splash_Data__c where Name = :Userinfo.getUserId()];
if(splash[0].Flag__c == 0){
splashRun = 'true';
}
else if(splash[0].Flag__c == 1){
splashRun = 'true';
}
else if(splash[0].Flag__c == 2){
splashRun = 'false';
}



}
return splashRun;
}
set;
}

 

 

 

How to accomplish test method for the above.. I write like this in multiple areas

 

I would like to if Multicurrency feature is supported for Custom Objects as well or is it available only for standard objects ?

From the documentation I see following, 

Objects that support multiple currencies include Opportunities, Opportunity Products, Opportunity Product Schedules, Campaign Opportunities, and reports related to these objects and fields

Does this mean custom objects don't have multiple currency support ?

Could someone confirm if multiple currency is supported for Custom objects as well ?

Thanks,

  • March 12, 2013
  • Like
  • 0

We have a contact lookup field in our Opportunity. How do we create an Opportunity report that can pull data from the contact fields associated to our lookup?

 

HI

 

I want to share reports with my boss.  I do not want my boss to be able to make edits/changes or run reports at will.  What is the best way to handle?  Should we set him up with Chatter?  Will that allow me to have scheduled reports for him?  Or can I email him scheduled reports?  He is not a SFDC user as of now.

 

 

Please suggest me.

 

Thank you

  • March 11, 2013
  • Like
  • 0

This is a very annoying thing when running demos on new computers... Is there a setting to turn it off?

Thanks

Just realized that opportunity owners are not being updated when the account owner changes.  Our system of record is an external system, so all ownership changes are done through the ASI.  I found an old post indicating this has been happening since 2009.  Does anyone have an automated example of how to do this?  I can add all these changes to a trigger, but I thought salesforce automatically handled this for active opportunities.

 

  • February 26, 2013
  • Like
  • 0

Hi

 

I have a custom object named broker_c.  We developed a visualforce page asking for the customers first name, last name , phone number and email id. Once the customers clicks on submit in the visualforce page link, all the details must be imported into the 'broker_c' custom object. This can be done by web-to-lead form, but these customers are that the leads for my company. 

 

So please let me know the solution to integrate the visualforce page details into the custom object. i figured out that the custom object 'broker_c' is going to be the standard controller in the visualforce page. But what would be the next step?

 

Please help me with coding. 

 

  • February 25, 2013
  • Like
  • 1

Does anyone know how many detail relationships can a master object have?

 

Is there a limit for that?

When I select "Accounts", a list of recently access accounts shows in a list. That list shows across: name of account, account phone number, record type and primary contact. 

 

Althought I have created a Contact under the Account and noted it as Primary, it still does not pull to this screen. 

 

Per someone in the other forum, "The field displayed on the "recent account: list is on the Account. The primary contact I am setting is on the Contact".

 

Any idea or help would be appreciated!

I need help writing a REGEX Validation rule.

 

Condition:

                  Filed Name - TestNo

                  Field length  - 23 characters

                   No of values in the field - 4 values with 5 characters (only numbers) seperated by commas.

                  Eg: 12345,23456,12356,23456

 

I need a validation rule that makes sure the TestNo(s) are 5 digits and separated by commas with no spaces

 

Can someone help me in building a formula using REGEX or some other function.

Hello,

 

I'm totally new to Apex Triggers, but I believe I have a good mental map of what needs to happen to overcome my 'issue'.

 

I have Opportunity (1-1 with Accounts for our org), Sequoia_Service_Level__c, and Accounting__c objects. I'd like to 'call' the trigger by way of a button, since I need to create all Accounting__c records before executing this logic.

 

I need to take the total count of Accounting__c records in the given month, and pro-rate an amount found on the Opportunity (called Revenue_Opportunity__c, which is a roll-up summary of the field "Total_Invoice_Amount__c" on the Current_Service_Level__c object).

 

For instance, if I had 3 Accounting__c records, with a Revenue_Opportunity__c of $10 from the related Opportunity object, each accounting object would be given the value 3.3333... Then, that 3.333 should be set to the field Accounting__c.Baseline_Service_Amount__c.

 

Accounting__c objects have a lookup relationship to Opportunities and Accounts, and all have a related Sequoia_Service_Level__c as well.

 

Is this pretty straightforward stuff? Or will this be quite difficult? I'm already finding invoices for the current month via a report (which is then PDF'd using CongaComposer), but I figured I could not take advantage of that with an Apex Trigger?

 

Any guidance is appriciated!

 

Charlie

 

  • May 14, 2013
  • Like
  • 0

We have a VF page that overrides the tab for a custom object. This page can be viewed in 2 modes: 1) without parameters in url, 2) with parameters in url. Both modes can be accessed fine by AdminUser1, but AdminUser2 can only access the page without parameters. Once she puts in *any* parameter she gets an "Insufficient privileges" error.

 

I tried removing everything from the VF page (actually reduced to 2 lines) but the behaviour didn't change. In the controller for the page there's zero logic around the parameter that's being passed. Moreover, like I said, this error occurs with *any* parameter even if it's some garbage character.

 

Any ideas what's going on?!

I have a VF page laid out as such: 1st column: checkboxes, 2nd column: Account Name, 3rd column: Contact Lookup field.

 

Checkbox |  Account Name |  Contact Lookup

                      Company A          Return Contacts From Company A

                      Company B          Return Contacts From Company B

                      Company C          Return Contacts From Company C

 

The problem I am trying to solve is for each line, I only want to return the contacts for the respective company. I.E. if I click on the lookup filter on the Company A line, I should only be returned the contacts for Company A.  If I click the lookup filter on the line for Company B, I should only be returned the contacts for Company B.  

 

Any help provided would be awesome!!! Thanks 

                      

 

 

I am trying to write a formula that says, if the "One Year from original contract date" field is less than today then display the green flag; otherwise display the red flag.

 

The One year original contract date field is a date formula field (Original_Start_Date__c + 365). 

 

This is what I've written so far but it's not working.  Can someone help me?

 

IMAGE (
IF ( One_Year_from_Original_Contract_Date__c < TODAY()),"/img/samples/flag_green.gif",
"/img/samples/flag_red.gif" )

Hi,

 

I need a custom button display on my standard page layout. When I click this button can send mail to some users.

So I create a custom button, and in the "Behavior" field, I choose "Execute JavaScript". Then I try to invoke my remote action to send maill.

 

if(confirm('Is your Distribution list updated ?')){
    alert('send');
    AuditController.saveAudit(auditData , SaveCallBack, {escape:true});
}
else{
    alert('just save');
}

function SaveCallBack(result, event){
    alert(1);
}

 

But it fail. When code go to the ture condition. There is a error tell me AuditController is not defined.

 

So does anyony know how to send mail by a custom button on the standard pagelayout?

 

Thank you!

When a parent Case gets updated, how can I set up a trigger to update all the childcases? I don't need to update any of the fields on the child, just need the modified date to change.

 

Here is what I have so far but it is not working correctly.

 

trigger updateRelatedCasesfromParent on Case (after update) {
    
If(Trigger.isUpdate){
     
    Set<ID> ids = new Set<ID>();
     list<Case> updatedParents = [SELECT Id, reason FROM Case 
                 WHERE Id in :ids];
     List<Case> childrenToUpdate = new List<Case>();

         //Then loop through each parent object in 'updated parent
         for ( Case p : updatedParents) 
         { 
                //and loop thru each kid in the child set}
               for(Case kid : p.Cases) 
               { 
                    childrenToUpdate.add(kid);
                }
        }
       //if( !childrenToUpdate.isEmpty)
       //{
            update childrenToUpdate;
       //}
}
}

 Thanks for the help.

  • May 08, 2013
  • Like
  • 0

I have 2 objects (A & B) related using Lookup relationship and I have a trigger on after insert on object A which creates record on object B. - Upto this stage everything is working fine. My issue is - I have the following fields in object A -

 

  1. Number of Installments
  2. First Installment Date
  3. Total Amount Due

If a user enters Number of Installments as 4, First Installment Date 5/15 and Total Amount Due $4000.00

Then

I would like to divide Total Amount Due by Number of Installments ($4000/4=$1000) and create 4 records of $1000 each in the object B. Also, the Payment Due Date in object B should set to 5/15, 6/15, 7/15 and 8/15.

 

Any help would be appreciated. Thanks.

  • May 08, 2013
  • Like
  • 0

Hi

 

     This is my custom text template code,i load the image in Documents and copy the image url and paste in src.But i didnt receive the images in my email ,just it shows text only........How to solve this?

 

     <img src=”https://na5.salesforce.com/servlet/servlet.ImageServer?id=01570000001G1nR&oid=00D70000000XXXX” alt=”My test image” height=”179” width=”702“/>

 

Thanks

==========

VenaktSforce

Hi,

I am new to salesfroce, so I'm trying to develop a simple piece of code but I'm having some issue with it, any help is trully appricated.

 

here is what I want, I have two objects Class__c  with fileds NumberOfStudents(RollUP field), Name, MaxLimit (Number)and Studebt__c has field FirstName__c, LastName__c , id.  here what I am doing :

* =================================================================================

    Trigger to restrict user to insert records if the max limit of calss has reached
   
   ================================================================================= */

trigger StudentBeforeInsert on Student__c (before insert) {
    set<id>stids= new set<id>();
        for(student__c stu: trigger.new){
            stids.add(stu.id);
        }
    list<student__c> std = new list<student__c>();
    std =[select class__r.name from student__c where id in :stids];
    set<student__c> stSet = new set<student__c>();
        stSet.addAll(std);   
    system.debug('From Data Loader====  :'+ std);
    List<class__c> cls = new list<class__c>();
    cls=[select MaxLimit__c,NumberOfStudents__c from class__c where name =:stSet]; get error at thisline as Invalid bind expression type of SOBJECT:Student__c for column of type String at line 19 column 69

basic idea I have is I want to find the NumberOfStudent already in the class and the maxList of the class and then to compare these two filed for which the user is trying to insert the record in student record. if value in both the field is asme then it will not allow to insert any record, or else it will go ahead with inserting record into the table.

 

Please give me some suggestion, so that I can learn and code

 

Thanks in Advance.

  • May 06, 2013
  • Like
  • 0

HI 

 

Am new to the Validation Rules. Am trying to Make the Lead Status Non Editable using a Validation Rule "ISCHANGED( Status )".. its working fine.. But the problem is, when i try to convert the lead to Opp the status will change to "Warm/Samples Sent" and there throws the Error. I could't able to convert the lead to Opp.

 

ThankU

I have a VF page that uses a custom object that has a master/detail relationship to account. 

 

I want to use this VF page as a button on the account page.  I need to account ID to drive my VF page.  If I convert from a standard controller to a custom controller will I be able to access this VF page from an account?

 

  • May 03, 2013
  • Like
  • 0

Hello everyone!

 

I'm new to salesforce and need some help recognizing sales and tracking inventory with Products that have sales/quantities spread across numerous months.

 

Here is my problem: Each Month we can only sell 25 units. I'm trying to track the number of units we've sold, and project which months still have available units. 

 

Note: Each Opportunity Project is 1 unit. However, I'm having difficulty when it comes to Opportunity Projects that have a Schedule assigned to them. For example, one of the products we provide is a 3 month subscription. This means we sell 1 Unit for each month: (if we sell the subscription on 1/1/13, this accounts for 1 unit in Jan, 1 unit in Feb, and 1 unit in March)

 

I would like to know if it is possible to get the quantity of product opportunities for each month specifically for those products that use revenue and quantity schedules. I want to know how many Opportunity Products are active in each month. 

 

Please let me know if this makes any sense. ABSOLUTELY any help would be so sincrerly appreciated!

 

Thank you!