• Osiris77706
  • NEWBIE
  • 49 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 40
    Replies

I'm attempting to create a scheduled job programatically using system.schedule but I'm running into issues. I'm trying to pass the parameters "Schedule Name",  "Schedule Time" and "Class Name" from strings from an object in SFDC. The problem is I don't know exactly how to change a string into an object. 

This is what I have so far:
 
 //Iterate through list of job descriptions
 For(Manage_ScheduleJobs__c addJobs : schJobs)
 {
 //Get class name and job name
 string ClassName = addJobs.Class_Name__c;
 string jobName = addJobs.Job_Name__c;
 
 //Attempt to change string to class
 object classDev = ClassName;

//Get the id of the new scheduled job
Id jobId = System.schedule(jobName, '0 0 0 * * ?', new classDev());
}
What am I doing wrong?
Thanks.

 

Hi all,

 

I created a custom object called Lead Contact.  It is located on the Lead Object.  When we have multiple Leads from the same company, we add the extra Leads to the Lead Contact object.  Once the Parent Lead is converted, all Lead Contacts need to be converted to Contacts and assigned to the Parent Account.

 

We also have a custom object called Locations that will be moved over upon conversion of the Lead.

 

The trigger works great in the Sandbox, but I cannot get over 65% coverage in production.  Any suggestions?

 

Trigger:

 

trigger LeadContactConvertAcc on Account (after insert, after update) {

    Account a = [select Id, Lead_Convert_Id__c from Account where Id = :Trigger.new[0].Id limit 1];

    if(a.Lead_Convert_ID__c != NULL) {
      
    Lead l = [select Id from Lead where Id = :a.Lead_Convert_Id__c Limit 1];
        
            for (Lead_Contact__c lc : [Select id, Converted_Account_ID_del__c, First_Name__c,
                   Last_Name__c,Title__c,Email__c,Secondary_Email__c,Phone__c,Fax__c,
                   Mobile__c,Mailing_Street__c,Mailing_City__c,Mailing_State__c,
                   Mailing_Zip__c,Mailing_Country__c 
                   FROM Lead_Contact__c 
                   WHERE Parent_Lead_ID_del__c = :a.Lead_Convert_Id__c]) 
                   
                   {
                           
                   Contact newContact = new Contact (
                     AccountId = a.Id,
                     FirstName = lc.First_Name__c,
                     LastName = lc.Last_Name__c,
                     Title = lc.Title__c,
                     Email = lc.Email__c,
                     Secondary_Email__c = lc.Secondary_Email__c,
                     Phone = lc.Phone__c,
                     Fax = lc.Fax__c,
                     MobilePhone = lc.Mobile__c,
                     MailingStreet = lc.Mailing_Street__c,
                     MailingCity = lc.Mailing_City__c,
                     MailingState = lc.Mailing_State__c,
                     MailingPostalCode = lc.Mailing_Zip__c,
                     MailingCountry = lc.Mailing_Country__c);
                     
                   insert newContact;  
                   
                   lc.Parent_Name_del__c = null;
                   
                   update lc;
     
                   }   
                   
            for (Location__c ln : [select Id, Lead__c, Account__c 
                from Location__c 
                WHERE Lead__c = :a.Lead_Convert_Id__c]) {
                
                ln.Account__c = a.Id;
                
                update ln;
                
     }        
   }
  }

  Class:

 

 

