• Rob Petrie
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Context: Based on the way our sales reps need to view activity data (with respect to how our parent and child accounts are related), we had to create custom buttons for logging calls. After developing these buttons, they are exactly what our sales reps need and actually have been improved to be a substantial time saver, even with the final lingering error I can't seem to code around. 

Below is the code I have for a Custom Call button. We have multiple buttons for different activity types, but they all follow this pattern. The issue: When our AEs click save, it takes them to their home page as opposed to taking them back to the contact record that they logged the call on. Most of them use multiple tabs, and as stated these custom buttons save us time and map our activity in the unique way we need it to, but it would be awesome to figure out the issues in the last part of my code (In bold) to get them back to the contact or account that they logged the activity at when they click save. Any help is GREATLY appreciated!

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

var taskObj = new sforce.SObject("Task"); 
taskObj.RECORDTYPEID = '012a0000001WDSk'; 
taskObj.Type = 'Cold Call';
taskObj.WhoId = '{!NULLVALUE(Contact.Id,Lead.Id)}';
taskObj.WhatId = '{!NULLVALUE(Account.ParentId, Account.Id)}';
taskObj.Status = 'Completed';

var year = '{!TEXT(YEAR(TODAY()))}';
var month = '{!IF(LEN(TEXT(MONTH(TODAY())))==1,"0"&TEXT(MONTH(TODAY())),TEXT(MONTH(TODAY())))}';
var day = '{!IF(LEN(TEXT(DAY(TODAY())))==1,"0"&TEXT(DAY(TODAY())),TEXT(DAY(TODAY())))}';
taskObj.ActivityDate = year.concat("-",month,"-",day);
taskObj.Completion_Date__c = year.concat("-",month,"-",day);


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

if (result[0].success=='false') { 
alert(result[0].errors.message); 
} else { 
var newURL = '/' + result[0].id + '/e'; 
window.top.location = newURL; 
}

 
Context: We have a custom object called Projects, which sinks to a system called Harvest. The projects have a child object called Time Entries, which stores start time, end time, and duration. Every night, Harvest syncs to these objects and adds new time entires. Every time entry lives on a parent Project. There are two Projects per client account, one for Client Relations, and the other for Development.

What I want: I want a roll up summary field on the Account object that sums the total Dev and CR time from the sum of time entries in the past twelve months. Unfortunately, it is my understanding that you cannot use the Today() formula on rollup summary objects.

I'm new to SFDC development but have been an admin for four years. My theoretical appraoch would be to have a trigger that runs every night on the Time Entries object and says is the date of the entry in the last 12 months, if so, check yes, if not, check no. Because the TODAY() formula will be running in the back end, I can then use that check box to create rollup summary fields and don't need to over complicate it. 

Problem: I've never written code. 

Any help here would be really really appreciated. We have a full sandbox, but no development resources currently, so I'm just trying to get started. 
Context: Based on the way our sales reps need to view activity data (with respect to how our parent and child accounts are related), we had to create custom buttons for logging calls. After developing these buttons, they are exactly what our sales reps need and actually have been improved to be a substantial time saver, even with the final lingering error I can't seem to code around. 

Below is the code I have for a Custom Call button. We have multiple buttons for different activity types, but they all follow this pattern. The issue: When our AEs click save, it takes them to their home page as opposed to taking them back to the contact record that they logged the call on. Most of them use multiple tabs, and as stated these custom buttons save us time and map our activity in the unique way we need it to, but it would be awesome to figure out the issues in the last part of my code (In bold) to get them back to the contact or account that they logged the activity at when they click save. Any help is GREATLY appreciated!

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

var taskObj = new sforce.SObject("Task"); 
taskObj.RECORDTYPEID = '012a0000001WDSk'; 
taskObj.Type = 'Cold Call';
taskObj.WhoId = '{!NULLVALUE(Contact.Id,Lead.Id)}';
taskObj.WhatId = '{!NULLVALUE(Account.ParentId, Account.Id)}';
taskObj.Status = 'Completed';

var year = '{!TEXT(YEAR(TODAY()))}';
var month = '{!IF(LEN(TEXT(MONTH(TODAY())))==1,"0"&TEXT(MONTH(TODAY())),TEXT(MONTH(TODAY())))}';
var day = '{!IF(LEN(TEXT(DAY(TODAY())))==1,"0"&TEXT(DAY(TODAY())),TEXT(DAY(TODAY())))}';
taskObj.ActivityDate = year.concat("-",month,"-",day);
taskObj.Completion_Date__c = year.concat("-",month,"-",day);


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

if (result[0].success=='false') { 
alert(result[0].errors.message); 
} else { 
var newURL = '/' + result[0].id + '/e'; 
window.top.location = newURL; 
}

 
Context: We have a custom object called Projects, which sinks to a system called Harvest. The projects have a child object called Time Entries, which stores start time, end time, and duration. Every night, Harvest syncs to these objects and adds new time entires. Every time entry lives on a parent Project. There are two Projects per client account, one for Client Relations, and the other for Development.

What I want: I want a roll up summary field on the Account object that sums the total Dev and CR time from the sum of time entries in the past twelve months. Unfortunately, it is my understanding that you cannot use the Today() formula on rollup summary objects.

I'm new to SFDC development but have been an admin for four years. My theoretical appraoch would be to have a trigger that runs every night on the Time Entries object and says is the date of the entry in the last 12 months, if so, check yes, if not, check no. Because the TODAY() formula will be running in the back end, I can then use that check box to create rollup summary fields and don't need to over complicate it. 

Problem: I've never written code. 

Any help here would be really really appreciated. We have a full sandbox, but no development resources currently, so I'm just trying to get started.