• Tim Barsotti
  • SMARTIE
  • 575 Points
  • Member since 2013

  • Chatter
    Feed
  • 17
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 147
    Replies
I have to change the record type name but i do not know in what components it has been used. Is there any way to find the usage of a particular record type in all the components of the org. for example workflows Approval process validation rule etc.
Initially I copied lead fields into lead custom fields after that I'm trying map Name and Email fields to Opportunity custom fields..

trigger mapping on Lead (after update) 
{
    Opportunity opp=new Opportunity();
    for(Lead ll:Trigger.New)
    {
        if(ll.isconverted==true)
        {
            opp.Client_Name__c=ll.Name;
            opp.Client_Email__c=ll.Email;
        }
        insert opp;
    }
}

This is working but opportunity fields not getting added. 
All,

I'm working on a project for a dynamic search of clients using Jeff Douglas's blog as a template

http://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/

I have everything displayed correctly, but when I go to search, the debug soql query doesn't seem to be adding the search letter I type with the wild card. If you look at the demo here:

https://jeffdouglas-developer-edition.na5.force.com/examples/CustomerSearch

you can see that when a letter is entered, the debug soql changed to add that new search to the original soql.

From:
select firstname, lastname, account.name, interested_technologies__c from contact where account.name != null order by lastName asc limit 20
To:
select firstname, lastname, account.name, interested_technologies__c from contact where account.name != null and firstname LIKE 'a%' order by lastName asc limit 20

Does anybody have any idea why my search doesn't seem to be firing when the 'OnKeyUp' function is executed? I feel like it may have something to do with the 'escapeSingeQuotes' method or the LIKE.

Here is a snippet of my code:

// runs the search with parameters passed via Javascript
  public PageReference runSearch() {
      
    String FirstName = Apexpages.currentPage().getParameters().get('FirstName');
    String LastName = Apexpages.currentPage().getParameters().get('LastName');
    String Broker = Apexpages.currentPage().getParameters().get('Broker_Dealer_Name__c');
    String MailingCity = Apexpages.currentPage().getParameters().get('MailingCity');
    String MailingState = Apexpages.currentPage().getParameters().get('MailingState');
    String MailingPostalCode = Apexpages.currentPage().getParameters().get('MailingPostalCode');
    String OwnerName = Apexpages.currentPage().getParameters().get('Owner.Name');
    String NSIncomeProducerStatus = Apexpages.currentPage().getParameters().get('Producer_Status__c');
    String NSIncomeIIProducerStatus = Apexpages.currentPage().getParameters().get('NS_Income_II_Producer_Status__c');
    String NSIncomeHIProducerStatus = Apexpages.currentPage().getParameters().get('NS_HI_Producer_Status__c');

    soql = 'select FirstName, LastName, Broker_Dealer_Name__c, MailingStreet, MailingCity, MailingState, 
MailingPostalCode, Owner.Name, Phone, Total_Sales__c, Producer_Status__c, NS_Income_II_Producer_Status__c, 
NS_HI_Producer_Status__c FROM Contact Where Broker_Dealer_Name__c !=null';

    if (!FirstName.equals(''))
      soql += ' and FirstName LIKE \''+String.escapeSingleQuotes(FirstName)+'%\'';
    if (!LastName.equals(''))
      soql += ' and LastName LIKE \''+String.escapeSingleQuotes(LastName)+'%\'';
    if (!Broker.equals(''))
      soql += ' and Broker_Dealer_Name__c LIKE \''+String.escapeSingleQuotes(Broker)+'%\'';
    if (!MailingCity.equals(''))
      soql += ' and MailingCity LIKE \''+String.escapeSingleQuotes(MailingCity)+'%\'';  
    if (!MailingState.equals(''))
      soql += ' and MailingState LIKE \''+String.escapeSingleQuotes(MailingState)+'%\'';
    if (!MailingPostalCode.equals(''))
      soql += ' and MailingPostalCode LIKE \''+String.escapeSingleQuotes(MailingPostalCode)+'%\''; 
    if (!OwnerName.equals(''))
      soql += ' and Owner.Name LIKE \''+String.escapeSingleQuotes(OwnerName)+'%\'';
    if (!NSIncomeProducerStatus.equals(''))
      soql += ' and Producer_Status__c = (\''+NSIncomeProducerStatus+'\')';
    if (!NSIncomeIIProducerStatus.equals(''))
      soql += ' and NS_Income_II_Contact_Type__c = (\''+NSIncomeIIProducerStatus+'\')';
    if (!NSIncomeHIProducerStatus.equals(''))
      soql += ' and NS_HI_Contact_Type__c = (\''+NSIncomeHIProducerStatus+'\')';
  
    // run the query again
    runQuery();

    return null;
  }

User-added image

Error is in expression '{!populateAdvertizingInfo}' in page lead_creation

 

Class.Lead_Creation.populateAdvertizingInfo: line 88, column 1

---------------------------------

 

Error results on VisualForce page that references the following code on my visualforce page.  What's highlighted in orange is what is failing and the referenced code follows below:

 

<apex:selectListvalue="{!SelectedExtension}"size="1"label="Ad Series"id="extension">

                    <apex:selectOptionsvalue="{!ExtensionsOptions}"></apex:selectOptions>

            <apex:actionSupportevent="onchange"action="{!populateAdvertizingInfo}"reRender="leadInterest"/> 

                </apex:selectList>

 

1    private Campaign thisCampaign ;

2   public void populateAdvertizingInfo()

3    {

4        List<String> SelectedAdSeries = SelectedExtension.split('-');

5        Decimal ext = Decimal.valueof(SelectedAdSeries[1]);

6        thisCampaign = [Select Campaign_Fully_Qualified__c, Ad_Type__c, Ad_Size__c, Media_Source__c, Project_Code__c,

7                       Type from Campaign where Project__c =: currentLead.Project_site__c AND Extension__c =: ext];

8        system.debug('the campaign '+thisCampaign.id);

9        currentLead.Ad_Type__c = thisCampaign.Ad_Type__c;

10        currentLead.Ad_Size__c = thisCampaign.Ad_Size__c;

11        currentLead.Media_Source__c = thisCampaign.Media_Source__c;

12        currentLead.Project_Code__c = thisCampaign.Project_Code__c;

13       currentLead.Ad_Series__c = thisCampaign.Campaign_Fully_Qualified__c;

14        SelectedCampaignID = thisCampaign.Id;  

15        SelectedCampaignName = thisCampaign.Campaign_Fully_Qualified__c;

16    }

 

It appears that I am getting hung up on the line 6 above.  Any suggestions?

  • September 19, 2013
  • Like
  • 0

Hello, I am writing a trigger that displays information from the most recently created opportunity on the account page. The fields are dynamic, meaning anytime theres an account update or insert, it looks for the most recently created opportunity, and grabs the necessary info. The trigger works fine, except when you move an opportunity. When moving an opporuntiy,  the information displayed on the account page is from the newly moved opportunity (which is incorrect). It does trigger an account update, but it still shows the old/incorrect data. My thought was to add an after update condition, but I get the below error:

 