public class LeadContactConvert {

static testMethod void LeadContactConvert() {

Id a1Id;
Id l1Id;
Id lnId;
Id lcId;
Id c1Id;
Id c2Id;

    // CREATE LEAD
    Lead l1 = new Lead();
    
        l1.Lastname='leaddata';
        l1.Company='nav';
        l1.Leadsource='Calling Campaign';
        l1.IsConverted = false;
        l1.IsUnreadByOwner = true;
        l1.Status = 'qualified';
        
        Database.insert(l1);
        l1Id = l1.id;
       

    //CREATE LEAD CONTACT
    Lead_Contact__c lc = new Lead_Contact__c ();
      
        lc.First_Name__c = 'test';
        lc.Last_Name__c = 'test';
        lc.Title__c = 'test';
        lc.Email__c = 'test@test.com';
        lc.secondary_Email__c = 'test2@aol.com';
        lc.Phone__c = '1111111111';
        lc.fax__c = '2222222222';
        lc.Mobile__c = '3333333333';
        lc.Mailing_Street__c = '123 Main St';
        lc.Mailing_City__c = 'Phoenix';
        lc.Mailing_State__c = 'AZ';
        lc.Mailing_Zip__c = '85083';
        lc.Mailing_Country__c = 'USA';
        lc.Parent_Name_del__c = l1.Id;
       
       
       Database.insert(lc);         
       lcId = lc.id;
   
    //CREATE LOCATION
    Location__c  ln = New Location__c ();
      
      ln.Street__c = '123 test';
      ln.City__c = 'Test';
      ln.State__c = 'az';
      ln.zip__c = '11111';
      ln.Entrances_Required__c = 'test';
      ln.Location__c = 1;
      ln.Proposed_Demarc__c = 'test';
      ln.Account__c = NULL;
      ln.Lead__c = l1.Id;
          
      Database.insert(ln);
      lnId = ln.id;
       
    //CREATE ACCOUNT   
    Account a1 = new Account();
        a1.name = 'AName';
        a1.type = 'Prospect';
        a1.Lead_Convert_ID__c = l1.Id;
        
        Database.insert(a1);
        a1Id = a1.Id;
    
     //CREATE CONTACT 1
     Contact c1 = new Contact ();
      
       c1.LastName = l1.Lastname;
       c1.Email = 'test@aol.com';
       c1.Phone = '9999999999';
       c1.AccountId = a1.id;
       
       Database.insert(c1);            
       c1Id = c1.id; 
    
    
    //CREATE CONTACT 2
    Contact c2 = new Contact ();
      
        c2.FirstName = lc.First_Name__c;
        c2.LastName = lc.Last_Name__c;
        c2.Title = lc.Title__c;
        c2.Email = lc.Email__c;
        c2.Secondary_Email__c = lc.Secondary_Email__c;
        c2.Phone = lc.Phone__c;
        c2.Fax = lc.Fax__c;
        c2.MobilePhone = lc.Mobile__c;
        c2.MailingStreet = lc.Mailing_Street__c;
        c2.MailingCity = lc.Mailing_City__c;
        c2.MailingState = lc.Mailing_State__c;
        c2.MailingPostalCode = lc.Mailing_Zip__c;
        c2.MailingCountry = lc.Mailing_Country__c;
        c2.AccountId = lc.Converted_Account_ID_del__c;
       
       Database.insert(c2);            
       c2Id = c2.id;     
     
               
// Account a = [select Id, Lead_Convert_Id__c from Account where Lead_Convert_Id__c = :l1.Id limit 1];
      
//      Lead_Contact__c lc1 = [Select id, Converted_Account_ID_del__c, First_Name__c,
//                   Last_Name__c,Title__c,Email__c,Secondary_Email__c,Phone__c,Fax__c,
//                   Mobile__c,Mailing_Street__c,Mailing_City__c,Mailing_State__c,
//                   Mailing_Zip__c,Mailing_Country__c 
//                   FROM Lead_Contact__c 
//                   WHERE Parent_Name_del__c = :a.Lead_Convert_Id__c]; 
      
      Contact newContact = new Contact (
      AccountId = a1.Id,
      FirstName = lc.First_Name__c,
      LastName = lc.Last_Name__c,
      Title = lc.Title__c,
      Email = lc.Email__c,
      Phone = lc.Phone__c,
      Fax = lc.Fax__c,
      MobilePhone = lc.Mobile__c,
      MailingStreet = lc.Mailing_Street__c,
      MailingCity = lc.Mailing_City__c,
      MailingState = lc.Mailing_State__c,
      MailingPostalCode = lc.Mailing_Zip__c,
      MailingCountry = lc.Mailing_Country__c);
       
      insert newContact; 
        
      lc.Parent_Name_del__c = null;
       
        update lc; 
        
      ln.Account__c = a1.Id;
      
        update ln;  
        
     }
   
}

 

 

Thank you in advance for any assistance.

 

Levi

 

