Running removal of table rows

Options

Hello,

I have a use case where I need to be able to remove data once a specific (variable) date is set, but I'm not sure how to do it.

Use Case: We send a report of associates up for a service award on a quarterly basis. The workflow runs through an eligibility check, and adds eligible associates to a table. Every month, we run a report of associates who have left the company and send it through a workflow which removes any associates from the eligibility list.

The two processes overlap- eligibility report is sent about a month before the next quarter starts- and use the same main eligibility table. The only date I have is the original hire date, which is in the 2001-09-24 format. After that date in the current year, they don't need to be on the list.

How can I remove associates whose eligibility date has passed? Thank you!

Best Answer

  • Chuck_146211
    Chuck_146211 Posts: 36 admin
    Answer ✓
    Options

    Hi @Anna_272419,

    I’d suggest the following steps to help get you started here -

    Get the current date when the run takes place

    Adjust the date to 1 year ago

    Change the date value obtained above into a string (important for later for the field formula)

    By getting the current date-time, adjusting it to one year ago, and setting these values as text you will be able to reference the adjusted date field in the field formula and compare it to the hire dates in your table when it comes time to remove rows.

    Field Formula code:

    var dateText = new Date(fields[‘text-value-of-date-year-ago’]);
    var num = dateText.getTime();
    result = num;
    

    The .getTime() method will turn your date into a number that you can use for a comparison in your workflow. The output of of the method is the number of milliseconds passed since 1/1/1970 - so the .getTime() of today’s date vs. the .getTime() of 1 year ago will always be greater.

    Hope this helps point you in the right direction to finding a solution that works for your use case. Let me know if you have any questions on the above and I will be happy to assist.