Setting Date Time Sensitivity from 5 minutes to 1 minute with a custom field renderer

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I need to have time entered in 1 minute increments. I stumbled across a post about this issue and the poster supplied this code. However, I can't get it to work as a field render or inline. Has anyone gotten this to work. Is it something that I am doing wrong? Any help would be appreciated.

______________________________________________________________________________

var field = arguments[0], value = arguments[1];

console.log(value);
if(field.mode == 'edit') {

skuid.ui.fieldRenderers.DATETIME.edit(field, value);
var html = '000102030405060708091011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859';

jQuery(field.element.find(".nx-dt-timewrapper").find("select")[1]).html(html);

var jsDate = skuid.time.parseSFDateTime(value);
var selectedOpt = jQuery(jQuery(field.element.find(".nx-dt-timewrapper").find("select"))[1]).find("option").filter(function(index, item) {return jQuery(item).attr("value") == jsDate.getMinutes()});

selectedOpt.attr("selected", "");

}
else {

skuid.ui.fieldRenderers.DATETIME.read(field, value);
}
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
AS an added note, when I activate this code it stops the entire page from loading. Thanks
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Looks like you haven't copied the code exactly as was shown in this post:  https://community.skuidify.com/skuid/topics/date-time-field-displaying-minutes-in-5-min-increments-n...

I also get a fatal error using that code when a blank date time field is found.  (Like on a new record).  An easy workaround would be to use a model condition to set the date time field to "TODAY"  which pulls in the current time as well as the current date.   Otherwize you will have to add some code to handle the scenario where "value" is blank. 
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Rob, you are awesome as always. I had the right code, but it didn't paste correctly into my post. I'm guessing it is because I didn't have word wrap on so it cut of a lot of the code. Anyway, the problem was that I was testing it on a new record that didn't have the date populated. I have been using two versions of my page "Detail" and "Edit". I'll just create a "New" version and have it populate with the current date and time using the condition as you suggested. It works great as long as the field is populated. Thanks!
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
I'm glad you were able to get this working! 
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
In the next major release of Skuid, you will be able to configure the Minute picker's sensitivity / increment declaratively through the Page Composer, no JS required. The options for increment sensitivity will be 1, 5, 10, 15, 20, 30.