• NishB
  • NEWBIE
  • 40 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 31
    Replies
I have a validation rule on the Account Object as below:

AND( 
NOT ISBLANK( Name),
ISPICKVAL (Account_Level__c, "Company" ),
ISBLANK( Address__c ),
NOT $User.Status__c
)
The above rule working when the Account is Created/Updated.Now I am create a Trigger on the Custom Object(Company):Trigger name is CompanySurvey. In CompanySurvey Trigger I Update the one field in Account Object.At the time does't showing the ERROR in standard-lone.But Account is not Updated because is validation rule executes.I debug the CompanySurvey Trigger in ERROR logs it show the error message but not showing the standard-lone.

Company lookup with Account Object.

Best Regards,
Ramesh
Hi,
    Whenever a custom object B is created a corresponding standard Case record has to be created. The user who creates the record of object B has a salesforce platform license. There is trigger which inserts case everytime a B record is created. Since the user has a platform license he will not be able to access Case. But what I did not understand is when the user creates a record of object B how does the trigger not fail and go on to create a Case even though the User cannot access Case?

Thank you,
Nisha
 
  • February 06, 2015
  • Like
  • 1
Hi,
    Whenever a user is assigned multiple leads a email gets sent to the owner informing him of this after 5 mins. We have a wokflow on User and based on the field value on the User the workflow is triggered. The email gets sent to the correct user i.e the owner of the leads but the merge fields on the template considers the values of the user who assigned the user to the leads. Could anyone please let me know the reason behind this incorrect merge field values .


Thanks,
Nisha
  • May 08, 2014
  • Like
  • 0
Hi,
    Whenever a custom object B is created a corresponding standard Case record has to be created. The user who creates the record of object B has a salesforce platform license. There is trigger which inserts case everytime a B record is created. Since the user has a platform license he will not be able to access Case. But what I did not understand is when the user creates a record of object B how does the trigger not fail and go on to create a Case even though the User cannot access Case?

Thank you,
Nisha
 
  • February 06, 2015
  • Like
  • 1
Hi,
    Whenever a custom object B is created a corresponding standard Case record has to be created. The user who creates the record of object B has a salesforce platform license. There is trigger which inserts case everytime a B record is created. Since the user has a platform license he will not be able to access Case. But what I did not understand is when the user creates a record of object B how does the trigger not fail and go on to create a Case even though the User cannot access Case?

Thank you,
Nisha
 
  • February 06, 2015
  • Like
  • 1
Hi,
    Whenever a user is assigned multiple leads a email gets sent to the owner informing him of this after 5 mins. We have a wokflow on User and based on the field value on the User the workflow is triggered. The email gets sent to the correct user i.e the owner of the leads but the merge fields on the template considers the values of the user who assigned the user to the leads. Could anyone please let me know the reason behind this incorrect merge field values .


Thanks,
Nisha
  • May 08, 2014
  • Like
  • 0
Hey there,

I have found some code on the internet, it is close..it is just not there yet. I have been able to filter a pageblocktable, from a page with a standard controller and the extension. The goal now is to be able to filter the records that are a child to a master object. This is what I have so far:

VF page:

<apex:page standardController="Office__c"  extensions="SearchExt" >



<apex:pageBlock title="Office Commissions"  >
<apex:form >
<apex:pageBlockSection >
                 <apex:pageBlockTable value="{!Office__c.Office_Commissions__r}" var="OffCom" >
                     <apex:outputLabel value="Start Date" />
                     <apex:inputField value="{!OffCom.Search_Start_Date__c}"/>
                 </apex:pageBlockTable>
                
<apex:pageBlockTable value="{!Office__c.Office_Commissions__r}" var="OffCom1" >
                     <apex:outputLabel value="End Date" />
                     <apex:inputField value="{!OffCom1.Search_End_Date__c}"/>
                 </apex:pageBlockTable>                 
<apex:commandButton value="Disply" action="{!displaingTable}" reRender="tableId"/>
</apex:pageBlockSection>


