• tedevang
  • NEWBIE
  • 30 Points
  • Member since 2009

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

I would like to set a rule that doesn't allow duplicate Opportunity Names. Can this be done with workflow/validation or do I need to set a trigger for this?

 

Thanks.

I would like to add a custom button on the task edit screen that does 2 things:

 

1. Save the task

2. If the Related To is an Opportunity, go to that Opportunity.

 

I believe I just need the javascript code that saves the task and sets the return URL. Any help would be appreciated.

 

Thanks.

I have added a custom button on my task screens which allow our sales reps to create an opportunity directly from the task screen. The button populates certain fields in the new opportunity. What I would like to do is then associate the task that spawned the opportunity with the opportunity that was just created. Is there anything I can do in the button script to do this? Any other way? Below is a copy of the button script:

 

navigateToUrl('/006/e?retURL=%2F{!Account.Id}&accid={!Account.Id}&CF00N80000003yiZu={!Task.Show__c}&00N80000004lILD={!URLENCODE(Task.Description)}&opp17={!Campaign.Name}&conid={!Contact.Id}&opp9={!Today}&opp3=Auto Name on Save&opp11=Verbal Commitment');

 

I was thinking that I might be able to pass the task ID along as one of the parameters and somehow associate it with the opportunity but am unsure how to do this. Help would be greatly appreciated.

 

Thanks.

I have a custom button which populates the account name on a custom activity field using Javascript OnClick. Works great except if the account name has an apostrophe. How would I escape any potential apostrophes from Account.Name in the following javascript?

 

navigateToUrl('00T/e?who_id={!Account.Primary_Contact_Lookup__c}&retURL={!Account.Id}&00N80000004QVPs={!Account.Name}');

This trigger updates a custom task field. I need to bulk load values for this field for existing tasks. How do I keep this trigger from running when doing a Dataloader update (which gives me a "too many SOQL queries" error). Any code snippets for this would be very helpful. Thanks.

 

trigger TaskLinkToParentAccount on Task(before insert, before update) {

    for(Task e : Trigger.new) {
        if    (
            e.WhoId != NULL
            )
        {
        String Link_Id = e.WhoId;
        String Account_ID = '';  
        String Account_Name = '';
        if    (
            Link_Id.startsWith('003')//Contact link
            )
        {         
            Account_ID = [SELECT AccountId FROM Contact WHERE id = :Link_Id limit 1].AccountId;
            Account_Name = [SELECT Name FROM Account WHERE id = :Account_ID limit 1].Name;
        }

        e.Account_Name__c = Account_Name;
        }
    }
   }

Hello,

 

I have the following simple trigger to add a custom field called "Account Name" on the task object:

 

trigger TaskLinkToParentAccount on Task(before insert, before update) {

    for(Task e : Trigger.new) {
        String Link_Id = e.WhoId;
        String Account_ID = '';  
        String Account_Name = '';
        if    (
            Link_Id.startsWith('003')//Contact link
            )
        {         
            Account_ID = [SELECT AccountId FROM Contact WHERE id = :Link_Id limit 1].AccountId;
            Account_Name = [SELECT Name FROM Account WHERE id = :Account_ID limit 1].Name;
        }

        e.Account_Name__c = Account_Name;
        }
   }

 

Here is the test class:

 

public static testMethod void testTaskLinkToParentAccount(){     
    Account a = new Account(name='TestAccount');
    insert a;
    Contact c = new Contact(lastname='Smith');
    insert c;
    Task t = new Task(subject='test', whoid=c.id);
    insert t;
}

 

I am getting the following error when I try to validate deployment:

 

*** Deployment Log ***
# Test Results:

Run Failures:
  testClass.testTaskLinkToParentAccount System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, TaskLinkToParentAccount: execution of BeforeInsert

caused by: System.QueryException: List has no rows for assignment to SObject

Trigger.TaskLinkToParentAccount: line 12, column 28: []

 

This trigger runs fine in the sandbox so I'm missing something in the test class. Hopefully an easy fix. Any ideas?

 

-Ted

I'm using the following javascript to invoke a new task for the primary contact (a custom lookup field on the Account object). The task is created just fine with the primary contact in the Contact field, but upon saving, it returns to the home page instead of the account page from which it was called. Any suggestions that would redirect this to the account page?

 

navigateToUrl('/00T/e?who_id={!Account.Primary_Contact_Lookup__c}&retURL=%2F{!Account.Id}');

 

