• CoryCowgill
  • NEWBIE
  • 99 Points
  • Member since 2010

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 23
    Replies

Hi Guys,

 

              I have small question regarding cloning the records, when you clone any record how do you know if the record is cloned or if it is created manually,is there any sort of flag or something placed on recored when you clone or what is the way to know if it is created by clone button, and if we clone any record is there any way to restrict some fields while cloning, for example we have a field called Amount in Opp and it has some value but when you clone the record you want to clear that field....................Any kind of help is appreciated

I want to implement the following logic:

 

If A == 'Off', then don't display inputField;

if A == 'On', then display inputField but make inputField not required

If A=='On/Required', then display inputField and make inputField required

 

I have the following code:

 

<apex:inputField value="{!B}" required="{IF(A =='On/Required', true, false)}" rendered="{!A != 'Off'}" />

 

It doesn't work. Can anyone point out where it went wrong?

 

Thanks in advance,

I'm trying to get the class code to throw an error if the country code is not equal to "US" or "CA".  For some reason I get the error on everything with the statement below.  Any ideas?

 

 

if(caseNo.Contact.MailingCountry != 'US')// || caseNo.Contact.MailingCountry != 'CA')
                {ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Sales Order cannot be created, no shipping outside the US or Canada.');
                        ApexPages.addMessage(msg);
                        ErrorFlag=true;
                }

 

 

  • August 10, 2010
  • Like
  • 0

I'm new to SF. I'm trying to import some basic info to do a demo to our sales team. I have some opportunties I would like to import. When I use the data loader, it  says "ID VALUE OF INCORRECT TYPE." I am trying to link these opportunties to the accts that I have uploaded. Any suggestions on how to do this? Thanks!

  • August 31, 2010
  • Like
  • 0

Hi,

 

Is it possible to fire an Apex trigger on a Task sObj when a user clicks the Edit button?   I'd like to be able to have a trigger automatically put the date (System.today()) in The Task's Description field.   Right now my trigger event is defined as "before insert", but this won't update the Task.Description field until after the Task Save button is clicked.   That's too late :)

 

Any ideas??   Thanks as always for your collective support.

 

Best regards,

-P 

  • August 31, 2010
  • Like
  • 1

how to create a Master-Detail relationship field it shows error

 

You cannot create a new Master-Detail relationship on an existing custom object if records already exist. You must first create a Lookup relationship, populate the lookup field with data in all records, and then change the relationship type to Master-Detail.

Hi,

I have a trigger on Account object in production environment. Although i have tried deactivating that trigger using n number of ways. But its not getting deactivated.

Now, i have lots of Account data to get uploaded using data loader. And i want that trigger not to fire.

Do we have any way to keep that trigger silent and let the complete data upload?? Thanks

I have a trigger that runs on lead update (when a lead is converted to a contact.) . We use demand tools to dedupe leads to leads and then leads to contacts. When we run demand tools its giving me this error

 

UpdateContactOnLeadUpdate: execution of AfterUpdate

 

caused by: System.Exception: Too many SOQL queries: 101

 

Trigger.UpdateContactOnLeadUpdate: line 13, column 25

 

I am pasting the code for my trigger below. Line 13 is where I am getting the recordTypes . Its a single query. I am not sure why its causing this error. 

 

 

