Hi Matt/Pavel, What date format does the CreateRecord Api accept? I already formatted the date to hae the format yyyy-mm-dd but I still cannot get the correct value to save. Here's my debug log and I keep on getting null values for the date. 001 var rbv_api = new Packages.com.rb.core.services.api.ServerSideAPI(110369479, 123689058); 002 003 var iCount = 0; 004 var sDate = new Date('Sat Feb 16 2013'); 005 var sYear = sDate.getFullYear(); 006 var sMonth = sDate.getMonth()+1; 007 var sDay = sDate.getDate(); 008 009 var sqlDate = rbv_api.formatDate(sDate, "yyyy-mm-dd"); 010 rbv_api.println(sqlDate); 011 var dateString = sYear+'-0'+sMonth+'-'+sDay; 012 013 var sQuery = 'Select Id from bill_record where bill_date = '+sqlDate+' and R125560506 = 121844125 and R125563673 = 113922731'; 014 iCount = rbv_api.selectNumber(sQuery); 015 016 if(iCount == 0){ 017 var br1 = new Array(); 018 019 020 br1["bill_date"] = new Date(dateString); 021 br1["R125560506"] = 121844125; 022
There is a small problem with printArr() API, will be fixed in 4.07 release
But aside from the printarr, what date format does createrecord accept if i am creating a record with a date field? I tried merge tokens, but errors appeared. Then i tried formatting the date field, into different patterns (yyyy-mm-dd and yyyy-dd-mm) but the record is saving 1/1/1970 instead.
JavaScript Date instance should work just fine.
You may try using the standard javascript date instance
ex. >> br1['bill_date'] = new Date("{!date_token}");
which basing on your code is your sDate variable.
I believe
br1['bill_date'] = sDate;
should work as expected.
in your code:
new Date(dateString); <
try saving in another variable and printing if it is returning a valid date since you are trying to make an instance of a "dashed" formatted date. (not sure if js accepts this)
var tester = new Date(dateString);
rbv_api.println(tester);
This might give you some ideas on debugging your issue.
Hope this helps.