• ra811.3921220580267847E12
  • NEWBIE
  • 119 Points
  • Member since 2014

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 39
    Replies
We are looking for a part-time offshore developer to create 15-20 new Visual Force pages for a startup company.
Details will be provided later.  You must have 2-3 years of hands-on programming experience in Apex, VFP, Java Script, SOQL, etc.  Must sign an NDA (non-disclosure agreement).  Please contact us with your hourly rate and email address.
Hi All,

I need one developer who will be able work with me. The candidate must have experience on below modules.

1. APEX
2. Visualforce
3. HTML,CSS,Javascript
4. Salesforce Admin

Note:Price should be very low.

Thanks,
Ramesh
Hi, I tried reading up on static boolean variables and tried using them with not much success. Can somebody help how I can prevent recursive triggering in the below example? Many thanks!

First Trigger updates Invoice a dollar value equal to the sum of the dollar value from Permits which have a matching Invoice number. As below:

trigger InvoiceAmountUpdate on Permit__c (after update) {

for(Permit__c obj : trigger.new)
{
    List<Permit__c> permit = [select Total1__c from Permit__c p where p.Invoice_Num__c = :obj.Invoice_Num__c];

    decimal sum = 0;
    for (Permit__c p : permit) {sum = sum + p.Total1__c;}
    List<bb_Invoice__c> invoice = [select Invoice_Amount__c from bb_Invoice__c i where i.id = :obj.Invoice_Num__c];
    
for (bb_Invoice__c i : invoice) {
        i.Invoice_Amount__c = sum;
        update i;
    }
}
}

Second Trigger updates payment amount on Permits when the full invoice value is paid. However, with each update on Permit, the first trigger is called ending in a recursive pattern

