• Shawn Low 24
  • NEWBIE
  • 20 Points
  • Member since 2018
  • Sr Salesforce Administrator
  • TRI Pointe Group

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 14
    Replies
I need to populate one more field, but it's a little tricky.
1. Currently, when a new Task is created, the salespersopn needs to select a value for a custom field called "Division". This field is a picklist and it lists all the different divisions our company has.
2. Once they select a Division, the field "Community Site" becomes "active (It's a dependant picklist) and lists all the different tracts of homes we have, for that specific division.
** The field I would like to pre-populate is the "Division" field.
Challenges:
1. I need to prepopulate the Division field during Task creation, so using a workflow or a Process will not work, so the functionality of pre-populating the field needs to be within the coding of the button.
2. The field "Division" on the Task, is a custom field.
Current Button Code:
window.open('/00T/e?tsk1_lkid='+'{!$User.Id}'+'&tsk5=Community Appointment from NHS&who_id='+'{!Lead.Id}'+'&tsk13=Normal&tsk12=Not Started&00Nj000000AMbZA=Community Appointment from NHS');
Screen Shots:
User-added image
The Red Box is the custom field (picklist) "Division".
The Blue Box is the custom field (multi picklist) "Community Site"

Considerations:
The User Detail section on the User record, has a field called "Division". If there were a way to grab the value in this field and pre-populate it into the Division field on the Task, that could be added to the button code, that would be perfect.

Help :)
When clicked, a new Task window opens and there are several fields that are pre-populated. Here is the code for the button:

window.open('/00T/e?tsk1_lkid='+'{!$User.Id}'+'&tsk5=Community Appointment from NHS&who_id='+'{!Lead.Id}'+'&tsk13=Normal&tsk12=Not Started&00Nj000000AMbZA=Community Appointment from NHS');

