You are viewing limited content. For full access, please sign in.

Question

Question

Format Date token in Laserfiche Forms

asked on June 9, 2014 Show version history

Is there a way to have the customer enter a standard date  mm/dd/YYYY and parse out the year using the workflow engine that is built into Laserfiche forms?

 

I would like to return YYYY so I can use this value again.

 

I can do this in workflow but I would like to simplify this for the end user.

 

I need just the year to create a folder automatically when the completed forms are being saved to Laserfiche.

 

Thanks,

 

Rod 

0 0

Answers

APPROVED ANSWER
replied on June 10, 2014

Yeah, just slightly modify the code so that tries to use the existing value, if present.

 

$(document).ready(function () {
    $('.filledField input').val($('.date input').val().slice(-4));
    $('.date input').blur(function () {
        $('.filledField input').val($(this).val().slice(-4));
    });
});

 

0 0
SELECTED ANSWER
replied on June 10, 2014

That worked great.  Thanks for the help

0 0

Replies

replied on June 9, 2014

Yes, that's possible. Just create a token and assign that date to it. Then when you create the folder, use the Apply Formatting option to change it into a year.

 

0 0
replied on June 9, 2014

Hey Rod,

 

If possible, I'd suggest using Workflow so you can leverage the token formatting, as Devin stated in his reply.  

 

If it's absolutely necessary to have this done in Forms, it'll be a much more difficult process, but hypothetically, it's possible.  The process would include writing some Javascript to parse the date field for you, identify the year, and copy the year into a hidden Forms field.  Then you can use the hidden field's variable in your "Save to Repository" service task to include the year in the folder path.

 

As you can see, Workflow would be a much better option, but it'll be possible both ways.

0 0
replied on June 10, 2014

It's pretty straightforward to keep this all in Forms. As Rob suggested, it requires a small amount of JavaScript. The following code assumes you have the date CSS class added to your date field, and the filledField class added to the field where you'll store the year (you can hide this field, if you like).

$(document).ready(function() {
  $('.date input').blur(function() {
    $('.filledField input').val($(this).val().slice(-4));
  });
});

Then use a save to repository service task to save the submission to the appropriate folder in the repository.

0 0
replied on June 10, 2014

Eric,

 

I have implemented the Java Script.

 

I find if the date field is not changed. Example the default is today's date the script does not run.

 

Is there another way to force the script to run even if the Date field shows the current Date. Or do I need the user to change this field?

 

 

0 0
APPROVED ANSWER
replied on June 10, 2014

Yeah, just slightly modify the code so that tries to use the existing value, if present.

 

$(document).ready(function () {
    $('.filledField input').val($('.date input').val().slice(-4));
    $('.date input').blur(function () {
        $('.filledField input').val($(this).val().slice(-4));
    });
});

 

0 0
SELECTED ANSWER
replied on June 10, 2014

That worked great.  Thanks for the help

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.