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

edit cell based on year

New Here ,
Jun 22, 2018 Jun 22, 2018

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
376
Translate
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

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

Translate
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

Also, what should happen if the field is empty?

Translate
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

Remains white.

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

Translate
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

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;

Translate
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

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!

Translate
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

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.

Translate
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

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.]

Translate
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

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.

Translate
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

You need to disable the fields highlighting option.

Translate
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
LATEST

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

Translate
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

Just the year.

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

Translate
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