Custom clone page with a required date field cleared out

  • 1
  • Question
  • Updated 1 year ago
  • Answered
Trying my best to figure this one out, but hitting major roadblocks. Could be my own ignorance, lack of caffeine, and poor search terms...

We have a custom object where a user fills out a form requesting work to be done by required due date. I built a custom clone page (following the tutorial) for users to request new work with all the same information--EXCEPT, we need them to fill out a new due date.

I followed the tutorial and the field is set to edit and is required, but how do I make it clear out like it would be when first filling the form out? It is a date field and I want it to be blank to force the user to enter a new date. I would be okay (not great, but okay) with it being a pre-set value, like tomorrow. But, clearing out the data and forcing a new date to be picked is the ideal situation I am looking for.

Am I missing some easy step? (Please tell me I am.)
Photo of Sarah Hughes

Sarah Hughes

  • 454 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Sarah,

Any fields included in your model on the 'clone page' will be copied from the source record.  This is working as designed.

I think your best bet is to add a small Javascript snippet that will run on page load to clear the date field that you want the user to change.

Is this something that you can take on?

Thanks,

Bill
Photo of Sarah Hughes

Sarah Hughes

  • 454 Points 250 badge 2x thumb
Bill,

Thanks for the response. Yes, all my other clone features are working as designed. We just don't trust our users to change the date. The snippet path seemed like one that would work, but wasn't sure if there was another approach. I am NOT hip to writing my own javascript, just mangling existing snippets.

I found this post about clearing a datetime field, but there wasn't anything I saw that I could appropriate.

I will keep searching and see if I can cobble something together. At least I know this is the right direction.

--Sarah
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Sarah,

This should get you what you want.  When you add the JS snippet, make sure it is an 'Inline' snippet.  This will make it run on page load.

(function(skuid){
	var $ = skuid.$;
$(document.body).one('pageload',function(){
var myModel = skuid.model.getModel('Task');
var row = myModel.getFirstRow();
        myModel.updateRow(row, {ActivityDate:''});
});
})(skuid);

Thanks,

Bill
Photo of Sarah Hughes

Sarah Hughes

  • 454 Points 250 badge 2x thumb
Brilliant, Bill. This worked perfectly. Thanks!
Photo of Jason C

Jason C

  • 682 Points 500 badge 2x thumb
I'm trying to use the inline snippet above but it is not clearing out my field on my clone page. Is there something missing in the JS?


(function(skuid){
    var $ = skuid.$;
        $(document.body).one('pageload',function(){
        var myModel = skuid.model.getModel('MyModelName');
        var row = myModel.getFirstRow();
        myModel.updateRow(row, {MyFieldName:''});
        });
})(skuid);
(Edited)