trigger UpdateContactOnLeadUpdate on Lead (after Update)
{
  List<String> conIds = new List<String>();
  List<String> leadIds = new List<String>();
  
  Map<String,Lead> leadMap = new map<String,Lead>();
  Map<String,Contact> contactMap = new map<String,Contact>();
  List<Key_Event__c> keyEventsToInsert = new List<Key_Event__c>();
  List<Lead_Key_Event__c> keyEventsToDelete = new List<Lead_Key_Event__c>();
  
  List<Contact> consToUpdate = new List<Contact>();
  
  RecordType[] recType = [Select Id, Name, SobjectType from RecordType 
                                            Where SOBjectType =: 'Key_Event__c'];line13
  
    For(Lead lead : Trigger.new)
    {
        //the lead is just converted
        if(lead.IsConverted == true && Trigger.oldMap.get(lead.Id).IsConverted == false)
        {
          leadIds.add(lead.Id);
          
          leadMap.put(lead.Id,lead);
          
          conIds.Add(lead.ConvertedContactId);
        }
    }
    
    //get the key events for the leads
    List<Lead_Key_Event__c> leadKeyEvents = [Select k.Auto_Demo_Field_1__c,k.Appt_Scheduled_Date__c, k.Auto_demo_Field_2__c,k.Lead_Confirmed_by_RM_NAM__c, 
                      k.Best_time_to_contact_prospects__c,k.Contact_Sales_Comments__c, 
                      k.CreatedById, k.CreatedDate, k.Id, k.IsDeleted, k.Key_Event_Type__c, 
                      k.LastModifiedById, k.LastModifiedDate, k.Lead__c, k.Lead_Created_Date__c, k.Name, 
                      k.Primary_Business_Pain__c, k.Purchase_decision_timeframe__c, 
                      k.Score__c, k.SystemModstamp, k.Trade_Show_Comments__c, k.Webinar_date__c, 
                      k.Webinar_request_date__c, k.Webinar_status__c from Lead_Key_Event__c k where Lead__c IN: leadIds Order By k.CreatedDate ASC];   
    
    
    
    
            //get the contact associated with the lead
    Contact[] contacts = [select Id , Last_KE_Date__c , CPM_Autodemo__c , White_Paper_Download__c,
              Contact_Sales_Request_Form__c,Purchase_Decision_Pending__c ,Recorded_Webinar__c,
              Webcast__c,Webinar__c, AccountId,pi__score__c
                         from Contact Where Id IN :conIds ];
                         
    //set the contact map                     
    For(Contact con : contacts)
    {
      contactMap.put(con.Id,con);
    }
    
    //run through all the lead key events and create corresponding key events for contacts/accounts
    For(Lead_Key_Event__c ke : leadKeyEvents)
    {
      Lead leadObject = leadMap.get(ke.Lead__c);
      Contact contactObject = contactMap.get(leadObject.ConvertedContactId);
    
      Key_Event__c keyEvent = new Key_Event__c();
      keyEvent.Contact__c = contactObject.Id;
      keyEvent.Account__c = contactObject.AccountId;
      keyEvent.Auto_Demo_Field_1__c = ke.Auto_Demo_Field_1__c;
      keyEvent.Auto_demo_Field_2__c = ke.Auto_demo_Field_2__c;
      keyEvent.Best_time_to_contact_prospects__c = ke.Best_time_to_contact_prospects__c;
      keyEvent.Contact_Sales_Comments__c = ke.Contact_Sales_Comments__c;
      keyEvent.Key_Event_Type__c = ke.Key_Event_Type__c;
      keyEvent.Lead_Created_Date__c = ke.Lead_Created_Date__c;
      keyEvent.Name = ke.Name;
      keyEvent.Primary_Business_Pain__c = ke.Primary_Business_Pain__c;
      keyEvent.Purchase_decision_timeframe__c = ke.Purchase_decision_timeframe__c;
      keyEvent.Score__c = ke.Score__c;
      keyEvent.Trade_Show_Comments__c = ke.Trade_Show_Comments__c;
      keyEvent.Webinar_date__c = ke.Webinar_date__c;
      keyEvent.Webinar_request_date__c = ke.Webinar_request_date__c;
      keyEvent.Webinar_status__c = ke.Webinar_status__c;
      keyEvent.Appt_Scheduled_Date__c = ke.Appt_Scheduled_Date__c;
      keyEvent.Lead_Confirmed_by_RM_NAM__c = ke.Lead_Confirmed_by_RM_NAM__c;
      
      String recTypeToSearch;
      
      if(keyEvent.Name == 'Auto Demo')
        recTypeToSearch = 'Key Event Auto Demo';
      if(keyEvent.Name == 'Auto Demo Click Through')
        recTypeToSearch = 'Key Event Auto Demo';
      if(keyEvent.Name == 'White Paper Download')
        recTypeToSearch = 'Key Event White Paper Download';
      if(keyEvent.Name == 'Contact Sales request form')
        recTypeToSearch = 'Contact Sales Request form layout';
      if(keyEvent.Name == 'Purchase Decision pending')
        recTypeToSearch = 'Purchase decision pending';
      if(keyEvent.Name == 'Recorded Webinar')
        recTypeToSearch = 'Recorded webinar';
      if(keyEvent.Name == 'Webcast Attendence')
        recTypeToSearch = 'Webcast attendence';
      if(keyEvent.Name == 'Webinar Request')
        recTypeToSearch = 'Webinar Request';
      if(keyEvent.Name == 'Trade Show')
        recTypeToSearch = 'TradeShow';
      if(keyEvent.Name == 'Webinar Attendence')
        recTypeToSearch = 'Webinar Attendence';
      if(keyEvent.Name == 'Webinar Registration')
        recTypeToSearch = 'Webinar Registration';
      if(keyEvent.Name == 'Appointment Scheduled')
        recTypeToSearch = 'Appointment Scheduled';
      if(keyEvent.Name == 'Appointment Attended')
        recTypeToSearch = 'Appointment Attended';
        
      
      For(RecordType rec : recType)
        {
            if(rec.Name == recTypeToSearch)
                keyEvent.RecordTypeId = rec.Id;
        }
  
      if(contactObject.Last_KE_Date__c == null || (contactObject.Last_KE_Date__c < keyEvent.Lead_Created_Date__c))
        contactObject.Last_KE_Date__c = keyEvent.Lead_Created_Date__c;
      
      if(leadObject.pi__score__c != null)
        {
          if(contactObject.pi__score__c == null)
            contactObject.pi__score__c = leadObject.pi__score__c;
          else
            contactObject.pi__score__c += leadObject.pi__score__c;
        }
      
      List<Contact> refinedContacts = new List<Contact>();
      For(Integer i = 0 ; i < consToUpdate.size() ; i++)
      {
        if(consToUpdate[i].Id != contactObject.id)
        {
          refinedContacts.add(consToUpdate[i]);
        }
      }
      consToUpdate = refinedContacts;
      
      consToUpdate.add(contactObject);
      keyEventsToInsert.add(keyEvent);
      keyEventsToDelete.add(ke);
      
    }
      
    if(keyEventsToInsert.size() > 0)
      insert keyEventsToInsert;  
      
    if(consToUpdate.size() > 0)
      update consToUpdate;
      
    if(keyEventsToDelete.size() > 0)
      delete keyEventsToDelete;
}

 

 

 

 

