• gregj777
  • NEWBIE
  • 105 Points
  • Member since 2008

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 31
    Questions
  • 54
    Replies

I have the below apex trigger in place but it doesn't see me to be refreshing the filed when the data changes. Can anyone help me  figure out what I need to add to make sure  that operation happens. Something needs to be missing.

 

trigger updateContract on Opportunity (before Update) {

set<id> contIds = new set<id>();
list<contract> listcon = new list<contract>();
set<id> oppIds = new set<id>();
Double InitialSum ;

For(Opportunity o :trigger.new)
{
contIds.add(o.contract__c);
oppIds.add(o.id);
}

Map<id,contract> MapofCons = new Map<id,contract>([select id, name,Total_Opportunity_Amount__c from contract where id in :contIds]);
Map<id, opportunity> MapOfOpps = new Map<id,opportunity>([select id,name, amount from opportunity where id in :oppIds]);
For(opportunity o: trigger.new)
{


If( MapofCons.get(o.contract__c).Total_Opportunity_Amount__c ==null)
InitialSum = 0 ;
else
InitialSum = MapofCons.get(o.contract__c).Total_Opportunity_Amount__c;

If((MapOfOpps.get(o.id).amount==null)&& (o.amount!=null))
{ MapofCons.get(o.contract__c).Total_Opportunity_Amount__c = InitialSum + o.amount;
Listcon.add(MapofCons.get(o.contract__c));
}
else If((MapOfOpps.get(o.id).amount!=null)&& (o.amount==null))
{ MapofCons.get(o.contract__c).Total_Opportunity_Amount__c = InitialSum ;
Listcon.add(MapofCons.get(o.contract__c));
}
else
{
if(mapofOpps.get(o.id).amount != o.amount)
{ MapofCons.get(o.contract__c).Total_Opportunity_Amount__c = InitialSum + o.amount- mapofOpps.get(o.id).amount ;
Listcon.add(MapofCons.get(o.contract__c));
}
}
}
update Listcon;

}

 

Can anyone help me with this frustrating issue. I am developing an application where I want to relate a number of opportunities with a contract and have the abilitiy to total sum the opportunity amounts and count the opportunities against this contract. I can't believe this can't be done. Am I the first person that's tried to do something like this?

I am trying to setup a validation rule but when the picklist  field is populated with ---None--- it will allow to save. See below. What do you need to add to the formula so you can save it.

 

Rule NameError_message_on_SE_Pkg_typeActiveChecked
Error Condition FormulaOR(ISPICKVAL(Type, "KSYMP Pkg - Single Event"), 
ISPICKVAL( Type,"Road Show Pkg - Single Event"), 
ISPICKVAL(Event_Package__c, "2012 KSYMP Custom"), 
ISPICKVAL(Event_Package__c, "2012 KSYMP Gold 30"), 
ISPICKVAL(Event_Package__c,"2012 KSYMP Partner 70"), 
ISPICKVAL(Event_Package__c,"2012 KSYMP Platinum 50"), 
ISPICKVAL(Event_Package__c,"2012 KSYMP Silver 15"), 
ISPICKVAL(Event_Package__c,"2012 KSYMP Single"), 
ISPICKVAL(Event_Package__c,"2012 Road Show Custom"), 
ISPICKVAL(Event_Package__c,"2012 Road Show Gold 15"), 
ISPICKVAL(Event_Package__c,"2012 Road Show Partner 35"), 
ISPICKVAL(Event_Package__c,"2012 Road Show Platinum 25"), 
ISPICKVAL(Event_Package__c,"2012 Road Show Single"), 
NOT(ISPICKVAL(Event_Package__c,"")))
Error MessageNot required on Package Single Event type.Error LocationEvent Package
DescriptionThis validates that field is not required on Single Event Package types.
  

Can someone help me with a simple apex trigger on a custom object? I need to be able to sum up the Total price on a list of opportunity products in a opportunity. Here's a scenario:

 

Opportunity {Customer A} Package 10 Events(Products)

Opp Product - Event 1

Opp Product - Event 2...and so on

 

Opportunity {Customer B} Package 10 Events(Products)

Opp Product - Event 1

Opp Product - Event 2...and so on

 

Event (custom object)

Event Summary = Event 1 + Event 2

 

Ideally I would like to manage this under Campaign object but that doesn't seem to work.

 

 

 

I am trying to figure out a way to to populate the Quote Name automatically with the Opportunity Name. So when a user wants to create a Quote for a opportunity it will populate with the OppName. 

 

Is this possible?

Does anyone have any idea if it's possible to stop email notifications going to a user. RIght now there is a apex trigger that creates a lead to account - contract - opportunity base on certain lead field criteria. Can you code so the email notifucations are turned off.

 

I am creating an events management application so that the user can create multiple opportunity events. I want to be able to total the value of the events opportunties and track it under the contract. I am having difficulties being able to total opportunity amounts as you can't use the roll-up summary option in Contract object. Also each one these opportunities is tied to a Campaign.

Does anyone have a suggestion or another option on how to do this a better way? See example below:

Create Opportunity for each event.

Oppty Event 1 = $100 link to Campaign A

Oppty Event 2 = $200 link to Campaign B

Oppty Event 3 = $300 link to Campaign C

Oppty Event 4 = $400 link to Campaign D

Oppty Event 5 = $500 link to Campaign E

Oppty Event 6 = $600 link to Campaign F

 

Create Contract

Account purchases an event package for example GOLD = $15K and you get 6 events.

So I want to be able to track the total opportunity amounts and balance.

Event Package GOLD = $15,000

Total Opportunities = $10,000

Balance = $5,000

 

Let me know if you need further clarification.

 

I am creating an events management application so that the user can create multiple opportunity events. I want to be able to total the value of the events opportunties and track it under the contract. I am having difficulties being able to total opportunity amounts as you can't use the roll-up summary option in Contract object. Also each one these opportunities is tied to a Campaign.

Does anyone have a suggestion or another option on how to do this a better way? See example below:

Create Opportunity for each event.

Oppty Event 1 = $100 link to Campaign A

Oppty Event 2 = $200 link to Campaign B

Oppty Event 3 = $300 link to Campaign C

Oppty Event 4 = $400 link to Campaign D

Oppty Event 5 = $500 link to Campaign E

Oppty Event 6 = $600 link to Campaign F

 

Create Contract

Account purchases an event package for example GOLD = $15K and you get 6 events.

So I want to be able to track the total opportunity amounts and balance.

Event Package GOLD = $15,000

Total Opportunities = $10,000

Balance = $5,000

 

Let me know if you need further clarification.

 

 



 

 

I am trying to roll-up the amounts from a number of opportunities into a TOTAL_AMOUNT under the CONTRACT object. See below:

 

Scenario One:

OPP1 = $1

OPP2 = $2

OPP3 = $3

OPP4 = $4

OPP4 = $5

CREATE CONTRACT and sum Total_OPP_AMOUNT = $15 

 

Scenario Two:

Single Opportunity 

OPP1 = 1

No Contract required.

 

I am trying to create a detail button using a standard field. The one I created was called Create Opportunity under the Campaign object. Now I am trying to create one on the Opportunity object called Create Contract. I'm looking for the proper syntex for Contract. The code looks like this the one below, where &con = contract? I figured the ones out for opportunity (&opp) and cases (&cas). There some to be no list anywhere on the help site.

 

https://cs10.salesforce.com/800/e?retURL=%2F800%2Fo
&cas1=1

I am trying to create a custom detail page button called Create Opportunity on Campaign object. So when the user clicks it opens the opportunity object with the linked Campaign name. 

Both the related Opportunity and Campaign objects are in the related list. I know if the user scroll down in Campagns they could click on the NEW in the Oppportunity sections and that will work the same way. I just want to make it convenient for them to be able to have the button at the top.

This is what currently have but it doesn't seem to be pulling the Campaign Name.

 

https://cs10.salesforce.com/006/e?retURL=%2F006%2Fo
var records = {!GETRECORDIDS( $ObjectType.Campaign)}

 

Can some help me with this?

 

Is it possible to turn-off email notifications for leads assigned to a specifice user. I have done everything possible to deactivate email in their personal setting but it's not work.

 

I have a Lead trigger which assigns leads to SF users and sends them an email. Based on certain variblesa we don't want the auto email to be sent to a specific user email address. 

