• tgk1
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 24
    Questions
  • 50
    Replies

wat exactly an admin does in a company. I knw the tasks: "customization, security nd access, workflow rules, data validation etc..."   Below r my questions:

                                                                                                                                                                                                            Scenario: A small size company(say a construction company) with 50 users.

#1) how many admins required/ wat wil be the approx. team size ?     # 2) does 1 specific admin need to takecare of  ALL the tasks or will be focused on subset of tasks?       #3) Admin need to give/work 24/7 support?     #4) In general, an Admin reports to a Team leader/Sales director?       #5) Does Admin need to seek permission from anyone if he wants to install an application from Appexchange?

 

Kindly clarify my doubts nd educate me ..Thanks in advance

  • February 05, 2012
  • Like
  • 0

Hello everyone -

 

I took the Dev531 course a few months ago and I want to brush up on my developer skills.  The workbook that I have goes through the Universal Containers Recruiting App and schema, and I truly do not want to have to manually go back and recreate the app through the setup menu.  I've tried searching on the app exchange and it doesn't look like it's a managed package; does anyone know if there's a quick and easy way to download the Universal Containers Recruiting schema (it's like 4-6 objects total I believe).

 

Thanks!

  • December 28, 2012
  • Like
  • 0

Hi everyone.  I have a trigger that currently works fine through the user interface.  However I need to bulk update 85,000 task records and the trigger is causing failures.

 

Intended trigger purpose:  Update the Last_SW_Activity__c field (date time field) on the account object with the last modified date of the record when a task record meets the following criteria:

  1. The Subject Line starts with "sw".
  2. The task is marked as completed.
trigger LastSWDate on Task (after insert, after update) {
 
  //To do - If the subject of a completed task contains "SW", put the date of the completed task in the 
  //the "Last_SW_Activity__c" field on the account object

//Create a set of related account ID's
Set <ID> acctIDs = new Set <ID> ();
//Create a list to hold the Updated Accounts
List<Account> updAccts = new List<Account>();

//For every task, add it's related to account ID to the set
  for (Task t: Trigger.new){
    acctIDs.add(t.accountID);
//Create a map to match the task related to ID's with their corresponding account ID's
    Map<ID, Account> acctMap = new Map<ID, Account> ([Select ID, Last_SW_Activity__c from Account where ID in :acctIDs]);
//Create the account object
      Account acctRec = acctMap.get(t.accountID);

//If the account ID isn't null, the subject line starts with "sw", and the task has been marked as completed    
  If ((t.accountID != null) &&(t.subject.indexOf('sw')==0) && (t.Status == 'Completed'))
//Check to see if the Last_SW_Activity__c field is current compared with the latest completed activity
      If (acctMap.get(t.accountID).Last_SW_Activity__c < t.LastModifiedDate || acctMap.get(t.accountID).Last_SW_Activity__c ==null){
//Update the Last_SW_Activity__c field on the account object with the task's end date  
        acctrec.Last_SW_Activity__c = t.LastModifiedDate;
        updAccts.add(acctrec);
    }
  }
  update updAccts;
}

 Can somebody please help make the trigger code more efficient (bulkifying it) and help with creating a test class?  I'm not a developer and could use some serious help here.  Thanks!!

 

 

  • September 11, 2012
  • Like
  • 0

Hello - I'm trying to learn Apex but I'm having some difficulty understanding the concepts of Apex collections.  Can someone please explain to me a few examples of when using a list, set, or map would be appropriate?  For example what particular scenario would be good to use a list vs. the other collection classes?  Thanks for the help!

  • April 09, 2012
  • Like
  • 0

Hi everyone - I'm writing up a VisualForce page and I could use some help.  The page I'm trying to setup has three main values:  Product Line, Type, and Order Type.  These three fields are required, and the values of the Product Line field will be used to determine what pageblocksection to display.

 

<apex:page standardController="Opportunity" tabStyle="opportunity" sidebar="false" showHeader="false">
  <apex:form >
    <apex:pageblock title="{!Opportunity.Account.Name} Product List">
      <apex:pageblockButtons location="bottom">
        <apex:commandButton value="Save" action="{!save}"/>
      </apex:pageblockButtons>
      <apex:pageblocksection columns="1">
        <apex:inputfield value="{!Opportunity.Product_Line__c}" required="true"/>
        <apex:inputfield value="{!Opportunity.Type}" required="true"/>
        <apex:inputField value="{!Opportunity.OrderType__c}" required="true"/>
        
        <!-- Page Block Sections-->
        <apex:pageblocksection title="Value 1 Required Fields" columns="1" collapsible="true" id="value1">
        </apex:pageblocksection>
       
        <apex:pageblocksection title="Value 2 Required Fields" columns="2" collapsible="true" id="value2">
        </apex:pageblocksection>
        
        <apex:pageblocksection title="Value 3 Required Fields" columns="2" collapsible="true" id="value3">
        </apex:pageblocksection>
        
        <apex:pageblockSection title="Value 4 Required Fields" columns="2" collapsible="true" id="value4">
        </apex:pageblockSection>
       
      </apex:pageblocksection>
      <!--End Page Block Sections-->
    </apex:pageblock>
  </apex:form>
</apex:page>

 

I'm new to javascript and visualforce, so I could really use some help here.  I don't want any of the pageblocksections to display until the Product Line field is filled out.  For example, if a person selects "Value 1" in the Product Line field, I want the Value 1 page block section to display.  There are four values total.  Any help would be greatly appreciated! 

  • March 07, 2012
  • Like
  • 0

Hi everyone-

 

My organization has 8 values within the Stage field.  Analytic snapshots have proven unsuccessful for our particular organization in the past, so I'm looking to get creative.

 

The requirement here is to figure out how many days were spent in a particular stage (without getting overwritten).  I'm thinking about doing something where I create 8 fields (Stage 0 Age, Stage 1 Age, etc.) that can capture an integer value of how many days were spent in that particular stage.  This would allow us to really get down to the fine grain levels of reporting that our executive team is starting to require.  I believe something like this would have to be done with a workflow field update, as well as a formula field, but I'm not quite sure how I would do it.  Does anybody have any ideas?

  • February 10, 2012
  • Like
  • 0

Hi everyone-

 

I'm trying to bulk upload 23 new user records by using the Apex Dataloader.  I'm not making these users active yet, but I need to create the records so I can eventually activate them one at a time.  All of my fields values in the .CSV file are perfect, but I keep running into issues with the following fields:

 

Time Zone

Locale

Email Encoding

 

When I go to insert the new records, I get an error that states the field name & "bad value for restricted picklist field".

 

Does anybody know the values that I should be using for the New York time zone, with an English (United States) locale, and standard email encoding?  Thanks!!

  • January 02, 2012
  • Like
  • 0

Hi everyone - I've been an administrator for awhile now but I'm looking to branch out and become a salesforce developer.  I understand the use cases of Apex and Visualforce, but I'm confused as to how perl, PHP, python, and ruby can be used with salesforce.  Can someone please give me some examples of why these languages would be used to interact with salesforce?  Any use cases would be great, thanks for the help!!

  • September 27, 2011
  • Like
  • 0

Hey guys, I'm having an issue with an apex trigger that I rolled out recently.  The trigger is supposed to store a lead record's 18 digit id inside of a field I created called "lead_id__c" after save/insert.  The trigger works fine but is throwing an exception if a lead owner is changed (i.e. it will throw the exception if I change the lead from sales rep a to sales rep b).  Here's the error:

 

 

Apex script unhandled trigger exception by user/organization: 005000000073fWI/00D00000000hg2v

LeadAfterInsert: execution of AfterUpdate

caused by: System.DmlException: Update failed. First exception on row 0 with id 00Q00000009XfaeEAC; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: []

Trigger.LeadAfterInsert: line 29, column 9

 

Anybody have any idea how I can fix this?  Here's the existing trigger and test class I have, I would really appreciate the help!

 

Trigger -

trigger LeadAfterInsert on Lead (after insert, after update) 
{
    List<Lead> lstLeadstoupdate = new List<Lead>();
    if(trigger.isInsert)
    {
        for(Integer i = 0; i < Trigger.new.size(); i++)
        {
            String str = string.valueof(Trigger.new[i].Id);
            lstLeadstoupdate.add(new Lead(Id = Trigger.new[i].Id, Lead_Id__c = str.substring(0, 18)));
        }
    }
    else
    {
        for(Integer i = 0; i < Trigger.new.size(); i++)
            if(Trigger.old[i].Lead_Id__c != null && Trigger.new[i].Lead_Id__c !=  Trigger.old[i].Lead_Id__c)
            {
                String str = string.valueof(Trigger.new[i].Id);
                lstLeadstoupdate.add(new Lead(Id = Trigger.new[i].Id, Lead_Id__c = str.substring(0, 18)));
            }
            else if(Trigger.old[i].Lead_Id__c == null)
            {
                String str = string.valueof(Trigger.new[i].Id);
                lstLeadstoupdate.add(new Lead(Id = Trigger.new[i].Id, Lead_Id__c = str.substring(0, 18)));
            }
    
    }
    
    if(!lstLeadstoupdate.isEmpty())
        update lstLeadstoupdate;
}


 

Test class -

@isTest
private class Test_LeadAfterInsert_Trigger {

    static testMethod void myUnitTest() 
    {
        // TO DO: implement unit test
        Test.startTest();
            Lead objLead = new Lead();
            objLead.LastName = 'Test Lead 1';
            objLead.Company = 'Test Compant 1';
            Insert objLead;
            objLead.Lead_Id__c = '';
            update objLead;
        Test.stopTest();
    }
}



 



  • September 20, 2011
  • Like
  • 0

Hi all - I'm having trouble writing a test class for the following apex code:

 

trigger LastSWDate on Task (after insert, after update) {
  
  
  //To do - If the subject of a completed task contains "SW", put the date of the completed task in the 
  //the "Last_SW_Activity__c" field on the account object

//Create a set of related account ID's
Set <ID> acctIDs = new Set <ID> ();


//For every task, add it's related to account ID to the set
  for (Task t: Trigger.new){
    acctIDs.add(t.accountID);
//Create a map to match the task related to ID's with their corresponding account ID's
    Map<ID, Account> acctMap = new Map<ID, Account> ([Select ID, Last_SW_Activity__c from Account where ID in :acctIDs]);
//Create the account object
      Account acctRec = acctMap.get(t.accountID);

//If the account ID isn't null, the subject line starts with "sw", and the task has been marked as completed    
  If ((t.accountID != null) &&(t.subject.indexOf('sw')==0) && (t.Status == 'Completed'))
//Check to see if the Last_SW_Activity__c field is current compared with the latest completed activity
      If (acctMap.get(t.accountID).Last_SW_Activity__c < t.LastModifiedDate || acctMap.get(t.accountID).Last_SW_Activity__c ==null){
//Update the Last_SW_Activity__c field on the account object with the task's end date  
        acctrec.Last_SW_Activity__c = t.LastModifiedDate;
        update acctRec;
    }
  }
}

 Can somebody please help take a stab at a test class for this?  I would really appreciate it!  Thanks!

  • August 30, 2011
  • Like
  • 0

Hi everyone-

 

I could really use some help with a simple trigger.  When a lead record is saved I need an apex trigger to populate a field called "Lead_Id__c" with the lead record's 18 digit ID.  Can someone please help?  Thanks very much in advance!

 

-Tom

  • August 22, 2011
  • Like
  • 0

Hi everyone-  I posted a question last week regarding a test class but unfortunately I was never able to figure out an answer.  I need to write a test class for the following trigger:

 

trigger ReportsToDefensive on Defensive_Tracking__c (before insert, before update) {
	
	//Pull reports_to__c from user record
       // create a set of all the unique ownerIds

  Set<Id> ownerIds = new Set<Id>(); for (Defensive_Tracking__c d : Trigger.new) ownerIds.add(d.Account_Owner__c); // query for all the User records for the unique userIds in the records // create a map for a lookup / hash table for the user info
 Map<Id, User> owners = new Map<Id, User>([Select USER.Reports_To__c from User Where Id
in:ownerIds]); // iterate over the list of records being processed in the trigger and // set the field values before insert & update

 for (Defensive_Tracking__c d: Trigger.new) { d.Reports_To__c = owners.get(d.Account_Owner__c).Reports_To__c; } }



Can somebody please help me take a stab at it?  I'd greatly appreciate it.

  • August 08, 2011
  • Like
  • 0

Hi everyone-

 

I've developed a trigger that works as intended, but I'm having trouble developing a test class that gets coverage.  Here is the trigger code:

 

trigger ReportsToDefensive on Defensive_Tracking__c (before insert, before update) {
	
	//Pull reports_to__c from user record
       // create a set of all the unique ownerIds

  Set<Id> ownerIds = new Set<Id>(); for (Defensive_Tracking__c d : Trigger.new) ownerIds.add(d.Account_Owner__c); // query for all the User records for the unique userIds in the records // create a map for a lookup / hash table for the user info
 Map<Id, User> owners = new Map<Id, User>([Select USER.Reports_To__c from User Where Id
in:ownerIds]); // iterate over the list of records being processed in the trigger and // set the field values before insert & update

 for (Defensive_Tracking__c d: Trigger.new) { d.Reports_To__c = owners.get(d.Account_Owner__c).Reports_To__c; } }

And here is the corresponding test class I wrote that I cannot get coverage with:

 

@isTest
private class ReportsToDefensiveTest {

  static testMethod void testReportsToDefensive() {
        // TO DO: implement unit test

   User u = [Select id from User where id =: Userinfo.getuserId()];
   u.Reports_To__c = '00500000006xlrN';
   update u;

   test.startTest();
   system.runAs(u) {
   Defensive_Tracking__c d = new Defensive_Tracking__c(Account__c =    '001R000000dlCW1', 	Account_Owner__c = '005000000074MeF', 
   		of_Units_under_Raid_Risk__c = 12, Reason_why_at_Risk__c = 'Test', CT_Unit_Price_at_Time_of_Raid_Risk__c = 4,
   			Total_Annual_Rep_Rev_at_Time_of_Risk__c = 1, Competitor__c = 'Test' );
   //fill all mandatory field of account before insert if any
   
   insert d;
   d = [select id, Reports_to__c from Defensive_Tracking__c where id =:d.id];
   //requery account a after insert
   system.assertEquals(u.Reports_To__c, d.Reports_To__c);
   }
   test.stopTest();
   
     }

   }

 The various fields that I included are required based off of validation rules.  Can somebody please help me modify the test class so I get full coverage?

  • August 04, 2011
  • Like
  • 0

Hi everyone-

 

I believe I'm coming pretty close to finalizing my apex code.  Unfortunately I'm getting a compile error and could use some help.  I have included comments within the code to show exactly what I'm trying to accomplish.  Can somebody please take a look and see what modifications need to be made?

 

trigger LastSWDate on Task (before insert, before update) {
	
	//To do - If the subject of a completed task contains "SW", put the date of the completed task in the 
	//the "Last_SW_Activity__c" field on the account object

//Create a set of related account ID's
Set <ID> acctIDs = new Set <ID> ();


//For every task, add it's related to account ID to the set
	for (Task t: Trigger.new){
	  acctIDs.add(t.accountID);
//Create a map to match the task related to ID's with their corresponding account ID's
	  Map<ID, Account> acctMap = new Map<ID, Account> ([Select ID, Last_SW_Activity__c from Account where ID in :acctIDs]);
//Create the account object
      Account acctRec = acctMap.get(t.accountID);

//If the account ID isn't null, the subject line starts with "sw", and the task has been marked as completed    
	If (t.accountID =!null && t.subject.indexOf('sw') && t.Status == 'Completed')
//Check to see if the Last_SW_Activity__c field is current compared with the latest completed activity
  	  If (acctMap.get.(t.accountID).Last_SW_Activity__c < t.endDateTime || acctMap.get(t.accountID).Last_SW_Activity ==null){
//Update the Last_SW_Activity__c field on the account object with the task's end date  
  		  acctrec.Last_SW_Activity__c = t.endDatetime;
  	}
  }
}

 

 

 

 The error I'm getting states "Invalid field endDatetime for SObject Task".  It's refering to the last line of code.  Does anybody have any idea why it's giving me that error?

  • July 19, 2011
  • Like
  • 1

Hi everyone.  I have a multi-select picklist that contains roughly 50 values.  I need to create a simple formula field that counts the number of values that were marked off in the mult-select picklist.

 

For instance, if two values were selected in the mult-select picklist, the value of the formula field would equal 2. 

 

I know this seems simple but I'm having trouble due to the field type.  Any help would be greatly appreciated.

  • July 15, 2011
  • Like
  • 0

Hi everyone- I have four fields on the User object that have corresponding fields on the Account object.  I need to make a trigger that pulls the values from the User record and maps them appropriately on the Account record.  Here's the code I have:

 

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

//The purpose of this trigger is to pull four field values from an account owner's user record, and map them onto the account record
//Pulls 'Business Unit', 'Sales Role', 'Reports To', 'Region' fields


       
       // create a set of all the unique ownerIds  
       Set<Id> ownerIds = new Set<Id>();  
       for (Account a : Trigger.new)  
           ownerIds.add(a.OwnerId);      
     
    // query for all the User records for the unique userIds in the records  
       // create a map for a lookup / hash table for the user info  
       Map<Id, User> owners = new Map<Id, User>([Select USER.Business_Unit__c, USER.Sales_Role__c, USER.Reports_To__c, USER.Region__c from User Where Id in 
       :ownerIds]);     
     
       // iterate over the list of records being processed in the trigger and  
      // set the field values before insert & update
      for (Account a: Trigger.new)  
           a.Business_Unit__c = owners.get(a.OwnerId).Business_Unit__c;
           a.Sales_Role__c = owners.get(a.OwnerID).Sales_Role__c;
           a.Reports_To__c = owners.get(a.OwnerID).Reports_To__c;
           a.Region_c = owners.get(a.OwnerID).Region_c;
  }

 For some reason in the IDE it's stating that there's a save error: "Variable a.Sales_Role__c does not exist".  Does anyone know how I can fix this?

  • July 14, 2011
  • Like
  • 0

Hi everyone-  I know that Apex classes can be scheduled, but can a standard Apex trigger be scheduled?  I have a trigger on the account object that I would like to run every weekend and I'm curious if it can be done.  Thanks for the help!

  • July 14, 2011
  • Like
  • 0

Hi everyone, I could really use some help with a trigger I'm trying to make.  I essentially need a field on the account object to be populated with the latest completed task date if it meets two conditions:

 

 

1.  The task has been marked as completed

2.  The task field "Spoke_with__c" equals Yes

 

I tried to take a stab at it but I couldn't get the code to compile.  Sample code to get me going would be greatly appreciated.

 

Here are the variables-

Task custom field  (picklist)- Spoke_With__c

Account custom field (date/time)-  Last_SW_Activity__c

 

 

Thanks!

 



  • July 13, 2011
  • Like
  • 0

Hey guys-

 

I could really use some help with a VisualForce page I need to create.  Since Salesforce does not give the standard capability to create new Lookup page layouts (only can modify the columns on the standard layouts), I need to create one that looks and acts like a standard Lookup layout.

 

The reason why I need to do this is because the Lookup page layout URL will be used in an external application.  The user will search for the Account name, and the search results would display the Account Name, and Account ID (custom field).

 

Any help would be greatly appreciated!!

 

 

 

 

  • July 08, 2011
  • Like
  • 0