trigger DynamicOppDataOnAcctPageBefore on Account (before insert, before update) {

 

Account acct = Trigger.new[0];

String accountid = acct.id;

String OpQ = null;

String OpA = null;

 

for (Opportunity opp: [SELECT id, security_question__c, security_answer__c

                                        FROM opportunity

                                        WHERE (AccountID = :accountid) AND (recordtypeid = '01230000000000K'  OR recordtypeid = '012600000009I8D'

                                        OR recordtypeid = '012600000009FS0' OR recordtypeid = '01230000000000L')

                                        ORDER BY user_created_date__c ASC

                                        ]){

                                       

              acct.Security_question_opp__c  =  opp.security_question__c ;

              acct.Security_answer_opp__c  =  opp.security_answer__c   ;                    

              } 

}

 

Error when adding the after update piece, the line bolded above is line 15:

 

Error:Apex trigger DynamicOppDataOnAcctPageBefore caused an unexpected exception, contact your administrator: DynamicOppDataOnAcctPageBefore: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.DynamicOppDataOnAcctPageBefore: line 15, column 1

 

Any help would be greatly appreciated.

 

Thanks!

  • September 18, 2013
  • Like
  • 0

I'm creating a trigger to create a campaign member to a specific campaign. However, my edition of Salesforce only includes 1 Developer Sandbox and thus does not have the campaign needed for the trigger (no production data). What is the best way to create the trigger given this limitation? Is there a way to do it the Force.com IDE? 

  • September 17, 2013
  • Like
  • 0

Hello,

 

I'm not a developer and really new to this.  I had a question and was wondering if someone had a solution or could point me in the right direction.  I have a picklist field on the Case object, that when a value is selected, I would like it to update another picklist field with a value.  The picklist values for the two custom fields are not related by name, but there are equal amounts of picklist values (i.e. field_1 has 32 picklist options & code_1 has 32 options).  I don't want to do a workflow for field updates since I would have to do all 32 options, plus the field needs to be cloned to be 5 similar fields.  This would require too many workflows.  Also, the field_1 picklist options are REALLY long sentences, which I want to update a corresponding field code_1 with the 4 digit code of the field_1 option.  I tried writing a formula field, but ran out of characters before I could list all of the picklist options (other than that, it worked fine).

 

Ideally, I would like to use Apex to make this work.  I have a basic code, but I'd rather not hard code the picklist values in in case they change.  This is what my basic structure looks like:

 

trigger FieldUpdate on Case (before insert, before update, after insert, after update){
// Loop through the incoming records
for (Case c : Trigger.new){
if(c.field_1__c == 'blah blah blah, really long sentence'
&& c.code_1__c == null){c.code_1__c = 'COD1';
}else if (c.AEM_Violation_1__c == 'Equally long descriptive sentence...”'
&& c.AEM__c == null){c.AEM__c = 'COD2';
}else if ....
}
}
}

 

Basically, hard coding the field to update will require me to list all 32 reasons, and then make triggers for each of the 4 other fields that have the same values.  Is there any way to do this in a more efficient manner that doesn't require me to hard code each of the picklist values?

  • September 13, 2013
  • Like
  • 1

Can we do this logic in trigger

   new record have to be created in case object whenever a booking__c object is created 

  • September 12, 2013
  • Like
  • 0

HI All,

 

can anybody help me in this class. Its throwing error message as " Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [PricebookEntryId, Quantity, UnitPrice]: [PricebookEntryId, Quantity, UnitPrice] " when trying to insert service contract lineitems

 

Apex class :

 

public static void createContractLineItems(Set<Id> serviceContacts){
set<ID> assetIDs = new set<ID>();
map<ID,String> ProductsMap = new map<Id,String>();
list<ContractLineItem> contLineitems = new list<ContractLineItem>();
Map<Id,PricebookEntry> priceBookIds = new Map<Id,PricebookEntry>();
Set<Id> priceBooks = new Set<Id>();
List<ServiceContract> serviceCons = [select id ,Asset__c,Pricebook2Id from ServiceContract where id in :serviceContacts];
for(ServiceContract oContract : serviceCons)
{
if(oContract.Asset__c != null)
{
assetIDs.add(oContract.Asset__c);
}
if(oContract.Pricebook2Id != null)
priceBooks.add(oContract.Pricebook2Id);
}
if(assetIDs != null && assetIDs.size() > 0){
map<Id,List<Id>> assetMap = new map<Id,List<Id>>();
Set<Id> productIds = new Set<Id>();
List<id> procutsList ;
Map<Id,Asset__c> assetsMap = new Map<Id,Asset__c>([SELECT ID,SAP_SODO__c,SAP_SODO__r.Service_Product__c FROM Asset__c WHERE ID IN: assetIDs]);
for(ServiceContract oContract : serviceCons){
if(oContract.Asset__c != null && assetsMap.containsKey(oContract.Asset__c) && assetsMap.get(oContract.Asset__c) != null){
Asset__c asset = assetsMap.get(oContract.Asset__c) ;
ContractLineItem lineItem = new ContractLineItem(ServiceContractId = oContract.id);
// lineItem.PricebookEntryId = priceBookIds.get(oContract.Pricebook2Id).id ;
// lineItem.Quantity = 1 ;
// lineItem.UnitPrice = priceBookIds.get(serviceProdId).UnitPrice ;
contLineitems.add(lineItem);
system.debug ( '***********' + contLineitems);

}
}
if(contLineitems != null && contLineitems.size() > 0)
insert contLineitems ;
}
}

}

Any idea why customer portal users will get this error "salesforce sObject type 'AssignmentRule' is not supported." 

 

We have overridden the case submission form. And have a SOQL that fails for customer portal users. 

 

SOQL:

 

AssignmentRule AR = new AssignmentRule(); 
AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];

 

I have 2 buttons on a page: Save and Clear.

How do I clear values from the page if the Clear button is clicked?

 

Help would be greatly appreciated

 

My page:

<apex:page standardController="Case" showHeader="true" sidebar="true" extensions="RequestNewExtension"  tabStyle="New_Request__tab">
  <apex:form >
  <apex:sectionHeader subtitle="Create a Request">
  <div style="float:right">
        <span class="requiredExample">&nbsp;</span>
        <span class="requiredMark">*</span>
        <span class="requiredText"> = Required Information</span>
  </div>
    </apex:sectionHeader>


  <apex:pageMessages />  
    <apex:pageBlock >
        <apex:pageBlockButtons location="both">
                <apex:commandButton value="Save" action="{!Save}" />
                <apex:commandButton value="Clear" action="{!Cancel}" />
            </apex:pageBlockButtons>
<apex:pageBlockSection id="cas14" title="Request Subject/Description" collapsible="false" columns="2">

                 <apex:pageBlockSectionItem >
                <apex:outputLabel >Subject</apex:outputLabel>                
                <apex:inputField id="caseSubject" value="{!case.Subject}" style="width:90%" required="true" />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem > </apex:pageBlockSectionItem>
              
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >Description</apex:outputLabel>                  
                    <apex:inputField id="caseDescription" value="{!case.Description}" style="width:90%; height: 75px" required="true" />
                </apex:pageBlockSectionItem>               
                <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
                 </apex:pageBlockSection>
   
  <apex:pageBlockSection id="cas5" title="Request Detail:" collapsible="false" columns="2">
        <apex:pageBlockSectionItem >
                   <apex:outputLabel >Request Type</apex:outputLabel>                  
                   <apex:inputField id="caseType" value="{!case.Type}" required="true" />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>                            
                <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
                 </apex:pageBlockSection>
      <apex:inputHidden value="{!Comment}" id="theHiddenInput"/> 
                 
  </apex:pageBlock>
  </apex:form>