trigger PaymentStatusUpdate on bb_Invoice__c (before update) {

for(bb_Invoice__c obj : trigger.new)
{
   if (obj.Paid_Amount__c>=obj.Invoice_Amount__c) {
    obj.Payment_Status__c = 'Paid';
   
List<Permit__c> permit = [select Total1__c,Paid__c from Permit__c p where p.Invoice_Num__c = :obj.id];

    for (Permit__c p : permit) {
        p.Paid__c = p.Total1__c;
        update p;
    }
    } 

    else if (obj.Paid_Amount__c>0) {
    if (obj.Paid_Amount__c<obj.Invoice_Amount__c) {
    obj.Payment_Status__c = 'Partially Paid';
    } 
    }
}

Hi,

I'm adding a field from a parent object on one of our apex classes and one the corresponding visualforce page. When I am navigating to the visualforce page I checked the error message "System.NullPointerException: Attempt to de-reference a null object".

The error seems to be coming from line 620 on the apex class -
offerSiteObj.Offer__r.End_Date__c = offerSiteList[0].Offer__r.End_Date__c;
But I can't see whats wrong with this - this is to allow the user to enter a value and then when they save it will save the value on the field on the parent object.

The field is then referenced on the vf page as:
<apex:inputField value="{!offerSiteList[0].Offer__r.End_Date__c}"/>

Does anyone know what is wrong here? Am I unable to reference a field from a parent object here?
Any help is much appreciated.

I have "Items" object with different statuses. I need to get the following output with single soql query.

Ordered Items: 10 
Cancelled Items: 3 
Reviewed Items: 2

VF Page and apex code below:
 
Ordered Items: <apex:commandButton value="{!Count}"/> 
Cancelled Items: <apex:commandButton value="{!Count}" /> 
Reviewed Items: <apex:commandButton value="{!Count}"/> 


Public Integer Count(){ 
        List<Items__c> items = [SELECT Count(ID) FROM Items__c WHERE Status == 'Ordered' OR Status == 'Cancelled' OR Status == 'Reviewed']; 
        return items.size(); 
}



With the above code ofcourse, I get the following output

Ordered Items: 15 
Cancelled Items: 15 
Reviewed Items: 15

Im calling the same method here, but I want to return differently based on the Status. I tried to use apex:param for the commandButton, but doesn't work.

Any ideas how to implement. [I want to use only 1 SOQL, with different SOQL and different methods, I can get what I want]

There is a date field, for inserting date of birth.

There is another button to calculate age (in days) which will be displayed below.

How to do that?

Hi there,
i am new to Apex triggers. I need to write a trigger for Opportunity object. The logic is when any update is made on opportuntiy object. means if a user make change to an opportuntiy object certain fields should be get update based on the value of other object Credit App.
Opportunity Fields to be updated:
1. Broker_Firm__c
2. Broker_Firm_Office__c
3. Primary_Contact_Role__c
I am trying to it thru this Apex trigger please let me know if i am doing soemthing because it is no compiling
trigger UpdateOpportunity on Opportunity (After update)
//Map broker related opportunity fields to keep credit App up to date.
{
Opportunity Opp = [Select broker_firm__c, broker_firm_office__c, primary_contact_role__c from Opportunity WHERE ID In:Trigger.newMap.keySet()];
Underwriting__c U=[Select Opportunity__c from Underwriting__c where Opportunity_Id__c =:Opp.Id];

For (Opportunity O:Trigger.new){        
                 U.broker_firm__c = o.broker_firm__c;
                 U.broker_firm_office__c = o.broker_firm_office__c;               
                 U.broker_name__c = o.primary_contact_role__c;
                 }
}
 
How to prevent Trigger to be fired after workflow field update? Any suggestions on this?
Hi,

Below is my code. Hope there is some mistakes while getting the errors string from the map for corresponding records.
 
Map<String, List<Account>> errorRecords = new Map<String, List<Account>>();
List<Account> accError = new List<Account>();
if((record.Discount_Type__c == 'Date Specified' || record.Discount_Type__c == 'Life Time') &&  opps.Coupon_Codes__c == null)
			            	{
		            			accError.add(record);
		            			errorRecords.put(' Please provide coupon code for the discount type specified!', accError);
			            	}
			            	else if(record.Discount_Type__c == 'Date Specified' && String.valueOf(record.Discount_End_Date__c) == null)
			            	{
		            			accError.add(record);
		            			errorRecords.put(' Please choose the discount end date in account before clone the new opportunity', accError);
			            	}


Here I am adding the error messages to record

for(String str : errorRecords.keySet()) 
		    {
	    		for(Account o : errorRecords.get(str)) 
	    		{
        			Account oAccErrors = accountNewMap.get(o.Id); 
        			oAccErrors.addError(str); 
	    		}
		    }
Error records is seperated perfectly but the error message is displaying as same. Thanks in advance
 
User-added image

Hi guys  I need to remove customer portal user from standard user look field and only show User and Partner user.Can you please suggest some solution to achieve it.
Hi there,

I have a trigger which I have wrriten to send emails to all the contacts that are the children of an account which a custom object record (service__c) is also the child of. The code is designed to trigger upon Last_emails_Sent (picklist) change. The picklist is changed from a time based work flow rule with rule criteria of '(Service: Service NameEQUALSIntensive Property Coaching) AND (Service: Start of ServiceNOT EQUAL TOnull)'. It updates the picklist at (40 days before end of service support, 1 hour before end of service support, 120 days after sstart of service and 240 days after start of service). For some reason, upon reviewing my mass email, 5 accounts came to expiry today and at 11pm last night, 5 emaiils were sent out to each associated contact. 

I am not sure what has caused this problem, any help would be very much appreciated. Particular to do with whether this is due to the time based workflow or the trigger. Thank you in advance for any hel that you may give me. Below is my code:
 
rigger SendEmailtocontact on Service__c (after Update)
{
    List<String> lcontactEmails = new List<String>();
    Set<Id> sIds = new Set<Id>();
//Added
    Set<ID> accIds = new Set<ID>();
    for(Service__c qItr : Trigger.new)
{
        if(Trigger.isUpdate)
  {
            if(Trigger.oldmap.get(qItr.id).Last_Email_Sent__c!= qItr.Last_Email_Sent__c )
   {
                sIds.add(qItr.id);
    //Added
    accIds.add(qItr.Account__c);
            }
        }
  //Will Never Execute as trigger will fire only if a record is updated
        else if(Trigger.isInsert)
  {
           
                sIds.add(qItr.id);
            
        }
    }
// Modified
    //for(Account accItr : [SELECT id,(SELECT id FROM Contacts) FROM Account WHERE id IN (SELECT Account__c FROM Service__c WHERE Id IN: sIds)])
for(Account accItr : [SELECT id,(SELECT id FROM Contacts) FROM Account WHERE id IN : accIds])
{
        for(Contact con : accItr.contacts)
  {
            if(!String.isBlank(con.id))
   {
                lcontactEmails.add(con.id);
            }
        }
       // No need to put this condition here.
  /*if(!lcontactEmails.isEmpty())
  {
   EmailHandler.sendEmail(lcontactEmails);
  }*/   
    }
//Put this here
if(!lcontactEmails.isEmpty())
{
for(Service__c serv : Trigger.new)
{       
 if(Serv.Accept_Mass_Emails__c  == True){

        //Email handler Updated
        if(Serv.Last_Email_Sent__c == 'IPC Support Expiry')
        {
        EmailHandler.sendSupportExpiryIPCEmail(lcontactEmails);
        }
        
        //Email handler Updated
        if(Serv.Last_Email_Sent__c == '120 days after IPC Support Start')
        {
        EmailHandler.send120AfterStartIPCEmail(lcontactEmails);
        }
        
        //Email handler Updated
        if(Serv.Last_Email_Sent__c == '240 days after IPC Support Start')
        {
        EmailHandler.send240AfterStartIPCEmail(lcontactEmails);
        }
        
        //Email handler Updated
        if(Serv.Last_Email_Sent__c == '40 days before IPC Support Expiry')
        {
        EmailHandler.send40BeforeExpiryIPCEmail(lcontactEmails);
        }
        
        //Email handler Updated
        if(Serv.Last_Email_Sent__c == 'Momentum Support Expiry')
        {
        EmailHandler.sendSupportExpiryMOMEmail(lcontactEmails);
        }
        
        
        //Email handler Updated
        if(Serv.Last_Email_Sent__c == '160 days after Momentum Support Start')
        {
        EmailHandler.send150AfterStartMOMEmail(lcontactEmails);
        }
        
        
        //Email handler Updated
        if(Serv.Last_Email_Sent__c == '320 days after Momentum Support Start')
        {
        EmailHandler.send300AfterStartMOMEmail(lcontactEmails);
        }
    
}    

}   
}
}

 

Hi, I desperatly need some help creating my first trigger and i'm a bit lost.
I'm trying to create a trigger on a custom object called wp_leads__c which looks up a field called code_entered__c against another custom object called wp_cid__c on a field called coupon__c.

If wp_leads__c. code_entered__c = wp_cid__c.coupon__c I want to update a tickbox field called matched_code__c in the wp_leads__c object with a tick.

Please help!

I am trying to write a trigger on task that queries the subject, and if it is equal to "Requalify", find the related account and related opportunity and change the opportunity status to "Re-qualify". I have the below trigger, but it is not changing the opportunity status. Any help would be greatly appreciated!

trigger TaskSubject on Task (after update, after insert) {

set<id> accountIdSet = new set<id>();
//capture all the subject names in a set
//set<string> subjectName = new set<string>{'Requalify'};
map<id, list<opportunity>> opptyMap = new map<id, list<opportunity>>();
list<opportunity> updateOppList = new list<opportunity>();

//get those tasks where the tasks are related to account. Capture the account IDs in a set.
for(task t: trigger.new){
            string tempId = string.valueOf(t.WhatId);
    if(tempId.startsWith('001')){
        accountIdSet.add(t.whatId);
    }
}

//If we have any account IDs then get the associated opportuity and store the one account to many opportunity in a map<id, list<opportunity>>
if(accountIdSet.size()>0){
    for(opportunity opp:[select Name, stageName, accountid from opportunity where accountid IN :accountIdSet]){
        if(opptyMap.containsKey(opp.accountId)){
            list<opportunity> oppList = opptyMap.get(opp.accountId);
            oppList.add(opp);
            opptyMap.put(opp.accountId, oppList);
        }else{
            list<opportunity> newOppList = new list<opportunity>();
            newOppList.add(opp);
            opptyMap.put(opp.accountId, newOppList);
        }
    }
}

//If we get the opportunities then change the stage.
if(Trigger.isUpdate && opptyMap.size()>0){
    for(task t: trigger.new){

 //Check if the subject of the task is one among the set 
 //and also confirm that the subject has been changed.

        if(t.subject != trigger.oldMap.get(t.id).subject && opptyMap.containsKey(t.whatId)){

  //iterate thru the list of the opportunity associated with that account 
  //and check which of the opportunity contains the task subject in the 
   //opportunity name and update the stage to re-qualify

            for(opportunity oppty: opptyMap.get(t.whatId)){
               {
                    oppty.stageName='Re-Qualify';
                    updateOppList.add(oppty);
                }
            }
        }
    }
}
if(Trigger.isInsert && opptyMap.size()>0){
     for(task t: trigger.new){
            if(opptyMap.containsKey(t.whatId)){
                for(opportunity oppty: opptyMap.get(t.whatId)){
                   if(oppty.name.contains(t.subject)){
                      oppty.stageName='Re-Qualify';
                      updateOppList.add(oppty);
                   }
               }
            }
        }
    }
//update the oppties
if(updateOppList.size()>0){
    update updateOppList;
}
}
Hi,

I have created the following trigger on caseComment.

if(Trigger.isBefore && Trigger.isDelete)
{
cls_Case_Comment.CheckAssignedPermissionSet(trigger.old);
}
}

Below is the Helper Class:
Public with sharing class cls_Case_Comment {

Public Static Void CheckAssignedPermissionSet(List<CaseComment>newList)
{
/* This Method is used as Helper Method for trigger trg_Case_Comment 

Set<String>str_set= new Set<String>();
String profile_Name =[SELECT Name from Profile where Id=:UserInfo.getProfileId()].Name;   

List<PermissionSet>lst_PermissionSet = [SELECT Id, Name from PermissionSet where ID in ( SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId =:Userinfo.getUserId())];

for(PermissionSet ps:lst_PermissionSet){
str_set.add(ps.Name);
}

for(CaseComment cs:newList)
{
         if(profile_Name!='System Administrator'){
         if(!str_set.contains('Delete_cases'))
           {
                cs.addError(system.label.trg_cls_Case_Comment);
           }
         }

}

}

}

Everything is Working Correctly except on Deleting the CaseComment, I am getting a null value.

Error message is displaying correctly
User-added image
Hi

We are seeing a difference in the number of lines of code shown in the developer console after running the test. The code has only 488 lines but the right hand panel shows that it has 675 lines and only 435 are covered. I have compiled the code and have waited for a couple of days to check if it is a temporary issue and nothing seems to change. This is in production.
User-added image