You need to sign in to do that
Don't have an account?

Time Stamping a record using javascript and an s-control
Hi All,
Question #1:
I have written the followin Javascript code, implemented in an Execut Javascript s-control.
The Idea is to time stamp a record.
However, the date assignment (Line 3 in the code) doesn't work. the field type is date (not date/time).
I've tried wrapping {!TODAY()} twith single quotes, double quotes, and without any quotes. each delivers a different error. but no results.
Question #2:
Is there a way to reload only that field (save the page refresh)?
Any help would be much appreciated.
Thanks
Message Edited by beener on 10-28-2008 09:52 AM
Question #1:
I have written the followin Javascript code, implemented in an Execut Javascript s-control.
The Idea is to time stamp a record.
However, the date assignment (Line 3 in the code) doesn't work. the field type is date (not date/time).
I've tried wrapping {!TODAY()} twith single quotes, double quotes, and without any quotes. each delivers a different error. but no results.
Code:
var temporal= new sforce.SObject("Contact"); temporal.id = '{!Contact.Id}'; temporal.Audited_date__c={!TODAY()};//***this line doesn't work***
temporal.Audited_by__c = "{!$User.Alias}" result = sforce.connection.update([temporal]); window.parent.location.href="{!URLFOR($Action.Contact.View,Contact.Id,null , true )}";
Question #2:
Is there a way to reload only that field (save the page refresh)?
Any help would be much appreciated.
Thanks
Message Edited by beener on 10-28-2008 09:52 AM
That works. one problem however: the date used is of the user's machine so, I just tried turning my date to 2010 and changing it. and it stamps it as 2010. so I'd like to use a system time variable.
I've tried
temporal.Audited_date__c= new Date({!TODAY()});
This gave me the 01/01/1970 time stamp.
Any idea why?
By the way, regarding the 2nd question, I found that it isn't such an issue, since custom buttons disappear as soon an inline edit is made. they thought of it....
Thanks again.