<apex:pageBlockSection >
<apex:pageBlockTable value="{!Office__c.Office_Commissions__r}" id="tableId" var="OffCom" >
<apex:column headerValue="Office Commissions" >
<apex:commandLink rerender="OffComdetails">  {!OffCom.Name}
<apex:param name="OffComid" value="{!OffCom.id}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!OffCom.Upfront_Bonus_Average__c}"/>
<apex:column value="{!OffCom.Ongoing_Bonus_Average__c}"/>

<apex:column value="{!OffCom.Commission_Period_Start__c}"/>
<apex:column value="{!OffCom.Commission_Period_End__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>

</apex:form>
</apex:pageBlock>
<apex:outputPanel id="OffComdetails">
<apex:detail subject="{!$CurrentPage.parameters.OffComid}" relatedList="False" inlineEdit="True" title="false"/>
</apex:outputPanel>

</apex:page>

Extension:

public with sharing class SearchExt{




    public Office_Commission__c OffCom {get;set;}
    public list<Office_Commission__c> listOffCom {get;set;}
    public SearchExt(ApexPages.StandardController controller) {
   
    this.OffCom = (Office_Commission__c)controller.getRecord();
    }
    public Date startDate1;
    public Date endDat1;
    public SearchExt() {
      
        OffCom = new Office_Commission__c();
    }
     public PageRefeRence  displaingTable(){
        startDate1 = OffCom.Search_Start_Date__c;
        endDat1 = OffCom.Search_End_Date__c;
        listOffCom= [SELECT id, Name
                          FROM Office_Commission__c
                          WHERE Commission_Period_Start__c >=: startDate1 AND Commission_Period_End__c<= :endDat1+1];
        return null;
     }
   
}

Any help would be much appreciated. Whenever I try and load the page I get the error:

System.TypeException: Invalid conversion from runtime type SOBJECT:Office__c to SOBJECT:Office_Commission__c
Class.SearchExt.<init>: line 10, column 1


I am trying to create a simple trigger that checks to see if a value is changed and if so, update a few fields and create a task.  The update the few fields part works, but the create a task part does not.  I receive the error message below. 

Error Message:  Error:Apex trigger Decide_Which_Address_to_Use caused an unexpected exception, contact your administrator: Decide_Which_Address_to_Use: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Trigger.Decide_Which_Address_to_Use: line 78, column 1

<pre>
trigger Decide_Which_Address_to_Use on SD_Member__c (before update) {
/*
  Developer     : Todd Barry
  Created       :
  Last Modified : 03/19/2014
  Test Class    :
  Objective     :
*/

Task [] newTask = new Task[0];
// Variables
Date dtTaskDate = DateTime.now().addDays(+1).date();

For (SD_Member__c SD : Trigger.new){

SD_Member__c beforeUpdate = System.Trigger.oldMap.get(SD.Id);

if(beforeUpdate.Last_Address_Fail_Date__c != SD.Last_Address_Fail_Date__c){
      If(sd.mailing_address__c == SD.NCOA_Address__c){
    sd.Bad_NCOA_Address__c = SD.Mailing_Address__c;
          sd.Bad_NCOA_City__c = sd.Mailing_city__c;
          sd.Bad_NCOA_State__c = sd.mailing_state__c;
          sd.Bad_NCOA_Zip__c = SD.Mailing_Zip__c;
          SD.Send_Monthly_Letter__c = True; 
          newtask.add(new task(whatid=SD.Id,subject='Make 1st Follow Up Call',ActivityDate=dtTaskDate,Status='Not Started', ownerid=sd.OwnerId));
         
     }
    
  If (newtask.size()>0)  update newtask;
}
      
          
}
}
</pre>

Any ideas?

Thanks, 

Todd B.
Hi All,

How to add list custom settings into an existing multi select picklist in visualforce?

VF Page

<apex:selectList value="{!selectedValue}" size="1" multiselect="false">
                                 <apex:selectOptions value="{!MyOptions}"/>
  </apex:selectList>

Apex:

public List<SelectOption> getMyOptions(){
    List<SelectOption> options = new List<SelectOption>();     

    // Reading picklist values and labels
    Schema.DescribeFieldResult fieldResult = Investor_Profile__c.Investor_Groups__c.getDescribe();
    List<Schema.PicklistEntry> picklistEntries = fieldResult.getPicklistValues();

    // Adding apicklist values to the select list
    for(Schema.PicklistEntry entry : picklistEntries){
        options.add(new SelectOption(entry.getValue(), entry.getLabel()));
    }
    // Now adding custom settings to the select list
     for(Investor_Details__c setting : Investor_Details__c.getAll().values()){
        options.add(new SelectOption(setting.name, setting.name));
            }    
      
       return options;
}



with this code am getting the picklist values but i need to get the multi select picklist values.
Reply ASAP....
Thanks in Advance....:)

Hi All,

I have the following requirement. When cutom button is clicked on Opportunity detail page, i need to update the schedule date for all products associated with that opportunity to match Opportunity close date.

Below is my code, i'm getting Script error on button click, what am i missing?

Button Click Javascript:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}

// Call Apex Web service

var result = sforce.apex.execute(
"ProductScheduleDateUpdate", // class
"updateProductDate", // method
{iDate:"{!Opportunity.CloseDate}", // method arguments
iOppId:"{!Opportunity.Id}"});

}


Apex Class code

global class ProductScheduleDateUpdate
{

    WebService static String updateProductDate(Date iDate, String iOppId){
        List<OpportunityLineItem> oliList = [SELECT Id, OpportunityId FROM OpportunityLineItem
                                        WHERE OpportunityId= : iOppId];

        if(oliList.size() == 0){
            return 'No Opportunity Products to Update';
        }

        List<OpportunityLineItemSchedule> olisList = new List<OpportunityLineItemSchedule>();
        Map<Id, String> oppLineItemIdIdOppIdMap = new Map<Id, String>(); // it is for setting opportunity access level

       
        for(OpportunityLineItemSchedule olis : [SELECT Id, ScheduleDate, OpportunityLineItemId
                                                FROM OpportunityLineItemSchedule
                                                WHERE OpportunityLineItemId IN : oppLineItemIdIdOppIdMap.keySet()]) {
            olis.ScheduleDate = iDate;
            olisList.add(olis);
        }
       
        if(olisList.size() > 0){
            update olisList;
        }
   
        return 'All Product Schedule Date updated to match Opportunity Close Date';
    }
}
Upon executing a task before insert trigger, I am trying to update an activity custom field  "Assigned_Region__c" by concatenating two text field values derived from the user.
Looking @ the code below, when I create a task, then look @ the debug logs, strConcatenate appears concatenated correctly- I get the values I'm expecting.  However, on the next line of code, when I try to  assign strConcatenate value to the Assigned_Region__c field (Type:  Text Area(255)), nothing happens - the field never populates with the value from strConcatenate once the record is inserted, nor do I get any errors.  I have checked that the field level security is set to be visible to all profiles including mine.  Any thoughts as to the cause?  Thanks in advance for your help - Bronco.

CODE:

trigger UpdateAssigned on Task (before insert) {
    String tskAssigned;
    for (Task tt : Trigger.new)
    {      
     tskAssigned = tt.Owner.Id;
        String uProf =  [SELECT Profile.Name FROM User WHERE id =: tskAssigned LIMIT 1].Profile.Name;//uProf stores user Profile Name
        String uRegion =  [SELECT Region__c FROM User WHERE id =: tskAssigned LIMIT 1].Region__c;//uRegion stores user Region 
        String strConcatenate = uProf + ' ' + uRegion;
        system.debug('strConcatenate= ' + strConcatenate);//debug log shows "SADMIN East" which is what I expect
        tt.Assigned_Region__c = strConcatenate;
    }
}


Hi

I had state custom field and the values are 

State__c   -  US-MA, US-NJ, IN-AP, IN-KE

in that field  states(MA,NJ,AP,KE)  are displaying with counry abbrivation.how to delete county abbrevations(US-,US-, IN-,IN-from state)

out put shoulsdbe MA,NJ,AP,KE

Appreciate your help

Thanks,

I have a validation rule on the Account Object as below:

AND( 
NOT ISBLANK( Name),
ISPICKVAL (Account_Level__c, "Company" ),
ISBLANK( Address__c ),
NOT $User.Status__c
)
The above rule working when the Account is Created/Updated.Now I am create a Trigger on the Custom Object(Company):Trigger name is CompanySurvey. In CompanySurvey Trigger I Update the one field in Account Object.At the time does't showing the ERROR in standard-lone.But Account is not Updated because is validation rule executes.I debug the CompanySurvey Trigger in ERROR logs it show the error message but not showing the standard-lone.

Company lookup with Account Object.

Best Regards,
Ramesh
Our Organization has a custom object known as "Intiatives" that has connections to multiple opportunities via a Lookup Field.  We use a Method (see below) to  calculate the value of all renewal opportunities attached to the Initiative object.

This functionality had been working fine until recently when we started receiving an error for a specific reocrd type:

"Error:Apex trigger OpportunityTriggers caused an unexpected exception, contact your administrator: OpportunityTriggers: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Class.OpportunityTriggersMgr.populateInitiativeRenewals: line 233, column 1"

(Line 233 has been underlined in the method below) The only thing changed has been some sharing rule adjustment. Unfortunately we no longer work with the developer who authored the below method.  Any help or guidance on this would be GREATLY appreciated!!! 


public static void populateInitiativeRenewals(List<Opportunity> newOpp, List<Opportunity> oldOpp){
       
        Integer currentYr   = system.now().year();
        Set<Id> oppIds = new Set<Id>();
        Set<Id> initIds = new Set<Id>();
        Map<Id, List<Opportunity>> initOppMap = new Map<Id, List<Opportunity>>();
        Map<Id, Initiative__c> initMapUpdate = new Map<Id, Initiative__c>();
       
        if(newOpp != null){
            for(Opportunity o : newOpp){
                if(o.Initiative__c != null){
                    oppIds.add(o.Id);
                    initIds.add(o.Initiative__c);
                    List<Opportunity> tempOpp = new List <Opportunity>();
                    tempOpp.add(o);
                    initOppMap.put(o.Initiative__c, tempOpp);
                }
            }
           
            for(Opportunity o : [Select Id, Name, Amount, Inception_Renewal_Date__c, Initiative__c, StageName from Opportunity where Initiative__c IN: initIds AND Id NOT IN: oppIds]){
                if(o.Inception_Renewal_Date__c.year() == currentYr && o.Initiative__c != null){
                    if(initOppMap.get(o.Initiative__c) != null){
                        initOppMap.get(o.Initiative__c).add(o);
                    }
                }
               
            }
           
            for(Opportunity o : newOpp){
                if(o.Initiative__c != null){
                    Decimal wonAmt   = 0;
                    Decimal pipeline = 0;
                    for(Opportunity opp : initOppMap.get(o.Initiative__c)){
                        if(opp.StageName == 'Renewed'){
                            wonAmt += opp.Amount;
                        }
                        if(opp.StageName == 'Due for Rerate' || opp.StageName == 'Rerated' || opp.StageName == 'Renewal Produced'){
                            pipeline += opp.Amount;
                        }
                    }
                    Initiative__c initiative = new Initiative__c(id = o.Initiative__c);
                    initiative.Renewal_Won_YTD__c = wonAmt;
                    initiative.Renewals_Pipepline__c = pipeline;
                    initMapUpdate.put(initiative.Id, initiative);
                }
            }
        }


Hi ALL,

Recently we hired an external company to make certain modifications in our SFDC enterprise edition. The goal was the following:

Link a specific Opportunity Line Item (OLI) to a custom object and have the Unit Price copied from the OLI into the custom object. They built an Apex Trigger to do this.

ALL of our custom objects are in CHF revenue (our Company Currency), whereas the Opportunities & OLI can have their revenue displayed in all kinds of Currencies.

My issue is that I would like to have the revenue copied, which is always displayed in the Company Currency and in brackets (see screen shot attached). But I am unable to find the unique Field/API Name in order to revise the Apex Trigger. Currently, it gives me the List Price, in this case 3,400,000.00 instead of 3,154,635.60.

Screen shot of Opportunity Line Item - Unit Price field

Any Idea what the API Name is of the revenue in brackets in the OLI?

Thanks and kind regards,
Daphne