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

Custom format of Date and Time from Date form field

New Here ,
Jan 12, 2018 Jan 12, 2018

I am trying to change make a custom date and time to function as an "invoice number" so when the user chooses the date from the form Date field it populates as such: ddmmyy-hhmm. When I try to use the Custom format and type in ddmmyy-hhmm I get an error that reads

"Invalid date/time: please ensure that the date/time exists. Field [ Date of invoice creation ] should match format ddmmyy-hMM"

What am I doing wrong?try67​

TOPICS
PDF forms
16.9K
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
1 ACCEPTED SOLUTION
Community Expert ,
Jan 12, 2018 Jan 12, 2018

You're stuck with these formats, I fear.

On Jan 13, 2018 12:28 AM, "SanitySolutionsDEN" <forums_noreply@adobe.com>

View solution in original post

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 ,
Jan 12, 2018 Jan 12, 2018

You'll need to write your own Format script to be able to handle this pattern.

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 ,
Jan 12, 2018 Jan 12, 2018

Do you know of any resources I could reference to do so?

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 ,
Jan 12, 2018 Jan 12, 2018

It's not a simple task... Let's take a step back, though. What do you want the user to enter, and what should the result be?

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 ,
Jan 12, 2018 Jan 12, 2018

Using the Date Field from the form builder they select the day and the time stamp is added. Currently the same info can be displayed using one of the defaults like: m/d/yyyy HH:MM. I just want that information to look like mmddyy - HHMM.

I can also select "custom" and only have the date show up as mmddyyyy, but I would really like to include the time.

Same info, just reformatted.

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 ,
Jan 12, 2018 Jan 12, 2018

If they only select a date, how will it know what time to enter?

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 ,
Jan 12, 2018 Jan 12, 2018

The time stamp is automatic. When building the form and using the default options, the time stamp is automatically generated.

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 ,
Jan 12, 2018 Jan 12, 2018

Screen Shot 2018-01-12 at 3.30.11 PM.png

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 ,
Jan 12, 2018 Jan 12, 2018

Then you don't need a Date format setting. You can apply any date format you want in the script that assigns the value to this field.

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 ,
Jan 12, 2018 Jan 12, 2018

And therein lies another problem. Where do I go to change that script?

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 ,
Jan 12, 2018 Jan 12, 2018

I'm assuming you created it to populate the field... So you should know

where it's located.

On 12 January 2018 at 23:46, SanitySolutionsDEN <forums_noreply@adobe.com>

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 ,
Jan 12, 2018 Jan 12, 2018

Ok I see what you're asking. Yes I created the date field but when i try to us a custom date format AND a custom time format I get the error message of:

Screen Shot 2018-01-12 at 3.57.55 PM.png

To summarize: I can totally use custom for the date, but when I try to integrate the time stamp in any way I get the error message. Trying to figure out how to fix that.

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 ,
Jan 12, 2018 Jan 12, 2018

I'm not following how you're using this field... Does it take input from a user, or does it have an automatic value, applied using a script?

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 ,
Jan 12, 2018 Jan 12, 2018

Input from the user by way of a drop down arrow (right side of the field):

Screen Shot 2018-01-12 at 4.16.09 PM.png

Screen Shot 2018-01-12 at 4.16.17 PM.png

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 ,
Jan 12, 2018 Jan 12, 2018

OK, that's the built-in Date picker, but you won't be able to use it if you create your own custom Format script.

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 ,
Jan 12, 2018 Jan 12, 2018

Right right. So I guess to adjust my question: How do I customize the format of the information in the date picker? OR am I stuck just using one of the standard formats that Adobe uses to display date and time?

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 ,
Jan 12, 2018 Jan 12, 2018

You're stuck with these formats, I fear.

On Jan 13, 2018 12:28 AM, "SanitySolutionsDEN" <forums_noreply@adobe.com>

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 ,
Jan 15, 2018 Jan 15, 2018

try67 thank you for your help! I've come up with a possible work around. I have a script that fills a text field with the date in which its opened for mmddyy. I would like to add the same thing for time in a different field.

the script:

this.addScript("init", "this.getField(\"timePO\").value = new Date();");

Ideally it would have the format hhMM. Do you know if this is possible? or do I always need to use the ":"?

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 ,
Jan 15, 2018 Jan 15, 2018

You can use the printd method, like this:

util.printd("hhMM", new Date());

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 ,
Jan 15, 2018 Jan 15, 2018

what would happen if I changed the script to:

this.addScript("init", "this.getField(\"timePO\").value = new Time();");

End goal:

1. Date auto populates when document is opened (checked, that works)

2. Time auto populates in a DIFFERENT field "timePO" to hhMM when the document is opened.

I figured that the above script could be utilized twice. No?

Screen Shot 2018-01-15 at 9.21.03 AM.png

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 ,
Jan 15, 2018 Jan 15, 2018

No, that won't work. You can't just invent things and hope for them to work... Use the code I provided above.

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 ,
Jan 15, 2018 Jan 15, 2018

Right, sorry, dumb question. This will be my last one I promise, thanks again for being so patient.

Update: I talked with my team and the box I was trying to have populate the time (thank you for the script btw) is now asking for the form to have this function:

1. Press a button and just have the field auto generate a random 4 digit number. Doesn't have to be sequential, but the user needs to click the button (so mouse up) to generate the number.

My boss (Jason) appreciates your help, I (Nora) appreciate it even more.

You are the absolute best. Thank you.

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 ,
Jan 15, 2018 Jan 15, 2018

This code will return a random 4-digit number each time you call it:

util.printf("%04d", Math.floor((Math.random() * 10000) + 1));

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 ,
Jan 15, 2018 Jan 15, 2018

Do I add that to my Generate PO number button on the Mouse up action/run Java script? Or at the document level? The screenshot is the button "Generate PO" and i'm trying to get the generated numbers to show up in the acctingPO number field when you execute the mouse up action.

Screen Shot 2018-01-15 at 11.02.14 AM.png

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 ,
Jan 15, 2018 Jan 15, 2018

Either way. If you want it to be executed when the button is clicked then use it in its Mouse Up action. If you want it to update each time the file is opened use a doc-level script.

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