Hello,

     I'm modifying an existing APEX class to search through existing location objects to determine if a new one needs to be created in a particular situation. When I try to save the new code, I get the following error : Error: Compile Error: Invalid type: Schema.Location at line 189 column 34. My first guess based on research was that i must have the wrong name for the location object. Note here that i am using the standard SFDC Location object. As far as i can tell, the name is simply "Location" no more / no less, According to SFDC documentation and Our Enterprise WSDL. Second guess is that myself or whatever user is 'compiling' the code on save must not have permission to the Location object. I double checked that myself and API User both have access, they do. I'm at a brick wall here. I've simplified to code on the line in question to simply: "List<Location> locList = [Select id from Location ];" and I’m still getting the error. I then switched to the following:
1) List<Location> locList = new List<Location>();
2) locList = [Select id from Location];
I tried splitting the statement into two lines in order to better pinpoint the issue, in this situation I get the error on the second line, the query line, like I can create a list of locations, but I cannot populate it with a very basic select all query.

Does anyone have any idea on what could be going on here?

Thanks!
Hello,

      I'm currently developing a .net SFDC Web Service that creates new Assets based on a table that an ERP populates on a nightly basis. Without realizing it, on the first run the Service used up all of our API calls. I'm wondering if anyone knows of a way to programatically check the current API usage within the service ? the idea is that i'll only let the rest of the code run if i'm under 60% or so if API usage.
Hello,

    What I’m trying to do is create a trigger that sets a checkbox field (True/False) on Opportunity called "Is New Customer". This trigger should grab the accountID that is associated with the Opportunity that fired the trigger. It should then search for the most recent Opportunity with that same Account attached to it. If the Opportunity has a close date longer than 5 years ago, it should mark the "Is New Customer" as true on the Opportunity that fired the trigger. Now I believe that I have the trigger coded correctly, but I’m having some trouble with the test class. Here’s my code.

TRIGGER:

trigger setIsNewCustomer on Opportunity (after update, after insert)
{

for (Opportunity opp: trigger.new)
    {
        List<Opportunity> past_opps = new List<Opportunity>([select id, AccountId, IsNewCustomer__c, IsWon FROM Opportunity WHERE AccountId =: opp.AccountId AND IsWon = True ORDER BY CloseDate DESC LIMIT 1]);
      
        if(past_opps.size() < 1)
        {
            opp.IsNewCustomer__c = True;
        }
        for(Opportunity o: past_opps)
        {
            if(o.CloseDate <= date.today().addDays(-1825))
            {
                opp.IsNewCustomer__c = True;

            }

        }
      
          
        upsert opp;
    }
  
}

TEST CLASS

@isTest
private class setNewCustomerTest {
  static testMethod void testIsNewCustomer()
  {
     Opportunity a = new Opportunity(Name='testOpp', StageName ='testStage', closeDate = (date.today().addDays(10 * 365 * -1)));
   
     insert a;
   
   
   
     Opportunity[] opp_list = new List<Opportunity>();
             
    
      opp_list.add(new Opportunity(Name='testOpp', StageName ='testStage', closeDate = (date.today().addDays(10 * 365 * -1))));
      opp_list.add(new Opportunity(Name='testOpp', StageName ='testStage', closeDate = (date.today().addDays(7 * 365 * -1))));
      opp_list.add(new Opportunity(Name='testOpp', StageName ='testStage', closeDate = (date.today().addDays(6 * 365 * -1))));
      opp_list.add(new Opportunity(Name='testOpp', StageName ='testStage', closeDate = (date.today().addDays(5 * 365 * -1))));
      opp_list.add(new Opportunity(Name='testOpp', StageName ='testStage', closeDate = (date.today().addDays(3 * 365 * -1))));
      opp_list.add(new Opportunity(Name='testOpp', StageName ='testStage', closeDate = (date.today().addDays(2 * 365 * -1))));

      for(Opportunity opp: opp_list){
          insert opp;
      }
         
      List<Opportunity> opp_list2 = new List<Opportunity>([select id, AccountId, IsNewCustomer__c FROM Opportunity WHERE AccountId = '0013000000InnFdAAJ']);
    
      for (Opportunity o : opp_list2)
          {
               System.debug('Is New Customer, after insert' + o.IsNewCustomer__c);
          }
    
    
       for(Opportunity opp2: opp_list2){
          insert opp2;
      }

  }

}

