Skip to main content

Date field using custom field renderer snippet has stopped working. It used to work fine before. Now it has stopped working and gives an error message saying required field value is not populated when trying to save the record.

Below is the snippet:


var field = arguments[0], value = arguments[1]; //set Contract expiry date to 365 days from today var c=new Date(); c.setDate(c.getDate()+365); var cYear=c.getFullYear(); var cMonth=c.getMonth()+1; var cDay=c.getDate(); value = cYear+"-"+cMonth+"-"+cDay; skuid.ui.fieldRenderers.DATE.edit( field, value );<br>

Try setting a console log on the “Value” output.  Then compare that with model data for a date returned from salesforce. It looks like you are trying to parse your own salesforce date from the javascript date provided by your +365 calculation.  You should look into some of Skuid Time APIs that perform this parsing function more reliably.  http://help.skuidify.com/m/11720/l/129505-skuid-time 


Jayesh I am surprised that this was ever “working”, because the snippet above never actually updates the value of the Date field in the Skuid Model — in the UI the value might have shown as the Date you were creating, but you need to use model.updateRow() (see the docs on the Model object) to actually change the value of the field in the Model.


What I am trying to do is default today’s date + 365 as the expiration date of a contract. But the user should be able to override it. So i built the above custom field render snippet. This defaults the date correctly.

But if I understand correctly I need to use an updateRow to actually save it on the model even before the user clicks the save button?


Yes that is correct, you need to use updateRow to save it to the Model.


That resolved the problem. Thanks.


Reply