Hey everyone-

 

I need to create a field within the account object that holds the account records ID.  I can get the 15 digit ID very easily via a formula field, but unfortunately I need to get the full 18 digits.  Has anybody made a trigger like this in the past?  If so can you please share your code??  Thank you very much in advance.

 

-Tom

  • July 08, 2011
  • Like
  • 0

Hi everyone- I need to deploy an apex trigger and it's corresponding test class into my production instance.  Here's the code for the trigger:

 

trigger USERBusinessUnit on Account (before insert, before update) {
     
       // create a set of all the unique ownerIds  
       Set<Id> ownerIds = new Set<Id>();  
       for (Account a : Trigger.new)  
           ownerIds.add(a.OwnerId);      
     
    // query for all the User records for the unique userIds in the records  
       // create a map for a lookup / hash table for the user info  
       Map<Id, User> owners = new Map<Id, User>([Select USER.Business_Unit__c from User Where Id in 
       :ownerIds]);     
     
       // iterate over the list of records being processed in the trigger and  
      // set the Owner's Business Unit before being inserted or updated 
      for (Account a : Trigger.new)  
           a.Business_Unit__c = owners.get(a.OwnerId).Business_Unit__c;   
    
  }

 

 

And here is the test class that compiles (and works):

@isTest

private class USERBusinessUnitTriggerTest {