</apex:page>

 

My Extension:

 

public with sharing class RequestNewExtension {
    public String Comment
    {
        get;
        set;
    }
    public String Description
    {
        get;
        set;
    } 
    public String Subject
    {
        get;
        set;
    }
    public Boolean UseAssignmentRules
    {
        get;set;
    }
   
    public Case cs;
    ApexPages.StandardController controller;
   
    public RequestNewExtension (ApexPages.StandardController con)
    {
        controller = con;
        this.cs = (Case) con.getRecord();
    }
   
    public PageReference Save()
    {
        CaseComment com = new CaseComment();
        if(Comment.Length() > 0)
        {
            com.commentBody = Comment;
            com.ParentId = cs.Id;
            if(UseAssignmentRules == true)
            {
                AssignmentRule  AR = new AssignmentRule();
                AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
               
                //Creating the DMLOptions for "Assign using active assignment rules" checkbox
                Database.DMLOptions dmlOpts = new Database.DMLOptions();
                dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id;
                controller.getRecord().setOptions(dmlOpts);               
            }
            insert com;
        }
        String retURL = ApexPages.currentPage().getParameters().get('retURL');
        String CurrentId = ApexPages.currentPage().getParameters().get('id');
        PageReference redirectPG;
        if(retURL != null)
            redirectPG = new PageReference('/' + retURL);
        else if(CurrentId != null)
            redirectPG = new PageReference('/' + CurrentId);
       
        controller.Save();
       
         return Page.Request_Create_Thankyou;
    }
    public PageReference Cancel(){
return null;
}
 }

 

 

 

  • September 10, 2013
  • Like
  • 0

Our org has a search controller that pulls contacts by zipcode and city. I am trying to add the ability to search by State and Contact Owner. The class compiles and the test class passes with 80% coverage (not great, I know). But when I try to deploy into production, it's not recognizing Owner__r.Name. Can someone look into my code to see how I would properly reference the Contact Owner as another viable search option?? If the VisualForce page is needed, it can be provided.

 

Error:

 

Test_TerritorySearchController.testController() Class 167   Failure Message: "System.QueryException: Didn't understand relationship 'Owner__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.", Failure Stack Trace: "Class.TerritorySe...

 

Class:

public with sharing class TerritorySearchController
{
    public String searchType { public get; public set; }  
    public String searchValue { public get; public set; }
    public String zipcode { public get; public set; }
    public String state { public get; public set; }
    public String owner { public get; public set; }
    public String contactType { public get; public set; }  //Contact_Type__c
    public String statusType { public get; public set; } //Producer_Status__c / Prospect_Status__c
    
    public String citySearch { public get; public set; }
    public String citySearchResults { public get; public set; }
    public String citySearchSelected { public get; public set; }
    
    public String stateSearch { public get; public set; }
    public String stateSearchResults { public get; public set; }
    public String stateSearchSelected { public get; public set; }
    
    public String ownerSearch { public get; public set; }
    public String ownerSearchResults { public get; public set; }
    public String ownerSearchSelected { public get; public set; }
    
    public List<Contact> reps { public get; private set; }
    public Boolean mapView { public get; private set; }
    
    public TerritorySearchController()
    {
        this.reps=new List<Contact>();
        this.searchType = getParam('searchType', 'zipcode');
        this.searchValue = getParam('searchValue', '');
        this.zipcode = getParam('zipcode', '');
        this.state = getParam('state', '');
        this.owner = getParam('owner', '');
        this.contactType = getParam('contactType', '');
        this.statusType = getParam('statusType', '');
        this.citySearch = getParam('citySearch', '');
        this.citySearchResults = '';
        this.citySearchSelected = '';
        this.stateSearch = getParam('stateSearch', '');
        this.stateSearchResults = '';
        this.stateSearchSelected = '';
        this.ownerSearch = getParam('ownerSearch', '');
        this.ownerSearchResults = '';
        this.ownerSearchSelected = '';
        this.mapView = getBooleanParam('mapView', false);
    }
    
    public String getParam(String name, String defaultValue) {
        String value = ApexPages.currentPage().getParameters().get(name);
        return value == null ? defaultValue : value;
    }
    
    public Boolean getBooleanParam(String name, Boolean defaultValue) {
        String value = ApexPages.currentPage().getParameters().get(name);
        return value == null ? defaultValue : 'true'.equalsIgnoreCase(value);
    }
    
    public PageReference processSearch()
    {
        PageReference p=null;
        
        if (this.searchType=='city')
            p=searchCities();
        else if(this.searchType=='state')
                p=searchStates();
        else if(this.searchType=='zipcode')
                p=searchZips();
        else if(this.searchType=='owner')
                p=searchOwners();
            
        return p;
    }
    
    public PageReference searchZips()
    {
        List<String > lZips=new List<String>();
        lZips.add(this.searchValue);
        this.reps=getContactsByZip(lZips);
        return null;
    }
    
    public PageReference searchStates()
    {
        List <String > lStates = new List<String>();
        lStates.add(this.searchValue);
        this.reps=getContactsByState(lStates);
        return null;
    }
    
    public PageReference searchOwners()
    {
        List<String > lOwners=new List<String>();
        lOwners.add(this.searchValue);
        this.reps=getContactsByOwner(lOwners);
        return null;
    }
    
        public PageReference searchForCities()
    {
        String str='';
        this.citySearchResults='[';
        String strCity=this.citySearch; //Apexpages.currentPage().getParameters().get('citySearch');
        String strSOQL='SELECT Id, Name, City__c, State__c FROM Zip_Codes__c WHERE City__c LIKE \''+strCity+'%\' ORDER BY State__c LIMIT 10';
        System.debug(strSOQL);
        List<Zip_Codes__c> lZ=Database.query(strSOQL);
        Set<String> sZ=new Set<String>();
        
        for(Zip_Codes__c z : lZ)
        {
            str=z.City__c+', '+z.State__c;
            
            if(!sZ.contains(str))
            {
                if(sZ.size()>0)
                  this.citySearchResults=this.citySearchResults+',';
                  
                this.citySearchResults=this.citySearchResults+' { value: \''+z.Id+'\', label: \''+str.replace('\'', '\\\'')+'\'} ';
                sZ.add(str);
            }
        }
                    
        this.citySearchResults=this.citySearchResults+']';
        return null;
    }
    
    public PageReference searchCities()
    {
        this.reps=getContactsByCity(this.searchValue);
        return null;
    }

    public PageReference searchForStates()
    {
        String str='';
        this.stateSearchResults='[';
        String strState=this.stateSearch; //Apexpages.currentPage().getParameters().get('stateSearch');
        String strSOQL='SELECT Id, Name, City__c, State__c FROM Zip_Codes__c WHERE State__c LIKE \''+strState+'%\' ORDER BY City__c LIMIT 10';
        System.debug(strSOQL);
        List<Zip_Codes__c> lS=Database.query(strSOQL);
        Set<String> sS=new Set<String>();
        
        for(Zip_Codes__c s : ls)
        {
            str=s.City__c+', '+s.State__c;
            
            if(!sS.contains(str))
            {
                if(sS.size()>0)
                  this.stateSearchResults=this.stateSearchResults+',';
                  
                this.stateSearchResults=this.stateSearchResults+' { value: \''+s.Id+'\', label: \''+str.replace('\'', '\\\'')+'\'} ';
                sS.add(str);
            }
        }
                    
        this.stateSearchResults=this.stateSearchResults+']';
        return null;
    }

        public PageReference searchForOwners()
    {
        String str='';
        this.ownerSearchResults='[';
        String strOwner=this.ownerSearch; //Apexpages.currentPage().getParameters().get('ownerSearch');
        String strSOQL='SELECT Id, Owner__r.Name, City__c, State__c FROM Zip_Codes__c WHERE Owner__r.Name LIKE \''+strOwner+'%\' ORDER BY Owner__r.LastName LIMIT 10';
        System.debug(strSOQL);
        List<Zip_Codes__c> lO=Database.query(strSOQL);
        Set<String> sO=new Set<String>();
        
        for(Zip_Codes__c o : lO)
        {
            str=o.City__c+', '+o.State__c+', '+o.Owner__c;
            
            if(!sO.contains(str))
            {
                if(sO.size()>0)
                  this.ownerSearchResults=this.ownerSearchResults+',';
                  
                this.ownerSearchResults=this.ownerSearchResults+' { value: \''+o.Id+'\', label: \''+str.replace('\'', '\\\'')+'\'} ';
                sO.add(str);
            }
        }
                    
        this.ownerSearchResults=this.ownerSearchResults+']';
        return null;
    }

    public Integer getRepCount()
    {
        return this.reps.size();
    }
    
    private List<Contact> getContactsByZip(List<String> lZips)
    {   
        List<Contact> lContacts=new List<Contact>();
        
        if(contactType==null)
            contactType=''; 
        
        String strZipCodes=' \'0\'';
        String strSOQL='SELECT ID, Name, MailingStreet, MailingCity, MailingState, MailingPostalCode, MailingCountry, Phone, Email, Contact_Type__c, Prospect_Status__c, Producer_Status__c, Broker_Dealer_Name__c FROM Contact ';
        
        for(String s: lZips)
        {
            if(s.trim()!='')
            {
                strZipCodes=strZipCodes+' OR mailingpostalcode like \''+s+'%\' ';
                this.zipcode=s;
            }
        }
         
        strSOQL=strSOQL+' WHERE (MailingPostalCode like' + strZipCodes + ') ';
      //strSOQL=strSOQL+' AND SA_Status__c = \'NS REIT - Signed Selling Agreement\' ';
        strSOQL=strSOQL+' AND ( NS_Income_II_SA_Status__c = \'NS I2 - Signed Selling Agreement\' OR NS_HI_SA_Status__c = \'NS HI - Signed Selling Agreement\' )';
        strSOQL=strSOQL+' AND Contact_Type__c != \'POND List\' ';
        strSOQL=strSOQL+' AND Contact_Type__c != null ';
      //strSOQL=strSOQL+' AND contact.owner !=null ';
        
        //
        // Handle producer/prospect types.
        //
        
        if ('Un-Profiled'.equalsIgnoreCase(contactType)) {
            strSOQL += ' AND Contact_Type__c = \'Un-Profiled\' ';
        } else if ('All Producers'.equalsIgnoreCase(contactType)) {
            strSOQL += ' AND Contact_Type__c = \'Producer\'';
        } else if ('A Producers'.equalsIgnoreCase(contactType)) {
            strSOQL += ' AND Contact_Type__c = \'Producer\' AND Producer_Status__c like \'Producer A-%\'';
        } else if ('B Producers'.equalsIgnoreCase(contactType)) {
            strSOQL += ' AND Contact_Type__c = \'Producer\' AND Producer_Status__c like \'Producer B-%\'';
        } else if ('C Producers'.equalsIgnoreCase(contactType)) {
            strSOQL += ' AND Contact_Type__c = \'Producer\' AND Producer_Status__c like \'Producer C-%\'';
        } else if ('Sphere Of Influence Producers'.equalsIgnoreCase(contactType)) {
            strSOQL += ' AND Contact_Type__c = \'Producer\' AND Producer_Status__c like \'Sphere of Influence%\'';
        } else if ('All Prospects'.equalsIgnoreCase(contactType)) {
            strSOQL += ' AND Contact_Type__c = \'Prospect\'';
        } else if ('A Prospects'.equalsIgnoreCase(contactType)) {
            strSOQL += ' AND Contact_Type__c = \'Prospect\' AND Prospect_Status__c like \'Prospect A-%\'';
        } else if ('B Prospects'.equalsIgnoreCase(contactType)) {
            strSOQL += ' AND Contact_Type__c = \'Prospect\' AND Prospect_Status__c like \'Prospect B-%\'';
        } else if ('C Prospects'.equalsIgnoreCase(contactType)) {
            strSOQL += ' AND Contact_Type__c = \'Prospect\' AND Prospect_Status__c like \'Prospect C-%\'';
        } else if ('Sphere Of Influence Prospects'.equalsIgnoreCase(contactType)) {
            strSOQL += ' AND Contact_Type__c = \'Prospect\' AND Prospect_Status__c like \'Sphere of Influence%\'';
        }
        
        System.debug(strSOQL);
        lContacts=Database.query(strSOQL);
        return lContacts;
    }
    
    private List<Contact> getContactsByCity(String strCityState)
    {
        List<Contact> lContacts=new List<Contact>();
        Integer i=strCityState.lastIndexOf(',');
        
        if(i<1)
            return lContacts;
            
        String strCity=strCityState.substring(0, i).trim();
        String strState=strCityState.substring(i+1).trim().toUpperCase();
        
        System.debug('SELECT Id, Name FROM Zip_Codes__c WHERE City__c =\''+strCity+'\' AND State__c=\''+strState+'\' ORDER BY longitude__c');
        List<Zip_Codes__c> lZ=[SELECT Id,Name FROM Zip_Codes__c WHERE City__c=:strCity AND State__c=:strState ORDER BY longitude__c];
        List<String> lZips=new List<String>();  
        
        for(Zip_Codes__c z : lZ)
        {
            lZips.add(z.Name);    
        }
        
        lContacts=getContactsByZip(lZips);
        return lContacts;       
    }
    
    
    private List<contact> getContactsByState (List<String> lStates)
    {
        list<Contact> llContacts=new List<Contact>();
        
        if(contactType==null)
            contactType='';
        
        String strStates=' \'0\'';
        String strSOQL='SELECT Id, Name, City__c, State__c FROM Zip_Codes__c WHERE City__c=:strCity AND State__c=:strState ORDER BY City__c LIMIT 10';
        
      for(String s: lStates)
        {
            if(s.trim()!='')
            {
                strStates=strStates+' OR MailingState like \''+s+'%\' ';
                this.state=s;
            }
        }
        return llContacts; 
    }
    
    private List<Contact> getContactsByOwner(List<String> lOwner)
    {
        List<Contact> lllContacts=new List<Contact>();
        
         if(contactType==null)
            contactType='';
        
        String strOwner=' \'0\'';
        String strSOQL='select Id, Owner__r.Name, longitude__c, latitude__c, Territory__c, City__c, State__c from Zip_Codes__c WHERE Owner__r.Name=:strOwner';
        
        for(String o: lOwner)
        {
            if(o.trim()!='')
            {
                strOwner=strOwner+' OR Name like \''+o+'%\' ';
                this.owner=o;
            }
        }
        return lllContacts;
    }

    
    public Boolean getIsDisabledDownloadCSV() {
        return reps == null || reps.size() == 0;
    }
    
    public PageReference redirectToCSV() {
        processSearch();
        
        String documentData = '';
        documentData += '"Name",';
        documentData += '"Broker_Dealer_Name__c",';
        documentData += '"MailingStreet",';
        documentData += '"MailingCity",';
        documentData += '"MailingState",';
        documentData += '"MailingPostalCode",';
        documentData += '"Phone",';
        documentData += '"Email",';
        documentData += '"Last Completed Event",';
        documentData += '"Owner__r.Name",';
        documentData += '"Contact_Type__c"\r\n';
        
        for(Contact contact : reps) {
            documentData += '"' + contact.Name + '",';
            documentData += '"' + contact.Broker_Dealer_Name__c + '",';
            documentData += '"' + contact.MailingStreet + '",';
            documentData += '"' + contact.MailingCity + '",';
            documentData += '"' + contact.MailingState + '",';
            documentData += '"' + contact.MailingPostalCode + '",';
            documentData += '"' + contact.Phone + '",';
            documentData += '"' + contact.Email + '",';
            documentData += '"' + contact.Last_Event_Date__c + '",';
            documentData += '"' + contact.Owner + '",';
            documentData += '"' + contact.Contact_Type__c + '"\r\n';
        }
        
        Document document = new Document();
        document.Body = Blob.valueOf(documentData);
        document.ContentType = 'text/csv';
        document.FolderId = UserInfo.getUserId();
        document.Name = 'Territory Search - CSV Export - ' + DateTime.now().format() + '.csv';
        insert document;
        
        PageReference pageReference = new PageReference('/servlet/servlet.FileDownload?file=' + document.Id);
        pageReference.setRedirect(true);
        return pageReference;
    }
    
    public String getMapViewUrl() {
        PageReference pageReference = System.Page.TerritorySearch;
        pageReference.getParameters().put('searchType', searchType);
        pageReference.getParameters().put('searchValue', searchValue);
        pageReference.getParameters().put('zipcode', zipcode);
        pageReference.getParameters().put('contactType', contactType);
        pageReference.getParameters().put('statusType', statusType);
        pageReference.getParameters().put('citySearch', citySearch);
        pageReference.getParameters().put('stateSearch', stateSearch);
        pageReference.getParameters().put('ownerSearch', ownerSearch);
        pageReference.getParameters().put('mapView', 'true');
        return pageReference.getUrl();
    }
}

 Test Class:

@isTest
private class Test_TerritorySearchController 
{

    static testMethod void testController()
    {
        TerritorySearchController tsc=new TerritorySearchController();
        tsc.searchValue='00001';
        tsc.searchType='zipcode';
        tsc.processSearch();
        //System.assertNotEquals(tsc.getRepCount(), 0);
        
        tsc.contactType='Prospect';
        tsc.statusType='Prospect A- $1M+ potential business/yr';
        tsc.processSearch();
        //System.assertNotEquals(tsc.getRepCount(), 0);

        tsc.contactType='Producer';
        tsc.statusType='Producer A- $1M+ potential business/yr';
        tsc.processSearch();
        //System.assertNotEquals(tsc.getRepCount(), 0);
        
        tsc.contactType='Prospect';
        tsc.statusType='Prospect B- $1M+ potential business/yr';
        tsc.processSearch();
        //System.assertNotEquals(tsc.getRepCount(), 0);

        tsc.contactType='Producer';
        tsc.statusType='Producer B- $1M+ potential business/yr';
        tsc.processSearch();
        //System.assertNotEquals(tsc.getRepCount(), 0);
        
        
        tsc.contactType='Prospect';
        tsc.statusType='Prospect C- $1M+ potential business/yr';
        tsc.processSearch();
        //System.assertNotEquals(tsc.getRepCount(), 0);

        tsc.contactType='Producer';
        tsc.statusType='Producer C- $1M+ potential business/yr';
        tsc.processSearch();
        //System.assertNotEquals(tsc.getRepCount(), 0);
        
        
        tsc.contactType='Prospect';
        tsc.statusType='Prospect Sphere of Influence- $1M+ potential business/yr';
        tsc.processSearch();
        //System.assertNotEquals(tsc.getRepCount(), 0);

        tsc.contactType='Producer';
        tsc.statusType='Producer Sphere of Inlfuence- $1M+ potential business/yr';
        tsc.processSearch();
        //System.assertNotEquals(tsc.getRepCount(), 0);

        tsc.searchValue='Ridgefield, CT';
        tsc.searchType='city';
        tsc.zipcode='';
        tsc.processSearch();
        //System.assertNotEquals(tsc.getRepCount(), 0);
        
        tsc.searchValue='Sean Briceno';
        tsc.searchType='owner';
        tsc.processSearch();
        //System.assertNotEquals(tsc.getRepCount(), 0);
        
        tsc.searchZips();
        tsc.getRepCount();
        
        tsc.citySearch='West';
        tsc.searchForCities();
        
        tsc.searchCities();
        tsc.searchForCities();
        
        tsc.searchStates();
        tsc.searchForStates();
        
        tsc.searchOwners();
        tsc.searchForOwners();
        
        tsc.redirectToCSV();
        tsc.getMapViewUrl();
    }
}

 

Hi All

 

I've been trying to get this run for a while now but cant get it. I'm not a fulltime apex programmer. I need help of all you veterans here in this discussion board.

 

I am trying to write a trigger on the Contact object that would fetch the values of one of the AccountTeamMember who has a profile 'P1'. To an extent, the debug values are fetching what I am trying to pull from the AccountTeamMember but am stuck in the last part of the code. I am getting the following error when I try to save the Contact record:

 

Apex trigger SetContact_ASD_Life_User caused an unexpected exception, contact your administrator: SetContact_ASD_Life_User: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 003E000000GvOz0IAF; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 003E000000GvOz0) is currently in trigger SetContact_ASD_Life_User, therefore it cannot recursively update itself: []: Trigger.SetContact_ASD_Life_User: line 25, column 1

 
And here is the code:

trigger SetContact_ASD_Life_User on Contact (before insert, before update) {
    Id AccId = null;
    Id uid = null;
    Id cid = null;
    List<Contact> con = trigger.old;
    List<User> users;

    for(integer i = 0; i<trigger.size;i++){
        AccId = con[i].AccountId;
        List<AccountTeamMember> atm = [SELECT UserId FROM AccountTeamMember where TeamMemberRole='ASD-Life' AND AccountId=:AccId limit 1]; 
        if(atm!=null){
                cid = con[i].Id;
                System.Debug('Contact Id is '+cid);
                AccountTeamMember m = atm[0];
                System.Debug('MSG ASD Life User '+ m.UserId);    
                if(m.UserId!=null){uid = m.UserId;}
                System.Debug('uid is : ' + uid);
                users = [Select Username from User where Id=:m.UserId ];                        
        }       
      }
    
    Contact[] cont = [Select Id, ASD_Life_User3__c, Email from Contact where Id=:cid limit 1]; 
    System.Debug('Contact Email is ' + cont[0].Email);
    cont[0].ASD_Life_user3__c = uid;
    update(cont);
 
 }

 

Any suggestions how to fix this?

 

thanks

gm


