• mhamberg1
  • NEWBIE
  • 100 Points
  • Member since 2006

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 48
    Replies

Hi all,

 

I am  very new to Salesforce.  I have created visual force pages with the help of documents and have written apex classes in standard objects.  Now I am trying to write apex classes in visual force pages.  For example in my visual force page I have a standard 'Save' button which functions normally. If I have to override this normal functionality, how do I do this? Can anyone guide me.

  • April 15, 2009
  • Like
  • 0

I have some records where a user has submitted for approval and been approved.  Now I am in a scenario where I want to erase the approval completely.

 

Is there a way to do this via the UI or the API?  

I'm working on a very simple scheduled Apex case. Once a month I want to scan opportunities, and reassign ones that don't have a status date back to an early stage (this keeps our pipeline clean).

 

I have read a lot of forum posts and blogs on this and here is what I have so far - it's basically not executing at all (0% coverage). I'm not an Apex/Java expert so I might be missing something very obvious. Please help if you can.

 

Here is my implements Scheduler class:

 

global class OpportunityRestageScheduler implements Schedulable
{
 
    global void execute(SchedulableContext ctx)
    {
       OpportunityRestage.changeStage();
    
    }    
}

 

 

Here is my regular class that reassigns a stage:

 

global class OpportunityRestage
{
   @future(callout=true)
    public static void changeStage()
    {
        List<Opportunity> opps = new List<Opportunity>();
        
        for(Opportunity OppMaster:[select ID, StageName from Opportunity where Current_Status_Date__c = null]) 
        {
            
            // Reassign the stage
            OppMaster.StageName = 'B = Target Account';
            opps.add(OppMaster);            
        }
        update opps;
    }
}

 

 

Here is my test class to run the above:

 

@istest

class OppRestageTest
{
   
   public static testMethod void testOppRestaging() 
   {
       Test.StartTest();

       Opportunity opp1 = 
new Opportunity(StageName = '6 = Selection Vendor / Solution', 
Name = 'testmethod', CloseDate = date.today());
       insert opp1;
       
      
       OpportunityRestageScheduler reassign = new OpportunityRestageScheduler();
       
       Test.StopTest();
       
       System.debug('Stage update');
       System.debug(opp1.StageName);  
   }            
}

 

I based the code off this Salesforce blog post which implements the Apex scheduler: http://blog.sforce.com/sforce/2010/02/spring-10-saw-the-general-availability-of-one-of-my-favorite-new-features-of-the-platform-the-apex-schedulerwith-the-apex-s.html

 

I'm trying to upload a package but there are a couple custom reports in one object that reference objects outside of what we want to share.  When I go to upload I get an error that these referenced components aren't included in my package. 

Is there a way that I can exclude these elements from my package without having to DELETE them?

We are currently using the dataloader to automate a retention policy on records. For example, we go through every day and delete all records that are older than two years for a certain custom object.

Right now we are on Dataloader v7 which is about 4 years old and we'd like to do an upgrade to the newest Dataloader (v17).

With the new 'bean' format of process-conf.xml, how can we execute a delete query passing in a dynamic date?

It only works today because the old dataloader version used separate config.properties files for every job so we could just generate a file.

We would like to create a multi-picklist "County" field with all of the counties found in the United States. Unfortunately that means that we would need to have about 3100 different values in our picklist .

I know that with multi-select picklists you can only have a maximum of 150 values.

 

Is there a way to store this information otherwise?

Is there a way around it using Apex or is the best way to do this to be forced into creating some kind of custom object solution?

 

any help would be appreciated.

I have a scenario where I want the user to input an Account ID as text in a field on my form. Then, after they update that field, I want to take that value and save it as the Account__c value which is a hidden field on my form.

 

Basically I'm looking for a way that a user can identify themselves with an account without being able to see the whole list of accounts out there using the lookup.

 

How would I modify this field dynamically upon them making that change?

 

Thanks

This is probably really simple, but I haven't seen it done: 

 

