Copy link to clipboard
Copied
Good morning,
I thought i nailed this one but it's doing something strange. My script is wrong but i'm learning as I go...
I added a script that auto-populates today's date and adds + 15 days to the date. When I Preview the field, it works find. However when I tab over to another field and add a value (doesn't matter what the other fields are), the initial date field keeps adding more days. Example, if the next two fields were simple check boxes (not tied to the date field in any way) and I were to check the boxes back and forth, the date field keeps jumping to a higher date.
var myDate = util.scand("mm/dd/yyyy", this.getField("GLOBAL__POSTING_DATE_15").valueAsString) ;
myDate.setDate(myDate.getDate() + 15);
event.value = util.printd("mm/dd/yyyy", myDate)
Is there a way to keep the date displayed and not get updated unless the user manually changes the date and only then does it add 15 days to that new date?
Thanks,
Edgar Arreguin
Copy link to clipboard
Copied
Where did you place this code?
Copy link to clipboard
Copied
Custom calculation script in the Calculate tab.
Copy link to clipboard
Copied
Maybe a hidden field would prevent this?
Copy link to clipboard
Copied
In what field did you add this script?
Is there any script that is updating the "GLOBAL__POSTING_DATE_15"?
Do you have a field with today's date?
If so, I would have places the code in the "on blur" action and use the value of today's date field for the base date for adjustment. That way the "GLOBAL__POSTING_DATE_15" would only be updated as the today's date field is changed.
Copy link to clipboard
Copied
I have a single field where I inserted the script. Field name titled "GLOBAL__POSTING_DATE_15". From the script, the date auto populates mm/dd/yyy and adds +15 days.
Bare with me as i'm still learning. I'm not familiar with "on blur"action but assuming you meant adding it to the actions tab as opposed to the Calculate tab, I can give that a shot.
-Ed
Copy link to clipboard
Copied
You can't do it like that. You've created a circular calculation. Each time you take the value of the field and add 15 days to it... You need to use some other event to trigger the calculation, or use the current date in your script, instead of the value that's already in the field.
Copy link to clipboard
Copied
I jumped the gun. I was seeing results based on a value (date) already populated. When i clear text, nothing happens,.
In the actions tab, after selecting blur trigger, what action do i select? JavaScript not working.
Copy link to clipboard
Copied
Thanks everyone. I was able to make it work using George's suggestion. See link..
Only difference is that the original date (auto imported by our UI interface) is hidden.
Defaulted the value of 15 to the second field and made it hidden as well.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now