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
The_FoxThe_Fox 

Date Calculation with Sforce.Util

Hello,

I have a date A, and I have a new date B and I would like to calculate the Diff between the two dates (B- A) (the diff could possibly be negative) and apply the diff to another date C so that new C= C+ (B-A).
All dates are converted first in ISO format if it can help

Second point I want to update different sforce objects can I pass something like updateObjects (Objects X; Objects Y; Objects Z) or I need to make updateObjects(Objects X), updateObjects(Objects Y)...

Thanks for your help

Cheers
Federico LarsenFederico Larsen
Hellow Fox, if you make a Query or a Retrieve all date fields are returned as javascript Date Objects so you can use all the javascript buit-in DateTime functions and the javascript DateTime functions arround the internet.

if you hava a opportunity, for example, oppourtunity.get("CloseDate") will return a Date Object.

If you want to store a Date you can use var mydate = new Date(), etc, etc and finally myObject.set("myDateFieldname", mydate)

to get the servertime into a date object

var sts = sforceClient.GetServerTimestamp().timeStamp;

In order to update differents kind of objects, the AJAX Tookit Documentation says:

..."

Update

SaveResult[]/SoapFault Update(<Array> objects, <Function> callback, <Boolean> async)
    Performs an update operation operation
      Parameters:
        objects - An array of sobjects to update, must be of the same object type.
          callback - A pointer to a function to be called once the http request has returned.
            async - A flag to indicate that the call should be made asynchronously or not. A value of true will cause the method to return immediately and once a response is recieved, the callback function will be invoked and passed the results of the call.
            "...