I adjusted the users email settings so they don't get the email notifications but it doesn't seem to work. Is it possible the below trigger(SEE BELOW) is over riding the email notification settings?

 

/*
    Author: Sarah Khalid
    Date: 06/07/2010
    Description: This trigger carries out lead assignment and parses out the title field coming from Netsuite
                 into 4 different fields on the lead object
                 
                 Added the New Lead Assignment on 20-Jan-2012 by Alex
*/

trigger ParseSourceInformation on Lead (before insert, before update) 
{
    system.debug('In LeadAssignment trigger');
    
    ConvertLeadHelper helper = new ConvertLeadHelper();
    LeadAssignmentHelper assignmentHelper = new LeadAssignmentHelper();
    Id leadOwner;
    
    //Variables added by Alex for new Lead Assignment. 
    
    //Variables to stroe the Active Users info.
    Map<Id, String> userIdUsernameMap = new Map<Id, String>();
    Map<String, Id> usernameUserIdMap = new Map<String, Id>();
    
    //Variables used to store the Custom Setting values.
    Set<String> leftUserIds = new Set<String>();
    String conversionEvent;
    String homeCustomerSegment;
    String recentConversionEvent;
    String countryNA;
    String countryCanada;
    String stateOrCountry;
    map<String, String> roundRobinUsers = new Map<String, String>();
    
    //Latin America Countries
    Set<String> latinAmericaCountries = new Set<String>{'ARGENTINA', 'BOLIVIA', 'BRAZIL', 'CHILE', 'COLOMBIA', 'ECUADOR', 'FRENCH GUIANA', 'GUYANA', 'PARAGUAY', 'PERU', 'SURINAME', 'URUGUAY','VENEZUELA' };
    
    //Get Usernames from Custom Setting.
    Map<String, Lead_Assignment__c> leadAssignment = Lead_Assignment__c.getAll();
    
    //Round Robin Count update
    List<Round_Robin_Count__c> updateRrc = new List<Round_Robin_Count__c>();
    
    //Store the values from Custom setting to variable.
    for( String tempName : leadAssignment.keySet() ){
    
        if( leadAssignment.get(tempName).Order_of_Execution__c == 1 ) leftUserIds.add( leadAssignment.get(tempName).Username__c );
        if( leadAssignment.get(tempName).Order_of_Execution__c == 2 ) conversionEvent       = leadAssignment.get(tempName).Username__c;
        if( leadAssignment.get(tempName).Order_of_Execution__c == 3 ) homeCustomerSegment   = leadAssignment.get(tempName).Username__c;
        if( leadAssignment.get(tempName).Order_of_Execution__c == 4 ) recentConversionEvent = leadAssignment.get(tempName).Username__c;
        if( leadAssignment.get(tempName).Order_of_Execution__c == 5 ) countryNA             = leadAssignment.get(tempName).Username__c;
        if( leadAssignment.get(tempName).Order_of_Execution__c == 6 ) countryCanada         = leadAssignment.get(tempName).Username__c;
        if( leadAssignment.get(tempName).Order_of_Execution__c == 7 ) stateOrCountry        = leadAssignment.get(tempName).Username__c;
        if( leadAssignment.get(tempName).Order_of_Execution__c == 8 ) roundRobinUsers.put( tempName, leadAssignment.get(tempName).Username__c );
    }
    
    //Get User info.
    for( User u : [ SELECT Id, Username FROM User WHERE isActive = TRUE ] ){
    
        userIdUsernameMap.put( u.id, u.Username );
        usernameUserIdMap.put( u.Username, u.id );
    }
        
        
        
    for (Lead currentLead : Trigger.new)
    {   
        String foundSiteVia = currentLead.hubspot__Found_Site_Via__c;
        Double qualificationScore = currentLead.QualificationScore__c;
        String country = currentLead.Country;
         
        system.debug('Title = ' + currentLead.Title);
        system.debug('Country = ' + country);
        system.debug('Recent Event = ' + currentLead.hubspot__Recent_Conversion_Event__c);
        
        if(foundSiteVia!=null || foundSiteVia!='')
        {
            string source = helper.parseSource(foundSiteVia);
            string sourceDetail = helper.parseSourceDetail(foundSiteVia);
            currentLead.Source__c = source;
            currentLead.Source_Detail__c = sourceDetail;
        }
            
        /* Lead Assignment Starts here */
        //Start out with Occupation, HearAboutIdeaPaint and Country field and see if they match with lead assignment criteria
        //string occupation = currentLead.Occupation__c;
        //string hearAboutUs = currentLead.HowHearAboutIdeaPaint__c;
        //string state = currentLead.State;
        
        //This boolean determines if the lead assignment criteria was met or not so that a lead should be further processed
        boolean processed = FALSE;
        
        //string groupName;
        system.debug('Lead Assignment Starts here');
        
        //Only process lead assignment if the lead is initially assigned to Marcus
        if(currentLead.OwnerId=='00530000003UZTR')
        {
             //Check for Existing LeadOwner is not available in Exclude list
            if( !leftUserIds.contains( userIdUsernameMap.get( currentLead.ownerId ) ) ) {
        
                if( processed != TRUE && ( (currentLead.hubspot__Conversion_Events__c != NULL && currentLead.hubspot__Conversion_Events__c == 360) || (currentLead.Title != NULL && currentLead.Title.Contains('GMA')) )){
            
                    currentLead.OwnerId = usernameUserIdMap.get( conversionEvent ); 
                    processed = TRUE;
                }
                
                if( processed != TRUE && ( currentLead.WhereWantUseIdeaPaint__c != NULL && currentLead.WhereWantUseIdeaPaint__c == 'Home' )){
                    
                    if ( currentLead.hubspot__Recent_Conversion_Event__c != NULL && currentLead.hubspot__Recent_Conversion_Event__c.toUpperCase().Contains('VISITED PLAN YOUR INSTALLATION PAGE' )){
                    }else {
                        currentLead.OwnerId = usernameUserIdMap.get( homeCustomerSegment );
                        processed = TRUE;
                    }
                }
                
                //User - IdeaPaint Web
                if( processed != TRUE && ( currentLead.hubspot__Recent_Conversion_Event__c != NULL && currentLead.hubspot__Recent_Conversion_Event__c.toUpperCase().Contains('PURCHASE') )){
                
                    currentLead.OwnerId = usernameUserIdMap.get( recentConversionEvent );
                    processed = TRUE;
                }
                
                if( processed != TRUE && ( currentLead.Country != NULL && currentLead.Country.toUpperCase() != 'UNITED STATES' && currentLead.Country.toUpperCase() != 'USA' && currentLead.Country.toUpperCase() != 'CANADA' && !(latinAmericaCountries.contains( currentLead.Country.toUpperCase()))  )){
                
                    currentLead.OwnerId = usernameUserIdMap.get( countryNA );
                    processed = TRUE;
                }
                
                if( processed != TRUE && ( currentLead.Country != NULL && currentLead.Country.toUpperCase() == 'CANADA' )){
                
                    currentLead.OwnerId = usernameUserIdMap.get( countryCanada );
                    processed = TRUE;
                }
                
                if( processed != TRUE && ( (currentLead.State != NULL && ( currentLead.State.toUpperCase() == 'CA' || currentLead.State.toUpperCase() == 'CALIFORNIA' )) || (currentLead.Country != NULL && latinAmericaCountries.contains( currentLead.Country.toUpperCase())) )){
                
                    currentLead.OwnerId = usernameUserIdMap.get( stateOrCountry );
                    processed = TRUE;
                }
                
                //Round Robin User assignment.
                if( processed != TRUE ){
                
                    if( roundRobinUsers.size() > 0 ){
                    
                        Round_Robin_Count__c rrc = Round_Robin_Count__c.getOrgDefaults();
                                               
                        currentLead.OwnerId = usernameUserIdMap.get(Lead_Assignment__c.getValues('Round Robin User-'+String.valueOf( math.mod( Integer.valueOf( rrc.Round_Robin_Count__c), roundRobinUsers.size() ) + 1 )).Username__c);
                        rrc.Round_Robin_Count__c++;
                        updateRrc.add( rrc );
                        processed = TRUE;
                    }
                }//End of Round Robin User assignment.
            }//End of Exclude list check.
        }
        
            
        //Parse out the title field here
        String[] titleArray = new String[3];
        if(currentLead.Title!=NULL && currentLead.Title.length()>5 && currentLead.Title.contains(',')) 
        {
            titleArray = currentLead.Title.split(',');
            currentLead.Quantity__c = Double.valueOf(titleArray[0]);
            currentLead.Item_Type__c = titleArray[1];
            currentLead.Color__c = titleArray[2];
            currentLead.Amount__c = Double.valueOf(titleArray[3]);
            currentLead.TotalOrder__c = titleArray[3];
        }
        currentLead.Title = '';     
    }
    
    if( updateRrc.size() > 0 ) {
    
        update updateRrc;
    }
       
    //No need to update lead it updates explicitly
}

 

