• kyle.t
  • NEWBIE
  • 344 Points
  • Member since 2010

  • Chatter
    Feed
  • 13
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 126
    Replies

I want my button to default todays date in a date field

 

When I do


&00N80000003BpHg={!NOW()}

or

&00N80000003BpHg={!TODAY()}

 

Nothing is populated.

 

Please let me know what I need to do.

 

Thank you in advance

 

  • January 31, 2011
  • Like
  • 0

Hello,

 

I need to add a field to the lead detail page which calculates the number of days since the last activity for a lead. This formula would return a number which represents the number of days since the last task has been created, updated or completed. Does anyone know what this formula is?

 

Thanks,

 

Scott

  • January 25, 2011
  • Like
  • 0

This is the trigger i have written on Case object which updates a field in Account object. When i am closing a case, the following error shows up.

 

 

 for(Case ca:Trigger.New)
    {
      Id1=ca.AccountId;    
      Account acct=[Select a.id, a.Name, a.Last_Contacted_date__c, a.Contacted__c from Account a where a.Id=:ID1];
        if(ca.Subject=='New Member Outreach' && ca.Status=='Closed' && ca.AccountId==acct.Id)
        {
            acct.Contacted__c=True;
            acct.Last_Contacted_date__c=ca.ClosedDate;

        } 
                 database.update(acct);   --> Error: at this line       
    }
         
}

Error is: updateAccount_Premium: execution of AfterUpdate
caused by: System.DmlException: Update failed. First exception on row 0
with id 001P000000GIss5IAD; first error:
INVALID_FIELD_FOR_INSERT_UPDATE, Account: bad field names on
insert/update call: Name: [Name]: Trigger.updateAccount_Premium:
  • January 25, 2011
  • Like
  • 0

I'm trying automate the entry of recurring monthly donations for a non-profit. The process involves an object called monthly_gift__c (where I want to copy from) and an object called donation__c (where I want to copy to).

 

I keep gettinging Error: Compile Error: Incompatible element type SOBJECT:Monthly_Gift__c for collection of SOBJECT:Donation__c at line 22 column 9, and I assume its because the columns in the 2 table don't line up perfectly.

 

I'm not sure how to modify the list/collection before inserting, or if that is even the best method to use here.

 

Any help would be much appreciated,

James

 

public class updatepledges
{


    //added an instance varaible for the standard controller
    private ApexPages.StandardController controller {get; set;}
       
        public updatepledges(ApexPages.StandardController controller)
        {
            //initialize the stanrdard controller
            this.controller = controller;
            
   

 


    List<Donation__c> donations = new List<Donation__c>();
    for (Monthly_Gift__c mg: [SELECT Account__c, Contact__c, PaymentType__c FROM Monthly_Gift__c])
// the last line is causing the error. how can i extrract from donation__c and insert into Monthly_Gift__c??? 

{

        Monthly_Gift__c Newmg = mg.clone(false);
        donations.add(Newmg);
    }
    insert donations;

 

 

// the same problem will presumably come up again in the next few lines of code, where i insert detail records

    List<Allocation__c> allocations = new List<Allocation__c>();
    for (Donation__c currdon : donations)  
    {
        for(Monthly_Gift_Allocations__C mga: [SELECT Amount__c, Monthly_Gift__c, Program__c, Stream__c FROM Monthly_Gift_Allocations__c])
        {  
            Monthly_Gift_Allocations__c Newmga = mga.clone(false);
            allocations.add(Newmga);
        }
    }
    insert allocations;

}
}

On a contact I have mailing address and Other Address.

how can I check if the both address are same without writing my own code

 

any suggestions?

Hello,

Please tell me if you don't understand my question:

I want the field Name of my custom object to be something like {000000}-{000}, where {000000} is the number of the object and {000} is the number of the version, that should be incremented not when a record is created, but when some specific fields or child objects are updated. I can't use Auto Number, so I was thinking about using a Text name field and fill it with a trigger. I would have an Auto Number field called Object_Number__c and a Number Field called Version_Number__c. So, I would set the object name with: MyObject__c.Name = Object_Number__c + '-' + Version_Number__c; or something like that.

If I try to do this with a Before Insert Trigger, what I get in the name of my object is null-null because the Auto Number and the Number Fields are null before inserting. If I try to do this with an Afetr Insert Trigger, I can't change any field and I get the error "Record is Readonly". Does anyone have any idea of how to achieve this?

 

 