After a user fills out my Visualforce form, I want them to be redirected to a "Thank you for your submission" page instead of the native action of viewing the record.

 

How would I do this?

 

Thanks

I wrote a trigger that figures out who the Lead owner should be based on some rules that we have.

 

When I execute this via web-to-lead, my trigger assigns the appropriate person but in the order of operations after that, Salesforce runs the Lead 'Assignment Rules.'

 

Since I have no formal 'assignment rules' set up, the system assigns every lead to the default lead owner. This only happens in the web to lead scenario - when I manually create a lead or bulk load them with the dataloader, they get assigned properly.

 

Is there a way in Apex to tell the system not to run the assignment rules or is there a way around this situation?

 

Thanks

I've setup my lead object with a trigger that looks at a zip code table and assigns the proper owner for the lead.

 

This works great when I manually create a lead or load them in with the dataloader. However, when someone submits a lead from our website (web-to-lead), they are all getting assigned to me (not even the default owner). 

 

Is there something I have to turn on to enable my web-to-lead to fire off my Apex trigger? Is there a way that I can debug the web 2 lead process besides the debug email option (I already have that turned on). I'm looking for a way to write out my trigger code to a log and see if it is firing in the web to lead process.

 

Thanks

I wrote a custom app and tested the code and everything was fine. I pushed the code to production and it was working and in use.

 
I wrote new code in our Sandbox later on for another process, when I ran a test of that code, I had enough coverage of it and I was ready to push that code to production as well. However, when I tried to move the new code to production using Eclipse, all of a sudden one of my old triggers that was already in production said it had 0% test coverage. This made my new migration fail. It was a trigger that I had already tested and it previously had 100% test coverage. Since you can't change triggers in production, it was extra baffling.

After a few hours of testing and spinning my wheels, I realized that in Production we had created a new validation rule that we didn't have in the Sandbox. Because of the new validation rule, the Test class that was previously working was not allowed to fire off one of my triggers thus invalidating a working triggers' code coverage (even though the trigger still functioned fine in production).

The moral of the story is that when you add any new code to production, it reruns a test of ALL your code (including previously added classes). If you've added anything in production that might affect some of your triggers, it can break your test coverage percentage.

I'm trying to send a Visualforce email template with custom object information that also lists out some child items. It's a pretty simple idea, but I'm getting a compile error because it doesn't like my child object reference. Can anyone help me correct this? I have bolded the problem line.

 

 

<messaging:emailTemplate subject="Changeover Order Form APPROVED"
recipientType="User" relatedToType="Changeover_Order_Form__c">
<messaging:plainTextEmailBody >

Details:
Account: {!relatedTo.Account__c}

Ingoing Order Amount: {!relatedTo.Ingoing_Order_Amount__c}
Package: {!relatedTo.Package_Options__c}
Gift Card Level: {!relatedTo.Gift_Card_Level__c}
Gift Card dollars used: {!relatedTo.Total_Gift_Card_dollars_used__c}

GIFT CARD SELECTION:
<apex:repeat var="gx" value="{!relatedTo.Gift_Card_Selection}">
Vendor: {!gx.Vendor_Card__c} ] - # of Cards: {!gx.of_Cards__c} ]
</apex:repeat>

View the record: http://www.salesforce.com/{!relatedTo.Id}

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 

I made sure that the Child Relationship Name field was filled in with "Gift_Card_Selection."

Am I missing something else?

 

 

I just created a custom app and it has everything the marketing group wanted. However, at the end of the approval process it needs to send an email with the contents of the record (which is no problem) AND a listing of the related items.

I'm not sure how to send that list since it could be one entry or many and it is not part of the main object. It has a lookup relationship to the main object though.

 

Is there a way to somehow query the related list using Apex or some other method so that I could return the items in an email?

 

 

Thanks

I have a map instance of two strings. Each record is a zip code and a text literal (for example <90210, 'IP'> or <90210, 'RP'> ). The combination of both values makes each record unique.