   private static TestMethod void testUSERBusinessUnitMethod() {
   
   User u = [Select id from User where id =: Userinfo.getuserId()];
   u.Business_Unit__c = 'Test BU';
   update u;

   test.startTest();
   system.runAs(u) {
   Account a = new Account(Name = 'Test Account');
   //fill all mandatory field of account before insert if any
   
   insert a;
   system.assertEquals(u.Business_Unit__c , a.Business_Unit__c);
   }
   test.stopTest();
      }

   }

 

 

Both the user & account objects have the Business_Unit__c field  (picklist field with either a value of P or E ).  When i went to deploy the change set I got the following error:

 

API NameTypeLineColumnProblem

USERBusinessUnitTriggerTest.testUSERBusinessUnitMethod()Class184Failure Message: "System.AssertException: Assertion Failed: Expected: Test BU, Actual: null", Failure Stack Trace: "Class.USERBusinessUnitTriggerTest.testUSERBusinessUnitMethod: line 18, column 4 External entry point"



 

Can anybody please help?  Thanks!

  • June 29, 2011
  • Like
  • 0

Hi everyone-

 

I believe I'm coming pretty close to finalizing my apex code.  Unfortunately I'm getting a compile error and could use some help.  I have included comments within the code to show exactly what I'm trying to accomplish.  Can somebody please take a look and see what modifications need to be made?

 