trigger formatName on MyObject__c (after insert) {


    for(MyObject__c o : Trigger.new) {

        MyObject__c.Name = MyObject__c.Object_Number__c + '-' + MyObject__c.Version_Number__c;

    }

}

 

 

Hi,

 

Can anybody pls tell me how to retrieve list of Tasks for a particular Case using Apex coding.

  • December 29, 2011
  • Like
  • 0

Hi,

 

I'm having a problem with a Apex Class i've written. The class is intended to convert incoming e-mails to Bugs (Custom Object) and notify the sender that his/her e-mail has been received. In the notification the Bug ID should be included. Unfortunaltely when submitting an e-mail, in the sent notification null is displayed in stead of the actual Bug ID.

 

Can anyone tell me what i'm doing wrong?

 

Thanks in advance!

 

This is the script:

 

 

global class IncomingEmailToBugxxxx2 implements Messaging.InboundEmailHandler {
 
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope envelope)
    {
 
 
  // Create an inboundEmailResult object for returning the result of the Apex Email Service
 Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
        try
        {
            // Obtain the applicants name and the position they are applying for from the email.
            String emailFrom = envelope.fromAddress;
            String emailBody = email.plainTextBody;
            String emailSubject = email.subject;
            

  // Process the email information.
            processBugEmail(emailFrom, emailBody, emailSubject, email.binaryAttachments);            

            // Success.
            result.success = true;          
        }
       catch (Exception e)
        {
            // Return an email message to the user.
            result.success = false;         
            result.message = 'An error occured processing your message. ' + e.getMessage();
        }
        return result;
   }

   public static void processBugEmail(String emailFrom, String emailBody, String emailSubject, Messaging.InboundEmail.BinaryAttachment[] binaryAttachments)
   {
 

 
  // New Task object to be created
 
   SFDC_Bug__c newBug = new SFDC_Bug__c();
       newBug.Problem_Description__c =  emailBody;
       newBug.Priority__c = 'P4 - Low';
       newBug.Status__c = 'Open';
       newBug.Problem__c = emailSubject;
  insert newBug;

       if (binaryAttachments!=null && binaryAttachments.size() > 0)
        {
            for (integer i = 0 ; i < binaryAttachments.size() ; i++)
            {
                Attachment attachment = new Attachment();
                attachment.ParentId = newBug.Id;
                attachment.Name = binaryAttachments[i].Filename;
                attachment.Body = binaryAttachments[i].Body;
                insert attachment;


            }
        }
        
        // Confirm receipt of the applicants email
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses( new String[] { emailFrom });
        mail.setSenderDisplayName('xxxx Bug Management');
        mail.setReplyTo('no-reply@xxxx.net');
        mail.setSubject('Bug registration notification - ' + newBug.Name +'');
        mail.setPlainTextBody('*** AUTOMATED MESSAGE - PLEASE DO NOT REPLY AS YOU WILL NOT RECEIVE A REPLY ***' +
        '\n\nDear Sir, Madam,' +
        '\n\nThank you for your e-mail regarding a bug in the xxxx-platform.' +
        '\n\nYour e-mail has been correctly received and has been registerd with the reference number ' + newBug.Name + '. We will investigate the bug you have reported as quickly as possible and provide you with the nessesary feedback.' +
        '\n\nIf you have any questions regarding this matter, please do not hesitate to contact us by sending an e-mail to xxxx or if you prefer, you can contact us by telephone at xxxx during business hours. While contacting us please quote the reference number mentioned above.' +
        '\n\nKind regards,' +
        '\n\nxxxx Support');
         
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });               
   }
   
   /*
    * Represents errors that have occured interpretting the incoming email message
    */
   class ProcessApplicantException extends Exception
   {
   }  
}

 

 

System.AssertException: Assertion Failed: Expected: 9, Actual: 10

 

I have assert statement system.assertequals(mapCntr.cmapSegments.size(),10);

the cmapsegments is returning 9 elemetns and I put 10 to fail the assertion , it does but with wrong expected and actual numbers.

 

org type: sandbox

 

