• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

edit cell based on year

New Here ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

Good morning ladies and gentlemen!

I recently created an inspection report which contains various 'Year service is due' fields. When I enter a past or present year, I'd like the cell background to turn red. If I enter a future year, I'd like the cell background to stay white. I don't know how to write code but I assume I can create a java script in this case. Can someone please assist?

Thank you in advance!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

175

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

Are you entering a full date (eg. "22/06/2018"), or just the year (eg. "2018")?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

Also, what should happen if the field is empty?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

Remains white.

[Moderator Note: Personal information removed. Please turn off email signatures when replying to forum posts.]

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

You can use this code as the field's custom validation script:

if (event.value!="" && new Date().getFullYear()>=Number(event.value)) {

    event.target.fillColor = color.red;

} else event.target.fillColor = color.white;

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

Thank you very much. I'm sure you're right but with my limited code experience, I think I may be inputting it incorrectly. I just copy and past your script in the 'Create and Edit JavaScript' window correct? I did this and nothing changes. Do you know what I may be doing wrong? Do I need to delete any spaces? Does the file always know the current year when I open it on my ipad or computer? Thank you again!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

Where exactly did you place the code?

It will work on a computer (if you use Adobe software). It might not work on a mobile device.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

I’m using a windows desktop to create the fill-able pdf in Adobe Pro DC. Then I copy said pdf to my Dropbox and upload it in Adobe Pro on my iPad. I fill out the report while in the field via said iPad.

I opened the pdf on my desktop, clicked Tools > Prepare. Then clicked on a cell in the top row, Properties > Validate > Check the ‘Custom Java Script’ radio button > Edit > Paste (pasted your script). Then, I hit Close > Preview > entered 2017, and the bg stayed white. When I click on the cell to change it again, it flashes red but returns to white.

[Moderator Note: Personal information removed. Please turn off email signatures when replying to forum posts.]

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

Also, when I input a year less than 2019, the cell will remain light blue (fillable color). When I edit the year, it stays red background until the year is 2019 or after, but regardless of the year, the background remains light blue when not being edited.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

You need to disable the fields highlighting option.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

LATEST

try67...thank you so much - that was the problem! Thank you for the quick response and patience. Have a great day!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

Just the year.

[Moderator Note: Personal information removed. Please turn off email signatures when replying to forum posts.]

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines