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

Question

Question

How to auto fill a Date field within a Table or Collection using the Date from a standalone Date field

asked on April 14

I am using Forms 12 with Classic Designer.

I would like to have the Date Column in a row of a table or collection auto fill with the date value set in a field OUTSIDE the table and collection resulting in each new row defaulting to the value in the Date field outside.

Date field outside collection / table:  Called Today with css Today as well

Table css: MyLaborTable

Date field inside table: LaborDate

I tried using the Default Value option and pointing it to Today.  Nothing fills.

I tried Javascript to work with a table.  This too does not fill in the date value in the table.  I tried using a collection and altering the javascript, but that too did not produce the intended results.  Suggestions?

// Store the selected date from the Today field
$(document).on('change', '.Today', function () {
    window.todaySelected = $(this).val();
});

// Watch for new rows added to the MyLaborTable
$(document).on('table-row-added', function (event) {
    var $newRow = $(event.target);

    // Make sure it's part of the right table
    if ($newRow.closest('.MyLaborTable').length > 0 && window.todaySelected) {
        var $laborDate = $newRow.find('.LaborDate');

        if ($laborDate.length > 0) {
            $laborDate.val(window.todaySelected);
            $laborDate.trigger('change'); // Trigger field rules if needed
        }
    }
});

0 0

Answer

SELECTED ANSWER
replied on April 14 Show version history

If you're wanting each row in your table to repeat a date set in a field outside your table, you can simply go under the Advanced tab under Field Options for your Date column within the table, and under calculation enter:

=Today (assuming "Today" is your variable name within your process)

Let me know if you have any questions and I can add some screenshots to walk you through it a bit more.

 

Editing to add: 

If you're also wanting the field outside of your table to auto fill with today's date, you can set that calculation as:

=TODAY()

1 0

Replies

replied on April 14

That was easy.  Thanks.

1 0
replied on April 14

No problem at all, happy to help!

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

Sign in to reply to this post.