ERROR

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, setIsNewCustomer: execution of BeforeInsert

caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old

Trigger.setIsNewCustomer: line 23, column 1: []


I am relatively new to Apex triggers and test classes, so I am kind of stuck on this one. Also I understand that my test class may not be very thorough. I’m hoping someone here can give me a little help with this error and maybe a push in the right direction for a better test class.

Thank You!

Hello,



My organization is working with Cincom Systems Inc. and have installed the
"Cincom Sales and Product Configurator" From the app Exchange. We are
developing a configurator for our sales team to use in conjunction with
salesforce. The Package abve comes with a few custom buttons that are used on
the Quote object and Quote Line Item object. One of these buttons is throwing a
javascript error. Cincom was unable to assist me in figuring out exactly why
such an error would occour, but they were able to assist me in debugging the
issue down to a particular line of code where the error originated., the code
behind the button, and the particular line the error originates at below:



HERE is the code behind the button.



{!requireScript("/soap/ajax/22.0/connection.js")}



function GetCRMConfiguratorURL() 

{

var queryResult = sforce.connection.query("SELECT C_SPC__Protocol__c,
C_SPC__ServerName__c, C_SPC__Directory__c FROM
C_SPC__CRM_Configurator_Setup__c"); 

return (queryResult != null && queryResult.size > 0) ?
queryResult.getArray("records")[0].get("C_SPC__Protocol__c")
+ "://" + queryResult.getArray("records")[0].get("C_SPC__ServerName__c")
+ "/" +
queryResult.getArray("records")[0].get("C_SPC__Directory__c")
: "http://localhost/CRMConfigurator";


} 



function GetDefaultApplicationId() 

{

window.alert("Starting GetDefaultApplicationID");

window.alert("recordIds[0].substring(0,15) = " +
recordIds[0].substring(0,15) );

**********************************************************************************************************************************************

var queryResult = sforce.connection.query("SELECT PricebookEntryId FROM
QuoteLineItem WHERE Id = '" + recordIds[0].substring(0,15) +
"'");

***********************************************************************************************************************************************

window.alert("PriceBook queryResult.size=" + queryResult.size);

var pricebookEntryId = (queryResult.size > 0) ?
queryResult.getArray("records")[0].get("PricebookEntryId")
: null;

if (pricebookEntryId == null) return null;

queryResult = sforce.connection.query("SELECT Product2Id FROM
PriceBookEntry WHERE Id = '" + pricebookEntryId + "'");

window.alert("Product2 ID queryResult.size=" + queryResult.size);

var productId = (queryResult.size > 0) ?
queryResult.getArray("records")[0].get("Product2Id") :
null;

if (productId == null) return null;

queryResult = sforce.connection.query("SELECT
C_SPC__ProductApplicationId__c FROM Product2 WHERE Id = '" + productId +
"'");

window.alert("product applicationID queryResult.size=" +
queryResult.size);

var productApplicationId = (queryResult.size > 0) ?
queryResult.getArray("records")[0].get("C_SPC__ProductApplicationId__c")
: null;

if (productApplicationId == null) return null;

var today = GetDateToday();

queryResult = sforce.connection.query("SELECT Id,
C_SPC__BeginEffectiveDate__c FROM C_SPC__Application__c WHERE
C_SPC__ProductApplicationId__c = '" + productApplicationId + "' ORDER
BY C_SPC__RevisionNumber__c DESC");

window.alert("Application query queryResult.size=" +
queryResult.size);

for (var i = 0; i < queryResult.size; i++)

{

var beginEffectiveDate =
queryResult.getArray("records")[i].get("C_SPC__BeginEffectiveDate__c");

if (beginEffectiveDate == null || beginEffectiveDate == '' ||
beginEffectiveDate <= today)

return queryResult.getArray("records")[i].get("Id");

}

return null;

}



function GetDateToday() 

{

var dateToday = new Date();

var monthToday = dateToday.getMonth() + 1; if (monthToday < 10) monthToday =
"0" + monthToday;

var dayToday = dateToday.getDate(); if (dayToday < 10) dayToday =
"0" + dayToday;

return dateToday.getFullYear() + '-' + monthToday + '-' + dayToday;

}



window.alert("Starting");

var recordIds = {!GETRECORDIDS($ObjectType.QuoteLineItem)};

if (recordIds == null || recordIds.length ==0)

alert("Please select a quote line item.");

else if (recordIds.length > 1)

alert("Please select only one quote line item.");

else

{

var queryResult = sforce.connection.query("SELECT C_SPC__ApplicationId__c
FROM C_SPC__ConfigurationDna__c WHERE C_SPC__QuoteLineItemId__c = '" +
recordIds[0].substring(0,15) + "'");

window.alert("recordIds[0].substring(0,15) NEW = " +
recordIds[0].substring(0,15) );

window.alert("queryResult.size= " + queryResult.size);

var applicationId = (queryResult.size > 0) ?
queryResult.getArray("records")[0].get("C_SPC__ApplicationId__c")
:

GetDefaultApplicationId();

window.alert("Aplication ID");

if (applicationId == null || applicationId == '')

alert("The quote line item Product is not configurable.");

else

window.parent.location.href = GetCRMConfiguratorURL() +
'/CRMConfiguratorPage.aspx?CrmType=2&QuoteLineItemId='+recordIds+'&ApplicationId='+applicationId+'&SessionId={!$Api.Session_ID}&ServerURL={!$Api.Partner_Server_URL_220}&ReturnURL='+window.parent.location.href;

window.alert("window.parent");

}

 

 






HERE is the line of code that is throwing the error:

var queryResult = sforce.connection.query("SELECT PricebookEntryId FROM
QuoteLineItem WHERE Id = '" + recordIds[0].substring(0,15) +
"'");

 

 




In order to see the line in context, it is denoted by lines of '*' in the code
above.



The error is as follows:



A Problem with the OnClick JavaScript for this button or link was encountered.

{faultcode:'sf:INVALID_TYPE', faultstring:'INVALID_TYPE:sObject type
'QuoteLineItem' is not supported.',
detail:{exceptionCode:'INVALID_TYPE',exceptionMessage:'sObject type
'QuoteLineItem' is not supported.', row:'-1',},},}

 

 

 

Hello Everyone,

 

      I'm trying to do something with a custom button, but I'm a little lost in how I should go about doing this. I have two custom buttons in my quote object, the first is "Submit\Revise", the second is called "Baan". There is also a custom field that this process is going to be using, its called status. When a new quote is created, the status will be set to new. By default the Baan Button should be somehow locked out/disabled. Once the user completes the quote they can press the "Submit\Revise" button, this will change the status to "Submitted" And will enable the Baan Button.

 

Does anyone have any suggestions for doing this ?

 

Thank You,

Greg Coley

I'm trying to make a related list on the Quote object, the type of list should be a Bill To Address, now I believe Bill To Address is a custom made thing for my companies salesforce, it is originally found in the account, but I'm not sure. I have made a field in Quote that is a look-up relationship for type BIll To Address, When I try to add the related list to the quote page however, I can't seem to find the related list in the related list in the toolbox for editing the page layout.

 

Does anyone know what it is im doing wrong ?

This is probably a dumb question, but where is the products page ? I see from looking under my apps > customize > products , that there is indeed a product object but I can figure out how to get to it. I assumed that there was a page very similar to opportunity, lead, and account that would let you edit/view a list of products, but I can't seem to locate it.

 

I did, however see that you can add a product to an opportunity, although it asks me to choose a price book but there are none. Where do I add a pricebook ?

Hello all,

 

     My company is investigating the Sf quote object, And are wondering how one would do the following:

We want the Bill to and ship to addresses to be imported from the associated account, and a new address (the sold to address) to be imported from the associated opportunity object as soon as someone hits the 'Create New Quote' button.

 

Thank you for your help,

Greg Coley

Okay, this is my goal. We have an object called SFDC_Project__c. i'm investigating a way to retrieve all the 'projects' once a day. i need this data so that i can put it into our sqlserver database, from here we can develop various reports that can be put on our intranet site. unfortunately it almost seems like salesforce does not want you to do: A) Mass Exports on a daily basis, or B) Mass queries from a PHP script. there is a huge chance that i'm going about this the wrong way, does anyone have any suggestions ?

It seems like all the information is saying that i cannot put a dashboard into force.com site and have users see the dashboard without logging in , but salesforce support says that i can. does anybody know how i would go about doing this ?

Okay so I'm trying to get a dashboard to show up in a totally non-salesforce site (company intranet). My first thought was to right click on the dashboard grab the URL that is the source and use that as the source in my <img> tag on the intranet website. To my amazement, it worked, the dashboard showed up in a nonsalesforce site. After a bit of tinkering I have come to the conclusion that the dashboard only displays properly if I have another tab open in the same web browser logged into salesforce.

 

My Question: "How do I get Dashboards to show up outside of salesforce without making the user sign in  to salesforce somewhere ?"

So i have been using the system log window, to directly execute Apex code for maintence, for instance:

 

- clearing out a large number of leads older that 2 years.

- poping open and saving a large number of leads to fire a trigger.

 

Has anyone else used this window in a similiar fasion ?  is this a really bad practice  (besides the obvious possibilty of deleting stuff that you didnt mean to) ? it seems like such a valuable resource, a console for executing scrpts, but i can't help but think i shouldnt be in there doing that, or theres another way to perform such maintenance. The scariest part is that every user has access to that window, so anyone could potentially go in and delete all the leads or opportunities, or even wipe out the whole Db if they knew a little code ! is there a way to disable this window for all users except the admins ? 

okay so im getting this error:

 

Compile Error: line 19, column 7: Invalid foreign key relationship: Lead.createdDate

 

 

with this code:

 

it comes from the part where i compare each aspect of CreatedDate to my variables.

     

 

 

public with sharing class stuff {
Date   oldThreshold = Date.newInstance(2010, 1, 1); 
String newStatusForOldLeads = 'Archive-Omitted';

   
List<Lead> oldLeads = [select id, createdDate, status, isConverted
from Lead where status = 'open' OR status = 'working'];

List<Lead> leadsToUpdate = new List<Lead>();


{
if(oldLeads.size() > 0)
{
 
 for(Lead currentLead: oldLeads)
 {  
  integer compareyear = 2010;
integer comparemonth = 1;
integer compareday = 1;
  //Date x = currentLead.CreatedDate.Date;
  
  if (currentLead.CreatedDate.year < compareyear &&
     currentLead.CreatedDate.month < comparemonth &&
     currentlead.CreatedDate.day < compareday)
     {
    
     
     
      currentLead.status = newStatusForOldLeads;  
      leadsToUpdate.add(currentLead);
 


       
     }
  }
}

if(leadsToUpdate.size() > 0)
{
update(leadsToUpdate);
}
 


}
}

 

I don't get it ?

I'm trying to use system.debug() thdisplay the number of records my trigger has changed. im using an integer counter that increases everytime a record is changed, and at the end it is displayed. the only problem is that debug is not displaying.

 

here's my code:

 

/*  This is a bulk Trigger designed to change the status of leads created before
 *  a pre-determined date to a pre-determined status automatically
 *
 * @Author: Greg Coley
 * @Created: July 20th 2010
 */

//Fires on the succesfull update of a lead
trigger oldLeadBulkStatusUpdate on Lead (after insert)
{
    //the status to be put in place of the older leads current status
      String newStatusForOldLeads;
   
   
    //set the new status below in format('Status goes between single quotes like this')
     newStatusForOldLeads = 'Dead';

   
    //the list that will hold the selected list
      List<Lead> oldLeads;

   
    //search for all the leads whose status we havent changed yet, because salesforce limits us to pulling only 1000
    //objects at a time from the db, we mus limit our search results, i limit to 900...just in case.
    oldLeads = [select id, createdDate, status, isConverted from Lead where status !=: newStatusForOldLeads limit 900];
     

   
   
   
    //Do not change this line.
    for (Lead ld: trigger.new)
  {
      //Create the counter, which will be used to tell us how many records we have updated.
      Integer changeCounter;
     
           
      //the predetermined date that qualifies a lead as 'old'
      Date   oldThreshold;
     
     
     
    
     //set the threshold date below in format(YYYY,MM,DD)
     oldThreshold = Date.newInstance(2010, 12, 31);
    
         
     //initialize the counter to zero
      changeCounter = 0;
     
     
      // provided the search returns any results we loop through the results and change the status
      // for the lead to the predetermined status, as long as the leads created date is before
      // the pre determined date.
      if(oldLeads.size() > 0){
      for(Lead currentLead: oldLeads)
      {
     
      if (currentLead.CreatedDate < oldThreshold && currentLead.isConverted == false)
        {
          currentLead.status = newStatusForOldLeads;
          update(currentLead);
          changeCounter++;
        }
       
            }
      }
      //throws feedback to the system log
        system.debug(' ________________________________________________________________ ');
        system.debug('|Updated: '+ changeCounter +' Records out of a possible 900                                        |');
        system.debug('|================================================================ |');
        system.debug('|Note: if the two numbers above are the same you probably have to                               |');
        system.debug('|run again. when the first number is 0, all updates are finished.                                      |');
        system.debug('------------------------------------------------------------------------------------------------------------------');
     
      
  }

 


}

Okay so my code looks like this :

 

/* Apex Trigger: createNewProjectForOpportunnity
 * @ Author: Greg Coley
 * @ Contact: gjc5@students.pti.edu (or) gcoley@conairgroup.com
 *
 * @ Info: This trigger is designed to automatically generate an object of type
 *         SFDC_Project__ in salesforce.com.
 *
 */

// this trigger fires before the inserting or updating of a new object of type opportunity
trigger createNewProjectForOpportunity on Opportunity (before insert, before update)
{

 //Create an temporary variable of type SFDC_Project__c
 SFDC_Project__c tempProject;


  //Grab the Opportunity object that fired the trigger. assign to variable "opp"
  for (Opportunity opp: trigger.new)
  {
     
    //check to see if "opp" is null, it should'nt be, but just in case.
    if (opp != null)
    {
      //use SFDC_Project__c 's parameterized constructer to auto fill fields
      //using the data from "opp" 's fields.
      tempProject = new SFDC_Project__c(SFDC_Project_Name__c = opp.Name);
                                       
                                       
    //Check to see if tempProject 's SFDC_Project_Start_Date__C
    //is set to null. if this is the first creation of the project, the field will
    //be null. otherwise, the object will just be updating, and there is no
    //need to update the start date
    if(tempProject.SFDC_Project_Start_Date__c == null)
    {
        //asign project start date to today.
        tempProject.SFDC_Project_Start_Date__c = Date.Today();
    }
                                       
     
      // only upsert (which means insert if it doesnt exist already, and update
      // if it does exist) if the project object is not null, again it shouldnt be
      // but, just in case.
      if (tempProject != null)
      {
      upsert(tempProject);
      }

    
    }

  }

 
 

 

 

 
 }and instead of making just one object of type Project, it makes two that are identical, except ofcourse an auto number field....perhaps im missing a syntax mistake ?

     Okay I'm trying to access the object that fired my trigger, from the trigger. For instance:

 

1) a new object of type Opportunity is created.

2) my trigger is fired

3) my trigger takes information from certain fields and adds them to a temporary variable of type Opportunity

4)a new object of type Project is created.

5) my trigger inserts values from the temporary varibable of type opportunity into the new Project object.