How do you get access in APEX to the same global variables that are available in formulas and VisualForce. I'm looking for a non-SOQL based way to access this org-wide and environment-based settings. Particularly, is there a corresponding settings variable to $RecordType?

  • August 24, 2010
  • Like
  • 0

Sorry, I'm a bit of a newbie to SFDC development but was wondering if someone has a solution that I can use to roll-up data from a related list without a master-detail relationship between the two objects. I can't seem to find the answer on any existing discussion threads although there are a few people trying to similar things. 

 

The situation:

I have a related list of Contracts (standard object) on a custom object, Instruments. These Contracts have an End Date which I would like to roll-up to the associated Intrument record. Essenially I would like to show the MAX(Contract.End_Date) on the Instrument record for all Contracts assosciated with that Instrument. 

 

Obviously a Roll-up Summary Field won't work here because of the lack of a master-detail relationship, so I was thinking an APEX Trigger is the only option. Does any one have suggestions on how this can be accomplished? Do I need to go the APEX Trigger Route or is there an easier option? And if I have to use an APEX trigger, do you have any code examples I can reuse?


Thanks for your help!
Cam

May I please have advice on loading baseline data? Any tricks, gotcha's, land mines?

 

We need to build a script to insert a baseline set of data so the Developer Sandboxes can be of some value.

 

Thanks in advance for input.

  • August 12, 2010
  • Like
  • 0

Hello,

 

I am trying to create a HTML email that goes out when a new contact is added.  I need this email to contain all the contacts related to the account of the contact just added.  Below is the code i am using which is only displaying the contact that is added and no other contacts from the account.  Any help would be greatly appreciated.

 

 