trigger LastSWDate on Task (before insert, before update) {
	
	//To do - If the subject of a completed task contains "SW", put the date of the completed task in the 
	//the "Last_SW_Activity__c" field on the account object

//Create a set of related account ID's
Set <ID> acctIDs = new Set <ID> ();


//For every task, add it's related to account ID to the set
	for (Task t: Trigger.new){
	  acctIDs.add(t.accountID);
//Create a map to match the task related to ID's with their corresponding account ID's
	  Map<ID, Account> acctMap = new Map<ID, Account> ([Select ID, Last_SW_Activity__c from Account where ID in :acctIDs]);
//Create the account object
      Account acctRec = acctMap.get(t.accountID);

//If the account ID isn't null, the subject line starts with "sw", and the task has been marked as completed    
	If (t.accountID =!null && t.subject.indexOf('sw') && t.Status == 'Completed')
//Check to see if the Last_SW_Activity__c field is current compared with the latest completed activity
  	  If (acctMap.get.(t.accountID).Last_SW_Activity__c < t.endDateTime || acctMap.get(t.accountID).Last_SW_Activity ==null){
//Update the Last_SW_Activity__c field on the account object with the task's end date  
  		  acctrec.Last_SW_Activity__c = t.endDatetime;
  	}
  }
}

 

 

 

 The error I'm getting states "Invalid field endDatetime for SObject Task".  It's refering to the last line of code.  Does anybody have any idea why it's giving me that error?

  • July 19, 2011
  • Like
  • 1