I am trying to populate one more field. It's a "Pick List" field. It is also a custom field.
(I'm going to add pictures so you all can see what I am talking about)
The custom button on the Lead:

User-added image

The task screen that opens when you click the button: The red arrows show what is prepopulated and the Blue box & arrow show the field I would like to populate.

User-added image

Now here is a twist. The custom field "Division" is a picklist, I stated that earlier, however, the field directly below it, (a custom field that is a multi picklist field) is controled by the "Division" field.
Meaning that once you choose a value for Division, the multi pick list "Community Site" become active and has a predefined list of values. Of which the user can select as many as they like.

My challenge is to find a way to pre-populate the custom picklist field (Division).
I have actually created a formula field called "Division_v2", which looks to the User record for its value. The field is not on the Task page layout, as it was only meant for reference. I was hoping to use a Process to populate or update the field on the Task screen, but those processes, need to wait until the Task is actually "saved" or created, and I need the field to be pre-populated when the User is creating the Task (just like the other pre-populated fields).
I tried adding this to the button code (Red Box), but I am getting an error:
User-added image

Any thoughts??
Thanks
Shawn
 
However, I keep getting errors.
I am just trying to create a custom button that opens up a task window. Then the person fills things in and then clicks "save" and the task is created.
Here's what I have as Javascript...

{!REQUIRESCRIPT("/soap/ajax/41.0/connection.js")}

  var taskToCreate            = new sforce.SObject("Task");

   taskToCreate.OwnerId        = "{!$User.Id}";
   taskToCreate.Division__c    = "{!User.Division}";
   taskToCreate.Task_Type__c   = "Community Appointment from NHS";
   taskToCreate.Subject        = "Community Appointment from NHS";
   taskToCreate.WhoId          = "{!Lead.Id}";
   taskToCreate.Priority       = "Normal";
   taskToCreate.Status         = "Not Started";

  result = sforce.connection.create( [ taskToCreate ] );

   result[0].success == ("true"){ location.reload()};

Im just learning Javascript so I apologize for missing the obvious thing casuing me to get erros.
Thanks
Shawn
I built a custom button in my Dev sandbox that is supposed to open a Task window and pre-populate several fields. The sales person then selects a due date and adds notyes and saves. Pretty simple. I am using Javascript and here is my code.
It is a "Detail Page Button" and the Behavior is "Execute Javascript". The Content Source is "OnClickJavascript"

{!REQUIRESCRIPT("/soap/ajax/41.0/connection.js")}

var taskToCreate = new sforce.SObject("Task");
taskToCreate.OwnerId = "{!$User.Id}";
taskToCreate.Task_Type__c = "Community Appointment from NHS";
taskToCreate.Subject = "Community Site Visit";
taskToCreate.Division__c = "Pardee Homes - Inland Empire";
taskToCreate.WhoId = "{!Lead.Id}";
taskToCreate.Priority = "Normal";
taskToCreate.Status = "Not Started";

var result = sforce.connection.create( [ taskToCreate ] );

window.parent.location.href = "/" + result[0].id + "/e";

In my Dev Sandbox, is works great. I pushed out to the Full Sandbox for testing and received this error...
User-added image
Im not using a URL
I have been going a little crazy trying to figure this out.
Why is this not working in the Full Sandbox, but not in my Dev Sandbox?
There is a Trigger and a Class that creates three seperate tasks and assignes them to three seperate sales people (the three sales people are all part of a sales team). The issue is, and what I have been asked to create, is someway that when one of the three sales people "complete" thier assigned task, the other two tasks that are assigned to the other two people, also close (the status is changed to "Completed").
I have tried using workflows and the Process Buider, but I am not having any luck, so I need to turn to my Developer community for help on this.
Any suggestions, thoughts, or outright solutions?
Thank you
Shawn
I am posting a Trigger that was written before I started at this company. Being new to coding, I dont fully understand what is happening in this trigger. I wanted to ask if someone could please break things down for me so I can "connect" what the code says and what action is happening.
I am hoping someone can use snagit or something like that, and box off each part of the code, and then type in the explaination of what that code is telling SFDC to so.
Thank you for all your help.
Here is the trigger code...

//=================================================================================================
// Company: TRI Pointe Group
//  Author: Matt Starr (EnablePath)
// Created: 07/22/2016   
// Comment: Task Trigger
//=================================================================================================
//          Date            Purpose
// Changes: 07/22/2016    Matt Starr (EnablePath) Created
//=================================================================================================

trigger TaskTrigger on Task (after delete, after insert, after undelete, 
                                    after update, before delete, before insert, before update) {

    //Trigger Handler
    TaskTriggerHandler handler = new TaskTriggerHandler();

    //Before Insert
    if (Trigger.isBefore && Trigger.isInsert && !OpportunityTriggerHandler.onInsert) {
        handler.OnBeforeInsert(Trigger.new);
    }

    //After Insert
    if (Trigger.isAfter && Trigger.isInsert && !OpportunityTriggerHandler.onInsert) {
        handler.OnAfterInsert(Trigger.new);
    }

    //Before Update
    if (Trigger.isBefore && Trigger.isUpdate && !OpportunityTriggerHandler.onInsert) {
        handler.OnBeforeUpdate(Trigger.newMap,Trigger.oldMap);
    }
    
    //After Update
    if (Trigger.isAfter && Trigger.isUpdate && !OpportunityTriggerHandler.onInsert) {
        handler.OnAfterUpdate(Trigger.newMap,Trigger.oldMap);
    }

    

}
However, I keep getting errors.
I am just trying to create a custom button that opens up a task window. Then the person fills things in and then clicks "save" and the task is created.
Here's what I have as Javascript...

{!REQUIRESCRIPT("/soap/ajax/41.0/connection.js")}

  var taskToCreate            = new sforce.SObject("Task");

   taskToCreate.OwnerId        = "{!$User.Id}";
   taskToCreate.Division__c    = "{!User.Division}";
   taskToCreate.Task_Type__c   = "Community Appointment from NHS";
   taskToCreate.Subject        = "Community Appointment from NHS";
   taskToCreate.WhoId          = "{!Lead.Id}";
   taskToCreate.Priority       = "Normal";
   taskToCreate.Status         = "Not Started";

  result = sforce.connection.create( [ taskToCreate ] );

   result[0].success == ("true"){ location.reload()};

Im just learning Javascript so I apologize for missing the obvious thing casuing me to get erros.
Thanks
Shawn
I built a custom button in my Dev sandbox that is supposed to open a Task window and pre-populate several fields. The sales person then selects a due date and adds notyes and saves. Pretty simple. I am using Javascript and here is my code.
It is a "Detail Page Button" and the Behavior is "Execute Javascript". The Content Source is "OnClickJavascript"

{!REQUIRESCRIPT("/soap/ajax/41.0/connection.js")}

var taskToCreate = new sforce.SObject("Task");
taskToCreate.OwnerId = "{!$User.Id}";
taskToCreate.Task_Type__c = "Community Appointment from NHS";
taskToCreate.Subject = "Community Site Visit";
taskToCreate.Division__c = "Pardee Homes - Inland Empire";
taskToCreate.WhoId = "{!Lead.Id}";
taskToCreate.Priority = "Normal";
taskToCreate.Status = "Not Started";

var result = sforce.connection.create( [ taskToCreate ] );

window.parent.location.href = "/" + result[0].id + "/e";

In my Dev Sandbox, is works great. I pushed out to the Full Sandbox for testing and received this error...
User-added image
Im not using a URL
I have been going a little crazy trying to figure this out.
Why is this not working in the Full Sandbox, but not in my Dev Sandbox?
There is a Trigger and a Class that creates three seperate tasks and assignes them to three seperate sales people (the three sales people are all part of a sales team). The issue is, and what I have been asked to create, is someway that when one of the three sales people "complete" thier assigned task, the other two tasks that are assigned to the other two people, also close (the status is changed to "Completed").
I have tried using workflows and the Process Buider, but I am not having any luck, so I need to turn to my Developer community for help on this.
Any suggestions, thoughts, or outright solutions?
Thank you
Shawn
I am posting a Trigger that was written before I started at this company. Being new to coding, I dont fully understand what is happening in this trigger. I wanted to ask if someone could please break things down for me so I can "connect" what the code says and what action is happening.
I am hoping someone can use snagit or something like that, and box off each part of the code, and then type in the explaination of what that code is telling SFDC to so.
Thank you for all your help.
Here is the trigger code...

//=================================================================================================
// Company: TRI Pointe Group
//  Author: Matt Starr (EnablePath)
// Created: 07/22/2016   
// Comment: Task Trigger
//=================================================================================================
//          Date            Purpose
// Changes: 07/22/2016    Matt Starr (EnablePath) Created
//=================================================================================================

trigger TaskTrigger on Task (after delete, after insert, after undelete, 
                                    after update, before delete, before insert, before update) {

    //Trigger Handler
    TaskTriggerHandler handler = new TaskTriggerHandler();

    //Before Insert
    if (Trigger.isBefore && Trigger.isInsert && !OpportunityTriggerHandler.onInsert) {
        handler.OnBeforeInsert(Trigger.new);
    }

    //After Insert
    if (Trigger.isAfter && Trigger.isInsert && !OpportunityTriggerHandler.onInsert) {
        handler.OnAfterInsert(Trigger.new);
    }

    //Before Update
    if (Trigger.isBefore && Trigger.isUpdate && !OpportunityTriggerHandler.onInsert) {
        handler.OnBeforeUpdate(Trigger.newMap,Trigger.oldMap);
    }
    
    //After Update
    if (Trigger.isAfter && Trigger.isUpdate && !OpportunityTriggerHandler.onInsert) {
        handler.OnAfterUpdate(Trigger.newMap,Trigger.oldMap);
    }

    

}