Copy link to clipboard
Copied
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​
Copy link to clipboard
Copied
You're stuck with these formats, I fear.
On Jan 13, 2018 12:28 AM, "SanitySolutionsDEN" <forums_noreply@adobe.com>
Copy link to clipboard
Copied
You'll need to write your own Format script to be able to handle this pattern.
Copy link to clipboard
Copied
Do you know of any resources I could reference to do so?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
If they only select a date, how will it know what time to enter?
Copy link to clipboard
Copied
The time stamp is automatic. When building the form and using the default options, the time stamp is automatically generated.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
And therein lies another problem. Where do I go to change that script?
Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
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:
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Input from the user by way of a drop down arrow (right side of the field):
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
You're stuck with these formats, I fear.
On Jan 13, 2018 12:28 AM, "SanitySolutionsDEN" <forums_noreply@adobe.com>
Copy link to clipboard
Copied
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 ":"?
Copy link to clipboard
Copied
You can use the printd method, like this:
util.printd("hhMM", new Date());
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
No, that won't work. You can't just invent things and hope for them to work... Use the code I provided above.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
This code will return a random 4-digit number each time you call it:
util.printf("%04d", Math.floor((Math.random() * 10000) + 1));
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now