How to add 1 hour to a DateTime field in Multiple Actions?

  • 2
  • Question
  • Updated 6 years ago
  • Answered
  • (Edited)
I have a DateTime field that I would like to add 1 hour to in a multiple action.

I have set the multiple action to update the destination field (which is also a DateTime field and both are selected in the Model) by setting the option to a specific date and then I used {{$Model.Modelname.data.0.field}} as the value but I am not sure of the syntax or format to add 1 hour to the value?
Photo of Gregg Baxter

Gregg Baxter

  • 3,202 Points 3k badge 2x thumb
  • uneducated

Posted 6 years ago

  • 2
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,686 Points 5k badge 2x thumb
Your probably going to want to check out this doc : http://help.skuidify.com/m/11720/l/129505-skuid-time but something like this might work...

var params = arguments[0],   $ = skuid.$;
var model = skuid.$M('YOURMODEL');
var row = model.getFirstRow();
var dateVar = row.Your_Date_Field__c;
//convert from Salesforce date to Javascript date
var jsDate = skuid.time.parseSFDate(dateVar);
//add an hour 
jsDate.setHours(jsDate.getHours() + 1);
//convert from Javascript date back to Salesforce date
var hourAdded = skuid.time.getSFDate(jsDate);
model.updateRow(row,{Your_Date_Field__c : hourAdded});
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,686 Points 5k badge 2x thumb
If you're using a datetime field change "parseSFDate" and "getSFDate" to "parseSFDateTime" and "getSFDateTime".