Hi everyone.  I have a trigger that currently works fine through the user interface.  However I need to bulk update 85,000 task records and the trigger is causing failures.

 

Intended trigger purpose:  Update the Last_SW_Activity__c field (date time field) on the account object with the last modified date of the record when a task record meets the following criteria:

  1. The Subject Line starts with "sw".
  2. The task is marked as completed.
trigger LastSWDate on Task (after insert, after update) {
 
  //To do - If the subject of a completed task contains "SW", put the date of the completed task in the 
  //the "Last_SW_Activity__c" field on the account object

//Create a set of related account ID's
Set <ID> acctIDs = new Set <ID> ();
//Create a list to hold the Updated Accounts
List<Account> updAccts = new List<Account>();

//For every task, add it's related to account ID to the set
  for (Task t: Trigger.new){
    acctIDs.add(t.accountID);
//Create a map to match the task related to ID's with their corresponding account ID's
    Map<ID, Account> acctMap = new Map<ID, Account> ([Select ID, Last_SW_Activity__c from Account where ID in :acctIDs]);
//Create the account object
      Account acctRec = acctMap.get(t.accountID);

//If the account ID isn't null, the subject line starts with "sw", and the task has been marked as completed    
  If ((t.accountID != null) &&(t.subject.indexOf('sw')==0) && (t.Status == 'Completed'))
//Check to see if the Last_SW_Activity__c field is current compared with the latest completed activity
      If (acctMap.get(t.accountID).Last_SW_Activity__c < t.LastModifiedDate || acctMap.get(t.accountID).Last_SW_Activity__c ==null){
//Update the Last_SW_Activity__c field on the account object with the task's end date  
        acctrec.Last_SW_Activity__c = t.LastModifiedDate;
        updAccts.add(acctrec);
    }
  }
  update updAccts;
}

 Can somebody please help make the trigger code more efficient (bulkifying it) and help with creating a test class?  I'm not a developer and could use some serious help here.  Thanks!!

 

 

  • September 11, 2012
  • Like
  • 0

Hello - I'm trying to learn Apex but I'm having some difficulty understanding the concepts of Apex collections.  Can someone please explain to me a few examples of when using a list, set, or map would be appropriate?  For example what particular scenario would be good to use a list vs. the other collection classes?  Thanks for the help!

  • April 09, 2012
  • Like
  • 0