<messaging:emailTemplate subject="New Contact Created" recipientType="User" relatedToType="Contact">
<messaging:htmlEmailBody >  
<html>
        <body>
         <STYLE type="text/css">
               TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
               TD  {font-size: 11px; font-face: verdana } 
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE>
         <font face="arial" size="3">

           <p>Dear Lisa,</p>
               <p>A new contact has been added, How excited are you? Below should be a list of related contacts, but probably not. <a href="https://na1.salesforce.com/{!relatedTo.accountid}">{!relatedTo.account.Name}.</a></p>
           <table border="0" >
                 <tr > 
                     <th>Action</th><th>Contact</th><th>Gift Code</th><th>Create Date</th><th>Create By</th>
                  </tr>
             <apex:repeat var="cx" value="{!relatedTo}">
               <tr>
                   <td><a href="https://na1.salesforce.com/{!cx.id}">View</a> |  
                   <a href="https://na1.salesforce.com/{!cx.id}/e">Edit</a></td>
                   <td>{!cx.Firstname} {!cx.Lastname}</td>
                   <td>{!cx.Gift_Code__c}</td>
                   <td>{!cx.createdDate}</td>
                   <td>{!cx.createdby.Firstname}</td>
                   
               </tr>
               
            </apex:repeat>            
           </table>
               <p />
         </font>
        </body>
    </html>
  </messaging:htmlEmailBody>  
</messaging:emailTemplate>

 

 

Hi

 

I have following lines of code:

 

var obj1:SObject = _crObjectArrayJoined[0]; // First Index 0  has 1 Sobject
var obj2:SObject = _crObjectArrayJoined[1]; //Second SObject

 

Can you please give me any suggestions on how to merge these two object into one in AS3?

 

Cheers.

 

 

  • August 11, 2010
  • Like
  • 0

Hi,

 

We are trying to put together a join registration form for our business that will have the information for the customer stored in Salesforce.  The process the customer goes through is quite extensive and 9 times out of 10 would need to log into the registration form at a later date to complete it.  

 

We are looking at implementing  this in one of two ways, the first is to do this in a Force.com site that would load the customer details and save everything in an account/opportunity object, the downside we see with this is the restrictions with the design side of it.  The alternative is to write the application in ASP.NET and save/load the details through the Salesforce API, concerned about the time it takes to save through the API.  In the past we have developed in both so this is not an issue.

 

What are peoples thoughts? Which is the better more robust solution a Force.com site or writing the Salesforce API?

 

Thank you in advance for your advice,

 

-Jason

  • August 11, 2010
  • Like
  • 0

Hi Guys,

 

              I have small question regarding cloning the records, when you clone any record how do you know if the record is cloned or if it is created manually,is there any sort of flag or something placed on recored when you clone or what is the way to know if it is created by clone button, and if we clone any record is there any way to restrict some fields while cloning, for example we have a field called Amount in Opp and it has some value but when you clone the record you want to clear that field....................Any kind of help is appreciated

Greetings,

 

Wondering if the following is possible via Apex coding -

 

I have some functioning Apex code that fires on a button-click.  At the conclusion of that code, I'd like to pass/relinquish control to the save process, (via "update obj" or other construct).  I say relinquish, because I'd like any validation rules / workflow rules to execute normally - (outside of Apex, as if the user themselves clicked "Save").  Whether the record actually is 'Saved' or generated errors is unimportant to this procedure.

 

Is this possible?  Thanks for any information / assistance.

 

Pete  

All,

 

I have a field  name " channel " (picklist ). if  some value is selected from Picklist ( lets say " location ")i have to display on bottom of the picklist one text field.

 

How to do that. please help me. Thanks in Advance team .

 

sam.

 

 

 

 

I want to implement the following logic:

 

If A == 'Off', then don't display inputField;

if A == 'On', then display inputField but make inputField not required

If A=='On/Required', then display inputField and make inputField required

 

I have the following code:

 

<apex:inputField value="{!B}" required="{IF(A =='On/Required', true, false)}" rendered="{!A != 'Off'}" />

 

It doesn't work. Can anyone point out where it went wrong?

 

Thanks in advance,

Hi All,

 

I created a custom object in an enterprise edition of Salesforce. I have added few custom fields to it. When I click on the custom object tab, I do not see "new" button to create new records.I did the same thing in developer edition, and I can see "new" button in the developer edition. Could anyone please tell me why "new" button is not visible for custom object? your help is greatly appreciated.

  • August 10, 2010
  • Like
  • 0