I have a trigger that needs to filter only the records affected that fall into a certain Record Type.  In the past I've made multiple calls to get some variables for the record types I want to use and then use if statements, but that is a poor use of resources.  I'd rather just pull those record types into a list or set so that I could match for a value in a set when looping.

 

Here's what I'd like to do:

 

// Create a list of RecordTypes we want to check for
List<RecordType> rtID = [SELECT Id FROM RecordType WHERE (SobjectType = 'Opportunity') AND (Name = 'Annuity' OR Name = 'Life' OR Name='LTC' OR Name = 'TLC')]; // Create a list for Opportunities that match our RecordType criteria List<Opportunity> opptsToWorkOn = new List<Opportunity>(); // Loop through the Opportunities being updated or deleted and see if there are any // for the record types we want. if(trigger.isDelete){ for (Opportunity o : Trigger.old) {

\\ #### HERE IS WHAT DOESN'T WORK ": rtID" - Does anyone know how to do this?
 If (o.RecordTypeId = : rtID) opptsToWorkOn.add(o); } } else{ for (Opportunity o : Trigger.new) { \\ #### I WOULD ALSO DO IT HERE! #########
If (o.RecordTypeId = : rtID) opptsToWorkOn.add(o); } }

 

Can someone point me in the right direction?

 

Thanks!

Greg

 

 

 

 

    \\ #### HERE IS WHAT DOESN'T WORK ": rtID" - Does anyone know how to do this?

I think I may have identified a bug and need some help ensuring that I am right.  I have a trigger on the FeedItem object that checks to see if a filename contains jpg, png or gif.  from there it grabs the ContentData.  when loading a gif or png to a FeedItem, this works fine, but when I load a jpg, I am not seeing the data on the FeedItem

 

I have done some debuging and see that it returns Blob[0] for jpg but Blob[<large integer>] for gif and png.

 

the basic idea of the code is this: 

 

 