Hi everyone - I'm writing up a VisualForce page and I could use some help.  The page I'm trying to setup has three main values:  Product Line, Type, and Order Type.  These three fields are required, and the values of the Product Line field will be used to determine what pageblocksection to display.

 

<apex:page standardController="Opportunity" tabStyle="opportunity" sidebar="false" showHeader="false">
  <apex:form >
    <apex:pageblock title="{!Opportunity.Account.Name} Product List">
      <apex:pageblockButtons location="bottom">
        <apex:commandButton value="Save" action="{!save}"/>
      </apex:pageblockButtons>
      <apex:pageblocksection columns="1">
        <apex:inputfield value="{!Opportunity.Product_Line__c}" required="true"/>
        <apex:inputfield value="{!Opportunity.Type}" required="true"/>
        <apex:inputField value="{!Opportunity.OrderType__c}" required="true"/>
        
        <!-- Page Block Sections-->
        <apex:pageblocksection title="Value 1 Required Fields" columns="1" collapsible="true" id="value1">
        </apex:pageblocksection>
       
        <apex:pageblocksection title="Value 2 Required Fields" columns="2" collapsible="true" id="value2">
        </apex:pageblocksection>
        
        <apex:pageblocksection title="Value 3 Required Fields" columns="2" collapsible="true" id="value3">
        </apex:pageblocksection>
        
        <apex:pageblockSection title="Value 4 Required Fields" columns="2" collapsible="true" id="value4">
        </apex:pageblockSection>
       
      </apex:pageblocksection>
      <!--End Page Block Sections-->
    </apex:pageblock>
  </apex:form>
</apex:page>

 

I'm new to javascript and visualforce, so I could really use some help here.  I don't want any of the pageblocksections to display until the Product Line field is filled out.  For example, if a person selects "Value 1" in the Product Line field, I want the Value 1 page block section to display.  There are four values total.  Any help would be greatly appreciated! 

  • March 07, 2012
  • Like
  • 0

ple help the above validation rule in SFDc

  • February 11, 2012
  • Like
  • 0

Hi everyone-

 

My organization has 8 values within the Stage field.  Analytic snapshots have proven unsuccessful for our particular organization in the past, so I'm looking to get creative.

 

The requirement here is to figure out how many days were spent in a particular stage (without getting overwritten).  I'm thinking about doing something where I create 8 fields (Stage 0 Age, Stage 1 Age, etc.) that can capture an integer value of how many days were spent in that particular stage.  This would allow us to really get down to the fine grain levels of reporting that our executive team is starting to require.  I believe something like this would have to be done with a workflow field update, as well as a formula field, but I'm not quite sure how I would do it.  Does anybody have any ideas?

  • February 10, 2012
  • Like
  • 0

wat exactly an admin does in a company. I knw the tasks: "customization, security nd access, workflow rules, data validation etc..."   Below r my questions:

                                                                                                                                                                                                            Scenario: A small size company(say a construction company) with 50 users.

#1) how many admins required/ wat wil be the approx. team size ?     # 2) does 1 specific admin need to takecare of  ALL the tasks or will be focused on subset of tasks?       #3) Admin need to give/work 24/7 support?     #4) In general, an Admin reports to a Team leader/Sales director?       #5) Does Admin need to seek permission from anyone if he wants to install an application from Appexchange?

 

Kindly clarify my doubts nd educate me ..Thanks in advance

  • February 05, 2012
  • Like
  • 0

Hi everyone-

 

I'm trying to bulk upload 23 new user records by using the Apex Dataloader.  I'm not making these users active yet, but I need to create the records so I can eventually activate them one at a time.  All of my fields values in the .CSV file are perfect, but I keep running into issues with the following fields:

 

Time Zone

Locale

Email Encoding

 

When I go to insert the new records, I get an error that states the field name & "bad value for restricted picklist field".

 

Does anybody know the values that I should be using for the New York time zone, with an English (United States) locale, and standard email encoding?  Thanks!!

  • January 02, 2012
  • Like
  • 0

Hey guys, I'm having an issue with an apex trigger that I rolled out recently.  The trigger is supposed to store a lead record's 18 digit id inside of a field I created called "lead_id__c" after save/insert.  The trigger works fine but is throwing an exception if a lead owner is changed (i.e. it will throw the exception if I change the lead from sales rep a to sales rep b).  Here's the error:

 

 

Apex script unhandled trigger exception by user/organization: 005000000073fWI/00D00000000hg2v

LeadAfterInsert: execution of AfterUpdate