Thanks.

 I'm trying to create a task in the same screen as the opportunity using the trigger below. When I use this in the Lead object it works fine but on the opportunity object it doesn't create the task nor gives me an error. Can anyone see where my error may lie?

 

Thx.

 

trigger taskCreator on Opportunity (before insert, before update, after insert) {
  if (Trigger.isBefore) { 
    Map<Id, Opportunity> opportunityMap = new Map<Id, Opportunity>();


 } else if (Trigger.isAfter)  { 
    // after leads are inserted
    List<Task> followupTasks = new List<Task>(); // build list in memory
    for (Opportunity opp : System.Trigger.new) {
        Task task = new Task(
          //WhoId = opp.Assigned_To__c, 
          //Description = opp.Synopsis__C, 
          Priority = 'High', 
          ReminderDateTime = opp.Due_Date__C, 
          Status = 'Not Started', 
          Subject = opp.Quick_Task_Subject__c);
        followupTasks.add(task);   // add to list
    }

        // insert the entire list
    insert followupTasks;  // NOTE: this is outside the above loop, only one insert is needed

 } // end of isAfter

}// end of trigger

I have both custom fields and objects (accessed by related lists) that need to be moved to the account once the lead is converted. How would I accomplish the following:

  1. Move custom field values from lead to account
  2. Move contents of a custom object related list (which might have multiple entries) from lead to account
  3. Trigger some custom fields in account object to be automatically set to a specified value.

Thanks for any help on this.

 

-Ted

I would like to set a rule that doesn't allow duplicate Opportunity Names. Can this be done with workflow/validation or do I need to set a trigger for this?

 

Thanks.

I have added a custom button on my task screens which allow our sales reps to create an opportunity directly from the task screen. The button populates certain fields in the new opportunity. What I would like to do is then associate the task that spawned the opportunity with the opportunity that was just created. Is there anything I can do in the button script to do this? Any other way? Below is a copy of the button script:

 

navigateToUrl('/006/e?retURL=%2F{!Account.Id}&accid={!Account.Id}&CF00N80000003yiZu={!Task.Show__c}&00N80000004lILD={!URLENCODE(Task.Description)}&opp17={!Campaign.Name}&conid={!Contact.Id}&opp9={!Today}&opp3=Auto Name on Save&opp11=Verbal Commitment');

 

I was thinking that I might be able to pass the task ID along as one of the parameters and somehow associate it with the opportunity but am unsure how to do this. Help would be greatly appreciated.

 

Thanks.

This trigger updates a custom task field. I need to bulk load values for this field for existing tasks. How do I keep this trigger from running when doing a Dataloader update (which gives me a "too many SOQL queries" error). Any code snippets for this would be very helpful. Thanks.

 

trigger TaskLinkToParentAccount on Task(before insert, before update) {

    for(Task e : Trigger.new) {
        if    (
            e.WhoId != NULL
            )
        {
        String Link_Id = e.WhoId;
        String Account_ID = '';  
        String Account_Name = '';
        if    (
            Link_Id.startsWith('003')//Contact link
            )
        {         
            Account_ID = [SELECT AccountId FROM Contact WHERE id = :Link_Id limit 1].AccountId;
            Account_Name = [SELECT Name FROM Account WHERE id = :Account_ID limit 1].Name;
        }

        e.Account_Name__c = Account_Name;
        }
    }
   }

 I'm trying to create a task in the same screen as the opportunity using the trigger below. When I use this in the Lead object it works fine but on the opportunity object it doesn't create the task nor gives me an error. Can anyone see where my error may lie?

 

Thx.

 

trigger taskCreator on Opportunity (before insert, before update, after insert) {
  if (Trigger.isBefore) { 
    Map<Id, Opportunity> opportunityMap = new Map<Id, Opportunity>();


 } else if (Trigger.isAfter)  { 
    // after leads are inserted
    List<Task> followupTasks = new List<Task>(); // build list in memory
    for (Opportunity opp : System.Trigger.new) {
        Task task = new Task(
          //WhoId = opp.Assigned_To__c, 
          //Description = opp.Synopsis__C, 
          Priority = 'High', 
          ReminderDateTime = opp.Due_Date__C, 
          Status = 'Not Started', 
          Subject = opp.Quick_Task_Subject__c);
        followupTasks.add(task);   // add to list
    }

        // insert the entire list
    insert followupTasks;  // NOTE: this is outside the above loop, only one insert is needed

 } // end of isAfter

}// end of trigger