this should be so simple, but as i'm not any kind of OOP developer, and do not know java, c++ and/or apex, i have no idea what the issue might be... i get Compile Error: Invalid type; baseMOCharge at line 27....

 

any help is greatly appreciated.

public class MOCharge{

   public static decimal[] getMOCharge(boolean stdWin, 
                                       boolean spcWin, 
                                       boolean dblWin,
                                       boolean noWin,
                                       boolean MOWinDie,
                                       decimal wrkPerMQty,
                                       decimal wrkQty,
                                       decimal closureCharge,
                                       List<Mfg_Run_Charges__c> mrcRC1){

      decimal[] charges = new decimal[]{0,0};
      decimal baseMOCharge = 0.0;
      
      for(Mfg_Run_Charges__c MO : mrcRC1) {
         if (MO.Process_Code__c=='MO' && MO.Min_Qty__c <=wrkQty && MO.Max_Qty__c >=wrkQty){
            baseMOCharge = (MO.Set_Up_Cost__c / WrkPerMQty) + (MO.Run_Rate__c / (MO.Qty_per_Hour__c / 1000) );
            if ((noWin) || (stdWin && MOWinDie)){
               charges[0] = baseMOCharge + closureCharge;
            }else{
               if (dblWin){
                  if (!MOWinDie){
/// BELOW LINE IS WHERE THE INVALID TYPE ERROR OCCURS....
                     charges[0] = (baseMOCharge) + MO.Punch_Patch_Setup__c + (MO.Punch_Patch_M__c * WrkPerMQty); 
                     charges[1] = MO.Miscellaneous_Charge__c;
                  }else{
                     charges[0] = (((baseMOCharge) + MO.Punch_Patch_Setup__c + (MO.Punch_Patch_M__c * WrkPerMQty))+ ClosureCharge) * MO.Special_Window__c; 
                  }
               }else{
                  if (SpcWin){
                     if (!MOWinDie){
                        charges[0] = (baseMOCharge) + MO.Punch_Patch_Setup__c + (MO.Punch_Patch_M__c * WrkPerMQty) + ClosureCharge; 
                        system.debug('SpcWin - No MO Die: ' + charges[0] + ', ' + MO.Per_M_Charge__c + ', ' + MO.Punch_Patch_Setup__c + ', ' + MO.Punch_Patch_M__c);
                     }else{
                        system.debug('before charges[0]: ' + charges[0]);
                        charges[0] = ((baseMOCharge) + ClosureCharge ) * MO.Special_Window__c;
                        system.debug('wtf??? charges[0],ClsrChg,MO.SpclWin,: ' + charges[0] + ', ' + closureCharge + ', ' + MO.Special_Window__c);
                     }
                  }else{
                        charges[0] = (baseMOCharge) + MO.Punch_Patch_Setup__c + (MO.Punch_Patch_M__c * WrkPerMQty); 
                  }    
               }
            }
         break;
         }
      }
    return charges;
    }
 }

 

Hi Everyone,

