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
Jos vd HaveJos vd Have 

Custom button with javascript - copy date value

Hi all,

I'm struggling with the dates in JS.
Below is my code but whatever I try I end up with an error saying "Invalid time value"
the problem is in the bold code line.
Thx in advance...
Jos

{!REQUIRESCRIPT("/soap/ajax/37.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/37.0/apex.js" )}
var Status = "{!Case.Status}";
var newRecords = [];
if (Status != "Gesloten")
{
var c = new sforce.SObject("Case");
c.RecordTypeID = "012b0000000YfFNAA0";
c.AccountId = '{!Case.AccountId}';
c.ContactId = '{!Case.ContactId}';
c.ParentId = '{!Case.Id}';
c.Complaint_Type__c = "Standaard klacht";
c.Subject = '{!Case.Subject}';
c.Status = "In behandeling";
c.Substatus__c = "Beoordelen klacht";
c.Origin = '{!Case.Origin}';
c.Contract__c = '{!Case.Contract__c}';
c.Business_Unit__c = '{!Case.Business_Unit__c}';
c.Department__c = '{!Case.Department__c}';
c.Preferred_Contact_Method__c = '{!Case.Preferred_Contact_Method__c}';
c.Initial_opened_date__c = new Date('{!Case.CreatedDate}').toISOString();
newRecords.push(c);
result = sforce.connection.create(newRecords);
alert ('Klacht case is aangemaakt.');}
else
{
alert ('Case mag niet gesloten zijn voor deze actie.');
}
Laraib_JafriLaraib_Jafri
Is Initial_opened_date__c a date/time field or Text field?
 
Jos vd HaveJos vd Have
Hi, it is a date/time field