6) the new Project object is upserted.

 

Mind you I am very new to salesforce, and I imagine the solution is very simple, I just haven't found it yet. The problem I have is at step 3 above; more specifically accessing the object of type Opportunity that fires the trigger.

 

 

     Im new to salesforce, and my company recently installed a new package from the appexchange called "project and issue management" the package came with some custom objects, one in particular is the "project" object, which I am trying to write a trigger for, but it seems that for some reason the object is not recognized.  the following very simple code errors out:

 

trigger ProjectAutoFill on SFDC_Project__c (before insert) {

SFDC_Project_c tempProject;

}

 

the error is:

 

Error: Compile Error: Invalid type: SFDC_Project_c at line 3 column 1

If anybody could help me understand what's going on here it would be greatly appreciated

Hello,

     I'm modifying an existing APEX class to search through existing location objects to determine if a new one needs to be created in a particular situation. When I try to save the new code, I get the following error : Error: Compile Error: Invalid type: Schema.Location at line 189 column 34. My first guess based on research was that i must have the wrong name for the location object. Note here that i am using the standard SFDC Location object. As far as i can tell, the name is simply "Location" no more / no less, According to SFDC documentation and Our Enterprise WSDL. Second guess is that myself or whatever user is 'compiling' the code on save must not have permission to the Location object. I double checked that myself and API User both have access, they do. I'm at a brick wall here. I've simplified to code on the line in question to simply: "List<Location> locList = [Select id from Location ];" and I’m still getting the error. I then switched to the following:
1) List<Location> locList = new List<Location>();
2) locList = [Select id from Location];
I tried splitting the statement into two lines in order to better pinpoint the issue, in this situation I get the error on the second line, the query line, like I can create a list of locations, but I cannot populate it with a very basic select all query.

Does anyone have any idea on what could be going on here?

Thanks!

I'm trying to make a related list on the Quote object, the type of list should be a Bill To Address, now I believe Bill To Address is a custom made thing for my companies salesforce, it is originally found in the account, but I'm not sure. I have made a field in Quote that is a look-up relationship for type BIll To Address, When I try to add the related list to the quote page however, I can't seem to find the related list in the related list in the toolbox for editing the page layout.

 

Does anyone know what it is im doing wrong ?

This is probably a dumb question, but where is the products page ? I see from looking under my apps > customize > products , that there is indeed a product object but I can figure out how to get to it. I assumed that there was a page very similar to opportunity, lead, and account that would let you edit/view a list of products, but I can't seem to locate it.

 

I did, however see that you can add a product to an opportunity, although it asks me to choose a price book but there are none. Where do I add a pricebook ?

Hello all,

 

     My company is investigating the Sf quote object, And are wondering how one would do the following:

We want the Bill to and ship to addresses to be imported from the associated account, and a new address (the sold to address) to be imported from the associated opportunity object as soon as someone hits the 'Create New Quote' button.

 