I am trying to create a trigger that updates a field (Passed_Test_Count__c on the Employee__c Object.  It will update the field by adding +1 each time another field Passed_Date__c on the Team_Member_Test_Result__c changes from null to an actual date.  Listed below is my code, any help is greatly appreciated!

 

 

trigger PassedTestCounter on Team_Member_Test_Result__c (after insert, after update) {
{
Map<Id,Id> TeamMemberResultsMap = new Map<Id,Id>();
for(Team_Member_Test_Result__c A : trigger.new)
TeamMemberResultsMap.put(A.Passed_Date__c,A.Id);

List<Employee__c> EmployeeToUpdate = new List<Employee__c>{};

for (Employee__c Employee: [SELECT Id,Passed_Test_Count__c FROM Employee__c WHERE Id IN: TeamMemberResultsMap.keySet()])
{
Id empId = TeamMemberResultsMap.get(EmployeeToUpdate.Id);
Employee__c emp = trigger.newMap.get(empId);

boolean transition = trigger.IsInsert || (trigger.isUpdate && trigger.oldMap.get(emp.Id).Passed_Date__c != emp.Passed_Date__c);
if (emp.Passed_Date__c != null){
EmployeeToUpdate.Passed_Test_Account__c = EmployeeToUpdate.Active_Count__c.Passed_Test_Account__c + 1 ;
EmployeeToUpdate.add(EmployeeToUpdate);
}else if (emp.Passed_Date__c == 'null') {
EmployeeToUpdate.Active_Count__c = EmployeeToUpdate.Active + 0;
EmployeeToUpdate.add(Employee);
}
}
if(EmployeeToUpdate.Active_Count__c != null && !EmployeeToUpdate.Active_Count__c.isEmpty())
Database.update(EmployeeToUpdate.Active_Count__c);
}
}

 

 

 

Thank you!!

I'm trying to update a field in "Account" if insert one "Asset" called AR.

 

I tried to create the trigger in "Asset", but it doesn't work.

 

Any help?

 

Hi All,

 

This is with respect to over all usage of a particular org.

The requirement is that i have to get records of "all modifications" done by "all users" after logging in.

It is similar to "setup audit trail", however we are extrapolating it to the complete instance and to all users and activity that they might have done.

For e.g. user A logged in at 19.00 hrs and edited "Account", etc ........

 

Hope i was able to articulate clearly.

 

Many thanks in advance,

 

Regards,

Anidev

  • March 09, 2013
  • Like
  • 0

I have a simple Visualforce page that I am using to override the case view. When I click "new" case comment, I get the dialog and upon saving it states 

"Review the errors on this page.

missing required field: [ParentId]"

Full code of my Visualforce page below:

<apex:page standardController="Case" id="page" lightningStylesheets="true">
    <apex:detail subject="{!Case.ID}" relatedList="true" inlineEdit="true" />
</apex:page>

 

Anyone run into this before? Issue is only present in Lightning. 

 

 

Hi All, this is a Lightning question.

I am wondering how to prepopulate / preset field values in a standard page layout using standard "New" functionality. Use case:

I have a Parent Object and a Child Object. The Child object should derive it's record type dynamically from the parent object.

    E.g. a picklist on the Parent has the values Type A, Type B, Type C

When a new child record is created from the parent, I would like to dynamically set the record type of the child to A, B, C.

The page layouts are different for each A, B and C. I would like to use the standard functionality of "New Child" to create these records. 

Quick Actions: do not allow dynamic binding of record type. They also do not have the capability to use standard page layouts. So having a unique button per record type is unacceptable. 

URL Hacks: Work great in classic - unsupported in LEX. 

Thanks in advance. 

Is there anyway to include VF pages in a "Site.com" site?  

Is there anyway to include a "Site.com" site in a VF page? 

I am not referring Force.com Sites. I am referring to the "Site.com studio" pages. https://github.com/developerforce/Site.com-Quick-Start
Anyone have issues with debug logs? I have turned mine all the way down to NONE or ERROR level and am getting a log size of 3,967 bytes with the message that the "MAXIMUM DEBUG LOG SIZE REACHED". Any input would be great.
The request to create a new opportunity line item through the web service API (salesforce.com/servlet/servlet.Api) is throwing an error if there are any field updates on the Opportunity Product object. 

A workflow or approval field update caused an error when saving this record. Contact your administrator to resolve it.

common.exception.SfdcSqlException: ORA-20067: OPPORTUNITY_LINEITEM.TOTAL_PRICE
ORA-06512: at "SLEEPY.SOPPLINEITEM", line 1211
ORA-06512: at line 1

If there are no workflow rules enabled, there is no error. Please advise.

I have a unique requirement. There is a desire to perform a screenscrape from a VisualForce page and email it out.

 

I've looked into rendering as PDF and it is not an option. 

 

Is there a method to convert a VF page to HTML in order to email it out as the email body? 

 

OR

 

Is there a method to perform a screenscrape (e.g. screenshot) of a VisualForce page and email it out?

 

Thanks in advance! 

 

I have a simple VisualForce component that is not displaying encrypted data properly. 

According to the docs: "Warning:Encrypted custom fields that are embedded in the component display in clear text. The component doesn't respect the View Encrypted Data permission for users. To prevent showing sensitive information to unauthorized users, use the tag instead." Reference: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_outputText.htm

My VisualForce component is as follows and has been added to a standard page layout:    

<apex:page standardController="My_Custom_Object__c">
   <apex:outputText value="{!My_Custom_Object__c.My_Encrypted_Field__c}"/ >
</apex:page>

 

It is displaying information encrypted with or without the View Encrypted Data permission and I would like it to display unencrypted. Please advise. 

Thank you!

I have a rest resource configured similar to below. I would like to be able to read the attributes that are passed in with each element, but have not found a way to do this. It appears that SF automatically maps the elements of the request into the user defined object and does not appear to allow me to access any of the attributes. Is there a method to access the original payload?

 

Ideally, I'd like to be able to access project and method from the request as logic is dependent on these fields. 

 

<request project="MyProject" method="NewTest">

     <Field1 attribute1="123">test</Field1>

</request>

 

@RestResource(urlMapping='/test/*')
    global class test{
          @HttpPost
          global static List<String> n(UserDefinedObject UDO){
                RestRequest req = RestContext.request;
                system.debug(req); //does not contain payload
                system.debug(UDO); //Already parsed out object - all attributes are gone

 

Thanks!

So I've created a Rest API like below and I need to have it return all values wrapped in Cdata. Is there an easy way to toggle on cdata? Or do I need to explicitly wrap each field using an xml writer? Even if I pass in cdata values it gets removed on the response due to the deserialization.

 

Thanks in advance! 

 

@RestResource(urlMapping='/echo/*')
global class echo{
    @HttpPost
    global static MyClass echo(MyClass c){
    return c;
  }

   global virtual class MyClass{
     global String s1;
     global String s2;
     global String s3;
     global String s4;
   }
}

 

Request looks like this

Hi,

I'm moving my production data to sql server, working on data migration. In my org, there is a Text(Encrypted) field, I want to see that field values. As i used that field in apex class, I'm unable to change the field type. Please suggest me how to Decrypt the data. 
Hi guys,
In my environmet I have activated the Web-to-Lead function, I created the html form and I tried to insert a new lead.
After I select the “Send” button happens that the form becomes completely white. I have to close this form to correctly display the fields and repeat the insert.
The data inserted into the form are properly stored in Salesforce. 
I had already used the function in the past and I was successful.

This is the code of file html:
<!--  ----------------------------------------------------------------------  -->
<!--  NOTA: aggiungere il seguente elemento <META> alla pagina <HEAD>.  Se    -->
<!--  necessario, modificare il parametro charset per specificare il set di   -->
<!--  caratteri della pagina HTML.                                            -->
<!--  ----------------------------------------------------------------------  -->

<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">

<!--  ----------------------------------------------------------------------  -->
<!--  NOTA: aggiungere il seguente elemento <FORM> alla pagina.               -->
<!--  ----------------------------------------------------------------------  -->

<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

<input type=hidden name="oid" value="00D58000000HP9I">
<input type=hidden name="retURL" value="http://">

<!--  ----------------------------------------------------------------------  -->
<!--  NOTA: questi campi sono elementi di debug facoltativi. Rimuovere        -->
<!--  l'identificativo di commento da queste righe se si desidera eseguire    -->
<!--  un test in modalità di debug.                                           -->
<!--  <input type="hidden" name="debug" value=1>                              -->
<!--  <input type="hidden" name="debugEmail" value="d.rinaldo@be-tse.it">     -->
<!--  ----------------------------------------------------------------------  -->

<label for="first_name">Nome</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>
<label for="last_name">Cognome</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>
<label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br>
<label for="mobile">Cellulare</label><input  id="mobile" maxlength="40" name="mobile" size="20" type="text" /><br>
<label for="company">Società</label><input  id="company" maxlength="40" name="company" size="20" type="text" /><br>
<label for="city">Città</label><input  id="city" maxlength="40" name="city" size="20" type="text" /><br>
<label for="state">Stato/Provincia</label><input  id="state" maxlength="20" name="state" size="20" type="text" /><br>
<input type="submit" name="submit">
</form>


Please, could somebody help me?
Thanks
Daniela
I have a problem I don’t know how to solve and hoping someone can help.  I have an object which is a services log for clients that have had services.  The service log contains customer ID, date of service, type of service, etc.
I need to create a list of unique client IDs who have had services last month for the first time in the current fiscal year.  I have to run this on a monthly basis so dates can't be hardwired.
Hopefully someone has a brilliant solution.  Thank you.
 
Dear All,
I have a field called " Opportunity Name" ( field name " opportunity")in the quote object, which is a look up to the opp object.

User-added image
I want that, when i create a Task from this quote, the opp name ( which is actually a auto -number set )

User-added image

In the task field, the opp number should get reflected. I have created a look up field in the Task object " opportunity" ( also a text datatype field " Opportunity Number" , whichever would convenient to bring the value)
I tried the process builder and work flow with various options but the issue is in teh Task object, the value is not geting reflected. can anyone suggest a way ?

User-added image
I have to change the record type name but i do not know in what components it has been used. Is there any way to find the usage of a particular record type in all the components of the org. for example workflows Approval process validation rule etc.
I am attempting to retrieve the HTML Rich Text field "Content" from ContentNote object, but results are not rich text. The closest I can get is the following query:
Select TextPreview, Content from ContentNote where id = '069...'
TextPreview gives me the text, but not HTML. Content gives me an alphanumeric coded field, but not rich text.

What I need is the actual text with HTML codes like a rich text field. What field/object can I query to retrieve the rich text from the content note object? If I can't, is there a trigger I can write to migrate that value on another object that I can query with rich text?
Are we able to upgrade picklists choices to 600 instead of 500?
Initially I copied lead fields into lead custom fields after that I'm trying map Name and Email fields to Opportunity custom fields..

trigger mapping on Lead (after update) 
{
    Opportunity opp=new Opportunity();
    for(Lead ll:Trigger.New)
    {
        if(ll.isconverted==true)
        {
            opp.Client_Name__c=ll.Name;
            opp.Client_Email__c=ll.Email;
        }
        insert opp;
    }
}

This is working but opportunity fields not getting added. 

please suggest me if any one knows, find below my code.

i am facing error :"Error:Apex trigger cloudRevenueForcastTrigger caused an unexpected exception, contact your administrator: cloudRevenueForcastTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a1Q4B0000008PPGUA2; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, cloudRevenueForcastTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a1Q4B0000008P7qUAE; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, cloudRevenueForcastTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 1 with id a1Q4B0000008P5pUAE; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a1Q4B0000008P5p) is currently being saved. Saving object (id = a1Q4B0000008P5p) would cause it to be recursively saved, which is not allowed.: [] Class.cloudRevenueForcastTriggerHandler.updateSegmentValue: line 85, column 1 Trigger.cloudRevenueForcastTrigger: line 14, column 1: [] Class.cloudRevenueForcastTriggerHandler.updateSegmentValue: line 85, column 1 Trigger.cloudRevenueForcastTrigger: line 14, column 1: []: Class.cloudRevenueForcastTriggerHandler.segmentValueUpdate: line 62, column 1"

Public void updateSegmentValue(List<Cloud_Revenue_Forecast__c> newList){
        
        set<string> crfIds = new set<string>();
        set<string> segmenttype = new set<string>();
        List<Cloud_Revenue_Forecast__c> updateRecords = new List<Cloud_Revenue_Forecast__c>();
        
        for(Cloud_Revenue_Forecast__c c : newList){            
            if(c.Segment_Value__c != null){
                crfIds.add(c.Id);
                segmenttype.add(c.Segment_Type__c);
            }            
        }
        Map<Id, Cloud_Revenue_Forecast__c> arSegmentValueMap = new Map<Id, Cloud_Revenue_Forecast__c>();        
        aggregateResult[] sumSegmentValue = [select sum(Segment_Value__c)cnt from Cloud_Revenue_Forecast__c where segment_type__c IN :segmenttype];        
        List<Cloud_Revenue_Forecast__c> uniquesegmentrecords = new List<Cloud_Revenue_Forecast__c>([select id, Segment_Value__c from Cloud_Revenue_Forecast__c where segment_type__c IN :segmenttype ]);
                
        for(Cloud_Revenue_Forecast__c c : uniquesegmentrecords){
            c.Segment_Value__c = (Decimal)sumSegmentValue[0].get('cnt');
            updateRecords.add(c);
        }
        update updateRecords;        
    }  
I need an instance of an Address() for testing, but the constructor takes no arguments. What is the best way to handle this?
I am aware that Trigger can process in chunks of 1-200 records at a time, is there any way we can increase this record count?

Here is my case: I am inserting 10,000 records from Test class
and my Trigger has 4 SOQL queries, as Triggers are processed in chunks of 200 records, my Trigger will be fired 50 times in this case. However, in each call my SOQL will get accumulated towards SOQL limits and Trigger will fail when it is called 26th time with SOQL limit exception.

In my Trigger I need to have 4 SOQL anyhow and I cannot reduce that, I know that Batch is the best solution in such scenarios but my application need this processing in real time.

Any solution or workaround is highly appreciated.
 
Using SOSL query we can fetch 2000 records, but can fetch 10000 records using SOSL query? If not possible then is there any other way  to do so? 
All,

I'm working on a project for a dynamic search of clients using Jeff Douglas's blog as a template

http://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/

I have everything displayed correctly, but when I go to search, the debug soql query doesn't seem to be adding the search letter I type with the wild card. If you look at the demo here:

https://jeffdouglas-developer-edition.na5.force.com/examples/CustomerSearch

you can see that when a letter is entered, the debug soql changed to add that new search to the original soql.

From:
select firstname, lastname, account.name, interested_technologies__c from contact where account.name != null order by lastName asc limit 20
To:
select firstname, lastname, account.name, interested_technologies__c from contact where account.name != null and firstname LIKE 'a%' order by lastName asc limit 20

Does anybody have any idea why my search doesn't seem to be firing when the 'OnKeyUp' function is executed? I feel like it may have something to do with the 'escapeSingeQuotes' method or the LIKE.

Here is a snippet of my code:

// runs the search with parameters passed via Javascript
  public PageReference runSearch() {
      
    String FirstName = Apexpages.currentPage().getParameters().get('FirstName');
    String LastName = Apexpages.currentPage().getParameters().get('LastName');
    String Broker = Apexpages.currentPage().getParameters().get('Broker_Dealer_Name__c');
    String MailingCity = Apexpages.currentPage().getParameters().get('MailingCity');
    String MailingState = Apexpages.currentPage().getParameters().get('MailingState');
    String MailingPostalCode = Apexpages.currentPage().getParameters().get('MailingPostalCode');
    String OwnerName = Apexpages.currentPage().getParameters().get('Owner.Name');
    String NSIncomeProducerStatus = Apexpages.currentPage().getParameters().get('Producer_Status__c');
    String NSIncomeIIProducerStatus = Apexpages.currentPage().getParameters().get('NS_Income_II_Producer_Status__c');
    String NSIncomeHIProducerStatus = Apexpages.currentPage().getParameters().get('NS_HI_Producer_Status__c');

    soql = 'select FirstName, LastName, Broker_Dealer_Name__c, MailingStreet, MailingCity, MailingState, 
MailingPostalCode, Owner.Name, Phone, Total_Sales__c, Producer_Status__c, NS_Income_II_Producer_Status__c, 
NS_HI_Producer_Status__c FROM Contact Where Broker_Dealer_Name__c !=null';

    if (!FirstName.equals(''))
      soql += ' and FirstName LIKE \''+String.escapeSingleQuotes(FirstName)+'%\'';
    if (!LastName.equals(''))
      soql += ' and LastName LIKE \''+String.escapeSingleQuotes(LastName)+'%\'';
    if (!Broker.equals(''))
      soql += ' and Broker_Dealer_Name__c LIKE \''+String.escapeSingleQuotes(Broker)+'%\'';
    if (!MailingCity.equals(''))
      soql += ' and MailingCity LIKE \''+String.escapeSingleQuotes(MailingCity)+'%\'';  
    if (!MailingState.equals(''))
      soql += ' and MailingState LIKE \''+String.escapeSingleQuotes(MailingState)+'%\'';
    if (!MailingPostalCode.equals(''))
      soql += ' and MailingPostalCode LIKE \''+String.escapeSingleQuotes(MailingPostalCode)+'%\''; 
    if (!OwnerName.equals(''))
      soql += ' and Owner.Name LIKE \''+String.escapeSingleQuotes(OwnerName)+'%\'';
    if (!NSIncomeProducerStatus.equals(''))
      soql += ' and Producer_Status__c = (\''+NSIncomeProducerStatus+'\')';
    if (!NSIncomeIIProducerStatus.equals(''))
      soql += ' and NS_Income_II_Contact_Type__c = (\''+NSIncomeIIProducerStatus+'\')';
    if (!NSIncomeHIProducerStatus.equals(''))
      soql += ' and NS_HI_Contact_Type__c = (\''+NSIncomeHIProducerStatus+'\')';
  
    // run the query again
    runQuery();

    return null;
  }

User-added image

Hi All,

Having issues with the Echosign in the local sandbox. The Documetns sent by EchoSign are not showing Up in the Local sandbox but those are there in the production. Any one can help us regarding this?

Thanks In advance
What is the easiest way of moving data from Sandbox to developer environment? I have some tables such as leads, campaigns, ..., which have custom fields. Is there a way to move the data automatically, rather than creating the custome objects in the destination envirtoment and then go through export and import?
Hello,

Every time I delete a record in SF shared by a Salesforce-to-Salesforce connection the publishing organization is notified via email of the deletion. Can this email notification be disabled somehow?

Thank you!
  • January 09, 2014
  • Like
  • 0