In my bulk load process, I have a need where I need to query against this Map object. I haven't seen where anyone has done this and I'm wondering what kind of syntax I should use.

My select statement looks like this - I need help on the where clause
Code:

Map<String, String> zips = new Map<String, String>();

// Simplified example
zips.put('90210','IP');
for(Zip_Code__c zip_code:[select Name, Sales_Rep__c from Zip_Code__c where Name in :zips]) 
{
// Some action code here
}

 What I really want to do is something like:
select Name, Sales_Rep__c from Zip_Code__c where Name = zips.key AND IP_or_RP__c = zips.value

How do I do that?
I'm working to try to fully understand how Maps and map lookups work. I've read all the documentation I can get my hands on, but that doesn't seem to help.

Here's an example Map called userMap:

<Name(String), UserID(User)>
<Mike, 00123456abc>
<Tim, 000123832abc>
<Jake, 00123999jam>

If I want to know what Tim's UserID is, how would I get that information? 

My first impression of maps would be to use something like: userMap.get(Tim).UserID

But based on Simon's post on a recent thread it seems like the key that you have to use to do the lookup is actually different.

Can anyone explain how Map keys actually work?


I'm writing a bulk trigger to update lead owners based on a zip code table we have.

I think I'm close to having the whole thing working, but I'm getting the "Attempt to de-reference a null object" error when I actually execute a test of my code.

Here is the code:

Code:
trigger LeadAssignmentTrigger on Lead (before insert) 
{    
    List<String> zips = new List<String>();

    // Loop through Leads and create list of zip codes
    for (Lead lead : Trigger.new)
    {
        if (lead.PostalCode != NULL)
        {
            zips.add(lead.PostalCode);    
        }
    }

    //query zip code table and link zips to Sales reps
    // Name field = a single zip code
Map<String, Zip_Code__c> leadsToUpdate = new Map<String, Zip_Code__c>
([select Name, Sales_Rep__c from Zip_Code__c where Name in :zips]);

// If there is at least one match, bulk update
if (leadsToUpdate.size() > 0)
{
for (Lead lead : Trigger.new)
{
//assign the lead owner to the zip code owner
lead.OwnerId = leadsToUpdate.get(lead.PostalCode).Sales_Rep__c; //this line gives the error
}
}
}

There must be some small problem I have in here. Basically what I want to do is find the Sales Rep who corresponds to the new lead's zip code and assign that sales rep as the new lead OWNER.

If anyone knows why I'm getting that error and can give me some advice I would be much obliged.

Thanks

We are trying to automatically assign lead ownership based on our database of Zip Codes. Since there are so many zip codes, we can't manually put them in the native assignment rules.

I'm trying to write a trigger to reassign the Lead Owner but this is my first one and I can't seem to get it right. Here's what I have:

Code:
trigger LeadAssignmentTrigger on Lead (before insert) 
{
    List<Lead> leadsToUpdate = new List<Lead>();

    for (Lead lead : Trigger.new)
    {
     
      if (lead.PostalCode != NULL)
      {
          // Find the sales rep for the current zip code
          List<Zip_Code__c> zip = [select Sales_Rep__c from Zip_Code__c 
where Name = :lead.PostalCode limit 1];


// if you found one
if (zip.size() > 0)
{
//assign the lead owner to the zip code owner
lead.Owner = zip.Sales_Rep__c; // This is my problem line

leadsToUpdate.add(lead);

}
}

}

// update the records
try
{
update leadsToUpdate;
}
catch (DmlException dm)
{
leadsToUpdate.addError('There was a problem reassigning the Lead Owner');
}

}

I have bolded the problem line. All I want to do is to assign the User from my Zip Code object (just a list of zip codes and user lookups) to the current lead creation on any given Lead insert.

Can someone please tell me what the correct syntax should be?

Thanks
I'm trying to delete records from the AccountShare table using the Dataloader.