caused by: System.DmlException: Update failed. First exception on row 0 with id 00Q00000009XfaeEAC; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: []

Trigger.LeadAfterInsert: line 29, column 9

 

Anybody have any idea how I can fix this?  Here's the existing trigger and test class I have, I would really appreciate the help!

 

Trigger -

trigger LeadAfterInsert on Lead (after insert, after update) 
{
    List<Lead> lstLeadstoupdate = new List<Lead>();
    if(trigger.isInsert)
    {
        for(Integer i = 0; i < Trigger.new.size(); i++)
        {
            String str = string.valueof(Trigger.new[i].Id);
            lstLeadstoupdate.add(new Lead(Id = Trigger.new[i].Id, Lead_Id__c = str.substring(0, 18)));
        }
    }
    else
    {
        for(Integer i = 0; i < Trigger.new.size(); i++)
            if(Trigger.old[i].Lead_Id__c != null && Trigger.new[i].Lead_Id__c !=  Trigger.old[i].Lead_Id__c)
            {
                String str = string.valueof(Trigger.new[i].Id);
                lstLeadstoupdate.add(new Lead(Id = Trigger.new[i].Id, Lead_Id__c = str.substring(0, 18)));
            }
            else if(Trigger.old[i].Lead_Id__c == null)
            {
                String str = string.valueof(Trigger.new[i].Id);
                lstLeadstoupdate.add(new Lead(Id = Trigger.new[i].Id, Lead_Id__c = str.substring(0, 18)));
            }
    
    }
    
    if(!lstLeadstoupdate.isEmpty())
        update lstLeadstoupdate;
}


 

Test class -

@isTest
private class Test_LeadAfterInsert_Trigger {

    static testMethod void myUnitTest() 
    {
        // TO DO: implement unit test
        Test.startTest();
            Lead objLead = new Lead();
            objLead.LastName = 'Test Lead 1';
            objLead.Company = 'Test Compant 1';
            Insert objLead;
            objLead.Lead_Id__c = '';
            update objLead;
        Test.stopTest();
    }
}



 



  • September 20, 2011
  • Like
  • 0

Hi,

 

I have a workflow that is triggered by the creation of an object named p_status__c. this object is connected by a lookup to another object p__c.

I want to create an email alert that will be triggered 30 days after the creation of p_status__c only if another checkbox (fieldname is paid) of the p__c object is FALSE.

The point is that only 30 days after the creation of p_status__c the function shoul evaluate the "paid" field.

 

The regular workflow evaluate both conditions on the creation trigger.

A solution anyone?

 

Thank's

  • August 31, 2011
  • Like
  • 0

Hi all - I'm having trouble writing a test class for the following apex code:

 

trigger LastSWDate on Task (after insert, after update) {
  
  
  //To do - If the subject of a completed task contains "SW", put the date of the completed task in the 
  //the "Last_SW_Activity__c" field on the account object

//Create a set of related account ID's
Set <ID> acctIDs = new Set <ID> ();


//For every task, add it's related to account ID to the set
  for (Task t: Trigger.new){
    acctIDs.add(t.accountID);
//Create a map to match the task related to ID's with their corresponding account ID's
    Map<ID, Account> acctMap = new Map<ID, Account> ([Select ID, Last_SW_Activity__c from Account where ID in :acctIDs]);
//Create the account object
      Account acctRec = acctMap.get(t.accountID);

//If the account ID isn't null, the subject line starts with "sw", and the task has been marked as completed    
  If ((t.accountID != null) &&(t.subject.indexOf('sw')==0) && (t.Status == 'Completed'))
//Check to see if the Last_SW_Activity__c field is current compared with the latest completed activity
      If (acctMap.get(t.accountID).Last_SW_Activity__c < t.LastModifiedDate || acctMap.get(t.accountID).Last_SW_Activity__c ==null){
//Update the Last_SW_Activity__c field on the account object with the task's end date  
        acctrec.Last_SW_Activity__c = t.LastModifiedDate;
        update acctRec;
    }
  }
}

 Can somebody please help take a stab at a test class for this?  I would really appreciate it!  Thanks!

  • August 30, 2011
  • Like
  • 0

Hi everyone-

 

I could really use some help with a simple trigger.  When a lead record is saved I need an apex trigger to populate a field called "Lead_Id__c" with the lead record's 18 digit ID.  Can someone please help?  Thanks very much in advance!

 

-Tom

  • August 22, 2011
  • Like
  • 0