trigger myTrigger on FeedItem (after insert) {
    
    for(FeedItem f : trigger.new){
        if(f.ContentFileName <> null && 
            ( f.ContentFileName.toLowerCase().endsWith('jpg') ||
              f.ContentFileName.toLowerCase().endsWith('gif') ||
              f.ContentFileName.toLowerCase().endsWith('png') 
            )            
           )
     {
          System.debug(f.ContentData);

     }
}

 

Please let me know if there is something I am missing or if you are experiencing the same issue.

 

  • April 23, 2011
  • Like
  • 0

I am leveraging the cookbook solution to prevent duplicate leads in order to stop duplicate contacts from being created. That is working just fine at this point, but here's the twist.  Contacts are private, so even if they search, they may not find the contact in question.  When they try to create a contact that is a duplicate, we want to automatically share the original contact with them using sharing rules and present a link to the newly shared contact.

I am leveraging the cookbook solution to prevent duplicate leads in order to stop duplicate contacts from being created. That is working just fine at this point, but here's the twist.  Contacts are private, so even if they search, they may not find the contact in question.  When they try to create a contact that is a duplicate, we want to automatically share the original contact with them using sharing rules and present a link to the newly shared contact.

 

 

Independantly the two actions work.  I can insert a sharing rule, I can stop the duplicte from being created, but when I try to do both together, it appears that the addError on the contact rolls back the insert of the sharing record.

 

 

trigger ContactDuplicateTrigger on Contact (before insert, before update) {
	Map<String, Contact> contactMap = new Map<String, Contact>();
    
    for (Contact c : trigger.new) {
         
        // Make sure we don't treat an email address that     
        // isn't changing during an update as a duplicate. 
     
        if ((c.Email != null) && (trigger.isInsert || (c.Email != trigger.oldMap.get(c.Id).Email))) {
         
            // Make sure another new lead isn't also a duplicate      
            if (contactMap.containsKey(c.Email)) {
                c.Email.addError('Another new contact has the same email address.');
            } else {	
                contactMap.put(c.Email, c);
            }
       }
    }
     
    // Using a single database query, find all the leads in 
    // the database that have the same email address as any 
    // of the leads being inserted or updated. 
     
    for (Contact c : [SELECT Email, Owner.Name FROM contact WHERE Email IN :contactMap.KeySet()]) {
        Contact newContact = contactMap.get(c.Email);       	
        ContactShare cShare = new ContactShare();
        cShare.ContactId=c.id;
        cShare.UserOrGroupId = UserInfo.getUserId(); 
        cShare.ContactAccessLevel = 'Edit';		
		
		newContact.addError('A contact with this email address already exists and is owned by ' + c.Owner.Name + 
                            '.  You have been granted access to this record and ' + c.Owner.Name + ' has been notfied.' +
                            'The Link for the existing contact is: <a href="/' + c.id + '"> Link </a>' ); 
		Database.insert(cShare,false);      		          	      	        
    }
}
  • December 03, 2010
  • Like
  • 0

I am working on a visualforce tool that displays all of the open opportunities a user is involved with.  At our company, that may mean they own the opportunity or they are the Sales Manager or Account Manager on the opportunity.  In the controller I am querying the opportunities for anything that is open that the current user is the owner of OR they are listed as the account manager or the sales manager.

 

We have sharing rules set up to share opportunities owned by someone in a district with everyone else in the district.

 

The visualforce tool is displaying all of the opportunities in a pageblocktable using inputFields to allow for quick updates to multiple opportunities at once.

 

The issue is that the query to get the opportunities may bring back opportunities that the user cannot actually edit, but because the visualforce page uses inputfields the user could try to edit the record, click save and get an error.  This happens when the opportunitiy is created by somebody outside of the users district and the owner is not changed to within the district.  (This is not something I designed and I know that this could be reimplemented in a differnent way, but that is not a battle I can fight right now).

 

I tried to alleviate this problem by querying the OpportunityShare table to determine the proper access, however, since some of the access is granted by the role hierarchy, I am unsure how to determine if a user has edit access on the opportunity.  If the users ID shows up in the UserOrGroupId Column this is easy, but if they are part of a group whose ID is in the UserOrGroupId column then I am not sure how to proceed.

 

My question boils down to: How can I determine if a user has access to a record so that I can exclude those that can't be edited from being displayed?

  • August 11, 2010
  • Like
  • 0

I am trying to create a Mass Edit page where our reps can see certain fields on all of the opportunities they are involved in.  I have the page rendered with all of the records and am attempting to implement a save button that will only update those records which have actually been changed.  Currently, using even the standard controller save functionality, ALL records are modified, but we don't want it to look like a rep changed ALL his records when, in fact, only a few records may have been updated. 

 

Here is what I have right now, but opportunityList is reflecting no changes, so nothing gets updated:

 

public PageReference save() {
	List<Opportunity> updateList = new List<Opportunity>(); //to capture the opportunities that need to be updated
	for (Integer i=0; i < opportunityList.size();i++){ //loop through the opportunities and if anything has been changed, we will update it.
		if(opportunityList.get(i).opp <> originalOpportunityList.get(i).opp){
			updateList.add(opportunityList.get(i).opp);
		}
	}
	update updateList;
	originalOpportunityList = opportunityList;
	return null;
}

 

I belive I need to access the current page values and do some sort of comparison, but I am unsure exactly how to do that.  Any help would be greatly appreciated.

 

Thank you!

 

Hello,

 

I am unable to check the save Hierarchy check box in the Report Properties on a Report.

I had to kind of play around as we had some visibility issue. I unchecked it first later on when I try to check it, this do not work. But If I hit on the Save buton on report and then I will have ability to check this. Though I check it, guess what Its gone again.

 

I do have SYS ADMIN rights.

Can someone please help me or gimme an idea?

 

Thank you!

 

I think I may have identified a bug and need some help ensuring that I am right.  I have a trigger on the FeedItem object that checks to see if a filename contains jpg, png or gif.  from there it grabs the ContentData.  when loading a gif or png to a FeedItem, this works fine, but when I load a jpg, I am not seeing the data on the FeedItem

 

I have done some debuging and see that it returns Blob[0] for jpg but Blob[<large integer>] for gif and png.

 

the basic idea of the code is this: 

 

 

trigger myTrigger on FeedItem (after insert) {
    
    for(FeedItem f : trigger.new){
        if(f.ContentFileName <> null && 
            ( f.ContentFileName.toLowerCase().endsWith('jpg') ||
              f.ContentFileName.toLowerCase().endsWith('gif') ||
              f.ContentFileName.toLowerCase().endsWith('png') 
            )            
           )
     {
          System.debug(f.ContentData);

     }
}

 

Please let me know if there is something I am missing or if you are experiencing the same issue.

 

  • April 23, 2011
  • Like
  • 0

I'm green so be gentle :smileyhappy: I'm more of an architect looking to move or rebuild an app on force.com and I'm looking to make sure that the key parts of this app will be able to be built with Force.com

 

The functionality I'm looking for or testing is this...  I will have a table with of over 15,000 codes or values that will grow soon to over 60,000 codes-  This table will serve as a Lookup to another table in which there will be about 36 possible fields in which codes will be entered from the "lookup" table

 

We want to be able to more or less build a rules engine-  starting with simple ones such as  no code can be the same in any of the 36 fields.  Then move to creating more complex to things like  if field 1= X  then   Field 17  can't be this, this , this, this, this ,this....so what if the list of what can't go in the field is huge like 200 or more.

 

When they type in these fields they wil only be able to enter values that are in the lookup table.  This is more of user interface type question but maybe someone knows-  can you enter a value in a field and have it validate or work these "rules" on the fly versus filling out the whole "form and then validating??  Thanks much!

  • February 09, 2011
  • Like
  • 0

Good day, 

 

I trying to create a condition in order to get the value appear in email template

 

the condition like following 

 

If approved reason = "Not Exceed" then show "Other approve reason" which is user entry value, i put it in this way but when i try to test the template, it doesn't show me the "Other approve reason" value

 

** Approved reason is picklist whereas "Other approve reason" is textfield

 

My try on following, but it doens't show me the "Other approved reason" value, any clue ?

 

 

{!IF(ISPICKVAL(myObject.Approved_Reason__c,"Not Exceed"),myObject.Other_approved_reason__c,"") OR 
!IF(ISPICKVAL(myObject.Approved_Reason__c,"Exceed"),"Exceed","")
}

 

Thanks in advance !

 

  • February 09, 2011
  • Like
  • 0

Anyone else seeing this?

 

Occurs on "Edit" of Account that has the Edit button overridden to bring up an AccountEditVFPage.

 

Debug logs shows no error!

 

Ideas?

  • February 09, 2011
  • Like
  • 0

I am trying build an outer join to display a list of contacts showing if they have a related portal user records or not.

 

I know you can get a list of related contacts from the user object but is it possible to go from contacts to user? 

 

I know this works...Select u.isactive, u.Contact.name From User u but what about Select name, c.user.isactive From Contact c?

 

Any thoughts how I can outer join these two tables and display one list? 

 

Thanks

 

I want my button to default todays date in a date field

 

When I do


&00N80000003BpHg={!NOW()}

or

&00N80000003BpHg={!TODAY()}

 

Nothing is populated.

 

Please let me know what I need to do.

 

Thank you in advance

 

  • January 31, 2011
  • Like
  • 0

Hi,

 

I am admin of one instance it was in production. I am unable to login, i can get ssword using forgot password option. But i dont want reset that password because this instance integrated with some other application that is the reason i am unable to reset my password. In this integration i used that password if i reset the password automatically the integration will collapsable.

 

Please advice me any one of you with solution Immediatly.

 

 Thank you

  krish

When you convert a LEAD into Account/Contact, Salesforce.com has rules in place that copies the data where it deems best.   One example is the LEAD SOURCE field winds up being transferred over to ACCOUNTS level record.    I however also want that same data to appear down in each CONTACT record that is a part of that same ACCOUNT.   When we are on the phone, I want to know what the LEAD SOURCE is.    How can this be solved?     Can I just display the account field LEAD SOURCE in the Contact view?  Or perhaps I have to create a custom field in CONTACTS level and create a formula for grabbing/copying that data down into Contacts - Lead Source field.

 

NOTE:  We are on GROUP EDITION of Salesforce.

 

Thanks for your assistance.

Hey guys,

I need some suggestions on how to write a trigger for this particular criteria.

Scenario is like this: An Account is created.And there is No activity on the account for 3 weeks. (no update, or delete).
I need to write a trigger for this inactivity, on Account. I am stumped because  until and unless there is some action on account, my trigger wont get fired.

so i need some suggestions on how to move forward with this.


  • January 26, 2011
  • Like
  • 0

Hi,

 

     I have a requirement where in the default values have to be set for the Standard Field of Opportunity i.e. Opportunity Name, could any one suggest a solution for this. 

 

 

Thanks & Regards

 

Arun