I've extracted and selected the records that I want using MS Access (like I do almost daily), but when I try to run the delete I get the error that the 'id does not exist.'

Is there something special that you have to do when deleting records from the Account Share table? How else can I delete these records?

Thanks
Is there a way now to do a "group by" in the API so that we can simulate a summary report? Will this be available in the API 8.0 version if not available now?

Thanks
We would like to have a tab for our users where they would see custom content related to salesforce.com.

For example, the page may have report links, data, images, etc and it would be accessible all on this tab. The idea is VERY SIMILAR to having a second "Home Page" tab.

I'd prefer to keep the page inside of salesforce instead of it sitting externally. Although I'd be open to some custom PHP development that we would be able to see right inside of our application (possibly using a web tab or something like that).

I'm looking for suggestions and best practices and ideas on how other people have implemented this sort of thing.

Thanks
I'm trying to get a record set of more than 2000 records and I know that I'm supposed to use the queryMore function to do that.

I read through many posts and I'm having a hard time knowing exactly how to do this in PHP.

Here is what I have and maybe someone can enlighten me as to what I have wrong. I'm pretty sure it has to do with the locator variable because that is coming up NULL when I echo it.

------------------------------------------------------
$query = "...my query which I know is working...";
 
  $response = $connection->query($query);

  while ($response->done == false)
  {
    $locator = $connection->queryLocator;
   
    $response = $connection->queryMore($locator, 2000);
  }

  return $response->records;
--------------------------------------------------------

Thanks

I have some records where a user has submitted for approval and been approved.  Now I am in a scenario where I want to erase the approval completely.

 

Is there a way to do this via the UI or the API?  

I'm working on a very simple scheduled Apex case. Once a month I want to scan opportunities, and reassign ones that don't have a status date back to an early stage (this keeps our pipeline clean).

 

I have read a lot of forum posts and blogs on this and here is what I have so far - it's basically not executing at all (0% coverage). I'm not an Apex/Java expert so I might be missing something very obvious. Please help if you can.

 

Here is my implements Scheduler class:

 

global class OpportunityRestageScheduler implements Schedulable
{
 
    global void execute(SchedulableContext ctx)
    {
       OpportunityRestage.changeStage();
    
    }    
}

 

 

Here is my regular class that reassigns a stage:

 

global class OpportunityRestage
{
   @future(callout=true)
    public static void changeStage()
    {
        List<Opportunity> opps = new List<Opportunity>();
        
        for(Opportunity OppMaster:[select ID, StageName from Opportunity where Current_Status_Date__c = null]) 
        {
            
            // Reassign the stage
            OppMaster.StageName = 'B = Target Account';
            opps.add(OppMaster);            
        }
        update opps;
    }
}

 

 

Here is my test class to run the above:

 

@istest

class OppRestageTest
{
   
   public static testMethod void testOppRestaging() 
   {
       Test.StartTest();

       Opportunity opp1 = 
new Opportunity(StageName = '6 = Selection Vendor / Solution', 
Name = 'testmethod', CloseDate = date.today());
       insert opp1;
       
      
       OpportunityRestageScheduler reassign = new OpportunityRestageScheduler();
       
       Test.StopTest();
       
       System.debug('Stage update');
       System.debug(opp1.StageName);  
   }            
}

 

I based the code off this Salesforce blog post which implements the Apex scheduler: http://blog.sforce.com/sforce/2010/02/spring-10-saw-the-general-availability-of-one-of-my-favorite-new-features-of-the-platform-the-apex-schedulerwith-the-apex-s.html

 

This should be an easy one but it doesn't seem to be in the documentation:

 

When executing a hard delete with the bulk api dataloader command line, what is the right syntax?

 

<entry key="process.operation" value="hard delete"/> - this throws an error. As does 'Hard Delete' and 'harddelete.'  So I'm not quite sure what to put.  Regular 'delete' works just fine.

 

Thanks!

We are currently using the dataloader to automate a retention policy on records. For example, we go through every day and delete all records that are older than two years for a certain custom object.