I need help with how to create a formula to roll-up the total amounts from a group of opportunities and sum the amount into the Contract object. Currently, I have the contract referenced in the opportunity and a related list in the Contract layout. I thought this would be easy by just creating a custom field under Contract and used the Roll-up summary field type. But this does not allow me to do that because its not considered the master in the master-detail relationship.

I think my only option is Apex Code. Can anyone help me with that?

 

Any help asap would be greatly appreciated.

I need help with how to create a formula to roll-up the total amounts from a group of opportunities and sum the amount into the Contract object. Currently, I have the contract referenced in the opportunity and a related list in the Contract layout. I thought this would be easy by just creating a custom field under Contract and used the Roll-up summary field type. But this does not allow me to do that because its not considered the master in the master-detail relationship.

According to salesforce support it's not possible to do this way but can be done through a formula. I'm just not sure how.

 

Any help asap would be greatly appreciated.

 

I have been a struggling with creating a time sheet app. I want to have the ability for staff to enter Time IN and Time Out hours and then calculate Total hours for that day.

 

I thought best way would be for them to use a TEXT field and enter time in military hours. ex. 0900.

 

But now I am stuck on how to go about creating a formula for Total hours. 

Ex, Start TIme = 0900

End Time = 1730

End time - Start Time = 8.5 hrs

