function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Fabio MilheiroFabio Milheiro 

Add custom button to list related

We have a Project and Time Entry custom objects. A project can have zero or more time entries.

 

I am supposed to create a button in the project time entries related table a Start/Stop button (right next to the New button).

 

I have created a custom button (Display Type = List Button) in Time Entry custom object to execute the following JavaScript onclick event:

 

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

var url = parent.location.href;
var records = {!GETRECORDIDS( $ObjectType.Time__c )};
var updateRecords = [];

function getCurrentSalesForceTime(){
    var currentDateTime = sforce.connection.getServerTimestamp();
    currentDateTime = setStringToDateTime(currentDateTime.timestamp);
 
    return currentDateTime;
}

function create() {
  var timeEntryName = prompt("Please enter for the time entry:", "New time entry");
  var newTimeEntry = new sforce.SObject("Time__c");
  newTimeEntry.Project__c = "{!Product2.Id}";
  newTimeEntry.Name = timeEntryName;
  newTimeEntry.Start = getCurrentSalesForceTime();
}

if (records.length == 0) {
  create();
}
else {
  var lastTimeEntry = records[records.length-1];
  
  if (lastTimeEntry.Stop < lastTimeEntry.Start) {
    lastTimeEntry.Stop = getCurrentSalesForceTime();
    sforce.connection.update(lastTimeEntry);
  }
  else {
    create();
  }
}

window.location.reload();

 

Then, I have edited the Project custom object page layout to add the button to the Time Entries related list.

 

The button now appears next to the New button in related table Time Entries in the Project details page.

 

But when I click it I get the following message:

 

"Unable to find a form for this button"

 

What am I doing wrong? Any ideas about what I can do to narrow the problem?

 

Thanks

Ankit AroraAnkit Arora

In which edition you are working in??

 

Let me know if it helps you anyhow:

 

http://boards.developerforce.com/t5/General-Development/Custom-Button-giving-error/td-p/76759

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Fabio MilheiroFabio Milheiro

Thanks for your response Ankit_Arora!

 

Unfortunately, that doesn't help because the Display Type of the button and is applied in the time entries related list in the project page.

 

Any other hint so I can narrow this problem please?