Thank you for your help,

Greg Coley

It seems like all the information is saying that i cannot put a dashboard into force.com site and have users see the dashboard without logging in , but salesforce support says that i can. does anybody know how i would go about doing this ?

I'm attempting to create a scheduled job programatically using system.schedule but I'm running into issues. I'm trying to pass the parameters "Schedule Name",  "Schedule Time" and "Class Name" from strings from an object in SFDC. The problem is I don't know exactly how to change a string into an object. 

This is what I have so far:
 
 //Iterate through list of job descriptions
 For(Manage_ScheduleJobs__c addJobs : schJobs)
 {
 //Get class name and job name
 string ClassName = addJobs.Class_Name__c;
 string jobName = addJobs.Job_Name__c;
 
 //Attempt to change string to class
 object classDev = ClassName;

//Get the id of the new scheduled job
Id jobId = System.schedule(jobName, '0 0 0 * * ?', new classDev());
}
What am I doing wrong?
Thanks.

 

Im getting error ' no such column found ' for ' Id ' for example in a test method when i query the ' GroupMember ' object with runAs a customer portal user.

I assume this means a customer portal user cannot see that object, but how can I confirm that to make sure its not something else I am missing?

 

So i have been using the system log window, to directly execute Apex code for maintence, for instance:

 

- clearing out a large number of leads older that 2 years.

- poping open and saving a large number of leads to fire a trigger.

 

Has anyone else used this window in a similiar fasion ?  is this a really bad practice  (besides the obvious possibilty of deleting stuff that you didnt mean to) ? it seems like such a valuable resource, a console for executing scrpts, but i can't help but think i shouldnt be in there doing that, or theres another way to perform such maintenance. The scariest part is that every user has access to that window, so anyone could potentially go in and delete all the leads or opportunities, or even wipe out the whole Db if they knew a little code ! is there a way to disable this window for all users except the admins ?