Right now we are on Dataloader v7 which is about 4 years old and we'd like to do an upgrade to the newest Dataloader (v17).

With the new 'bean' format of process-conf.xml, how can we execute a delete query passing in a dynamic date?

It only works today because the old dataloader version used separate config.properties files for every job so we could just generate a file.
Has anyone successfully written callouts to SAP/XI?

I have tried all sorts of combinations, but running into issues:

All my research points that I am doing this correct.  We have tried both self-signed certs and basic username/password authentication.

Setting my stub values:
Stub.inputHttpHeaders_x.put('Authorization','BASIC dnJldmF....W1wcGFzczAx');
--OR--
Blob headerValue = Blob.valueOf(username + ':' + password);//username/password set above String authorizationHeader = 'BASIC '+ EncodingUtil.base64Encode(headerValue);
stub.inputHttpHeaders_x.put('Authorization', authorizationHeader);

We have also tried (separately):
stub.clientCert_x = 'MIIG...';//Where this is the bas64 encoding of the pkc12 version of the cert
stub.clientCertPasswd_x = 'xxxxx';

Nothing seems to get past the security layer.  Has anyone successfully written the outbound message?

 

 

 

 

This is probably really simple, but I haven't seen it done: 

 

After a user fills out my Visualforce form, I want them to be redirected to a "Thank you for your submission" page instead of the native action of viewing the record.

 

How would I do this?

 

Thanks

Hi all,

 

I am  very new to Salesforce.  I have created visual force pages with the help of documents and have written apex classes in standard objects.  Now I am trying to write apex classes in visual force pages.  For example in my visual force page I have a standard 'Save' button which functions normally. If I have to override this normal functionality, how do I do this? Can anyone guide me.

  • April 15, 2009
  • Like
  • 0

I wrote a trigger that figures out who the Lead owner should be based on some rules that we have.

 

When I execute this via web-to-lead, my trigger assigns the appropriate person but in the order of operations after that, Salesforce runs the Lead 'Assignment Rules.'

 

Since I have no formal 'assignment rules' set up, the system assigns every lead to the default lead owner. This only happens in the web to lead scenario - when I manually create a lead or bulk load them with the dataloader, they get assigned properly.

 

Is there a way in Apex to tell the system not to run the assignment rules or is there a way around this situation?

 

Thanks

I'm trying to send a Visualforce email template with custom object information that also lists out some child items. It's a pretty simple idea, but I'm getting a compile error because it doesn't like my child object reference. Can anyone help me correct this? I have bolded the problem line.

 

 

<messaging:emailTemplate subject="Changeover Order Form APPROVED"
recipientType="User" relatedToType="Changeover_Order_Form__c">
<messaging:plainTextEmailBody >

Details:
Account: {!relatedTo.Account__c}

Ingoing Order Amount: {!relatedTo.Ingoing_Order_Amount__c}
Package: {!relatedTo.Package_Options__c}
Gift Card Level: {!relatedTo.Gift_Card_Level__c}
Gift Card dollars used: {!relatedTo.Total_Gift_Card_dollars_used__c}

GIFT CARD SELECTION:
<apex:repeat var="gx" value="{!relatedTo.Gift_Card_Selection}">
Vendor: {!gx.Vendor_Card__c} ] - # of Cards: {!gx.of_Cards__c} ]
</apex:repeat>

View the record: http://www.salesforce.com/{!relatedTo.Id}

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 

I made sure that the Child Relationship Name field was filled in with "Gift_Card_Selection."

Am I missing something else?

 

 

Here's the thing:

Trying to insert record with some apex-ifty code.
Schema says field is date type.
SOQL Dumper spits out 2004-04-05 format
I attempt to insert field_name__c='2004-04-05' in Apex Code
I fail.

Error: Compile Error: Invalid initial expression type for field field_name__c, expecting: Date at line #

Why?

Read Cookbook, Getting started, and forum pages.