I am trying to create a validation rule that when the StageName changes to Invoice it checks and make sure the CloseDate is today's date. Below is my formula. The problem is when any of the other fields are changed in this opportunity it still populates with Today's date. I don't want it do that. 

 

 

OR(IF(ISPICKVAL( StageName, "Invoice"), NOT(CloseDate = TODAY()), null),
IF(ISPICKVAL(StageName, "Invoice Supplies"), NOT(CloseDate = TODAY()), null))

 

 

Also I tried to setup a workflow rule. But same thing is happening.

 

Field Update:Opportunity.CloseDate

Formula Value: Today()

Workflow rule: Everytime a field is updated or created

Rule criteria = Invoice

 

 

I am trying to build a timecard app in SF. Does anyone have a better solution for the following.

 

Pay Period Start: {DATE} User enters

Pay Period End: {DATE} User enter or I might have it auto calculate based on a 2-week pay period

 

Monday(wk1): {DATE} = Pay_Period_Start__c

Start time: ????? User enter a time ex. 9:00 AM. Also I want a default value to be 9:00 AM

End time: ???? Same as start time. Also want default to be 5:00 PM

TOTAL Monday Hours: End_Time - Start_Time

 

Any ideas on this? Is there a way of getting around making it easier for user enter time like 930 or 1700 and return ex. 9:00 am or 5:00 pm.

 

I am trying to create either a Validation rule or workflow that says:

 

IF(ISPICKVAL(Opportunity_StageName, "Decline"), Product_Return = FALSE, TRUE)

Error message: Please make sure product is checked returned.

This works on the Opportunity Product object but I need it to work when the Opportunity Stage is changed to "Declined" the product get checked returned.

 

OR

Workflow but didn't work either. Anyone have other possible solutuon?

 

 

 

Wondering if someone has an idea on how to add text at the end of  a value after it has been entered. I have a field where the user enters a value but I want the result to add a standard text so they don't have to retype all the time.

 

Ex. User enters:  12.5

Result is: 12.5 cm H2O ( so the standard text is "cm H2O" all the time)

 

Thanks.

Can anyone help me with this frustrating issue. I am developing an application where I want to relate a number of opportunities with a contract and have the abilitiy to total sum the opportunity amounts and count the opportunities against this contract. I can't believe this can't be done. Am I the first person that's tried to do something like this?

I am trying to setup a validation rule but when the picklist  field is populated with ---None--- it will allow to save. See below. What do you need to add to the formula so you can save it.

 

Rule NameError_message_on_SE_Pkg_typeActiveChecked
Error Condition FormulaOR(ISPICKVAL(Type, "KSYMP Pkg - Single Event"), 
ISPICKVAL( Type,"Road Show Pkg - Single Event"), 
ISPICKVAL(Event_Package__c, "2012 KSYMP Custom"), 
ISPICKVAL(Event_Package__c, "2012 KSYMP Gold 30"), 
ISPICKVAL(Event_Package__c,"2012 KSYMP Partner 70"), 
ISPICKVAL(Event_Package__c,"2012 KSYMP Platinum 50"), 
ISPICKVAL(Event_Package__c,"2012 KSYMP Silver 15"), 
ISPICKVAL(Event_Package__c,"2012 KSYMP Single"), 
ISPICKVAL(Event_Package__c,"2012 Road Show Custom"), 
ISPICKVAL(Event_Package__c,"2012 Road Show Gold 15"), 
ISPICKVAL(Event_Package__c,"2012 Road Show Partner 35"), 
ISPICKVAL(Event_Package__c,"2012 Road Show Platinum 25"), 
ISPICKVAL(Event_Package__c,"2012 Road Show Single"), 
NOT(ISPICKVAL(Event_Package__c,"")))
Error MessageNot required on Package Single Event type.Error LocationEvent Package
DescriptionThis validates that field is not required on Single Event Package types.
  

Can someone help me with a simple apex trigger on a custom object? I need to be able to sum up the Total price on a list of opportunity products in a opportunity. Here's a scenario:

 

Opportunity {Customer A} Package 10 Events(Products)

Opp Product - Event 1

Opp Product - Event 2...and so on

 

Opportunity {Customer B} Package 10 Events(Products)

Opp Product - Event 1

Opp Product - Event 2...and so on

 

Event (custom object)

Event Summary = Event 1 + Event 2

 

Ideally I would like to manage this under Campaign object but that doesn't seem to work.

 

 

 

I am trying to figure out a way to to populate the Quote Name automatically with the Opportunity Name. So when a user wants to create a Quote for a opportunity it will populate with the OppName. 

 

Is this possible?

I am trying to roll-up the amounts from a number of opportunities into a TOTAL_AMOUNT under the CONTRACT object. See below:

 

Scenario One:

OPP1 = $1

OPP2 = $2

OPP3 = $3

OPP4 = $4

OPP4 = $5

CREATE CONTRACT and sum Total_OPP_AMOUNT = $15 

 

Scenario Two:

Single Opportunity 

OPP1 = 1

No Contract required.

 

I am trying to create a detail button using a standard field. The one I created was called Create Opportunity under the Campaign object. Now I am trying to create one on the Opportunity object called Create Contract. I'm looking for the proper syntex for Contract. The code looks like this the one below, where &con = contract? I figured the ones out for opportunity (&opp) and cases (&cas). There some to be no list anywhere on the help site.

 

https://cs10.salesforce.com/800/e?retURL=%2F800%2Fo
&cas1=1

I am trying to create a custom detail page button called Create Opportunity on Campaign object. So when the user clicks it opens the opportunity object with the linked Campaign name. 

Both the related Opportunity and Campaign objects are in the related list. I know if the user scroll down in Campagns they could click on the NEW in the Oppportunity sections and that will work the same way. I just want to make it convenient for them to be able to have the button at the top.

This is what currently have but it doesn't seem to be pulling the Campaign Name.

 

https://cs10.salesforce.com/006/e?retURL=%2F006%2Fo
var records = {!GETRECORDIDS( $ObjectType.Campaign)}

 

Can some help me with this?

 

Is it possible to turn-off email notifications for leads assigned to a specifice user. I have done everything possible to deactivate email in their personal setting but it's not work.

 

I need help with how to create a formula to roll-up the total amounts from a group of opportunities and sum the amount into the Contract object. Currently, I have the contract referenced in the opportunity and a related list in the Contract layout. I thought this would be easy by just creating a custom field under Contract and used the Roll-up summary field type. But this does not allow me to do that because its not considered the master in the master-detail relationship.

I think my only option is Apex Code. Can anyone help me with that?

 

Any help asap would be greatly appreciated.