How to replace a date in a date list using SSJS in XPages - date

I have a date list field and need to replace a value in the list with another value
so I have this list of type "date list"
The user enter a new value in a date field in the webpage. This new value should be added to in this case the second item in the date list, but it in the real case it should be able to be added to any position in the list
This is the inputfield where user enter a new date
<xp:inputText id="inputText1">
<xp:this.converter>
<xp:convertDateTime pattern="yyyy-MM-dd"></xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
This is the code I use in my button that should replace the date
doc is a data source on the XPage
var v:java.util.Vector = doc.getDocument().getItemValueDateTimeArray("TDate")
v.setElementAt(getComponent("inputText1").getValue(),1)
doc.replaceItemValue("TDate",v)
doc.save()
Not sure what I am doing wrong here, but I seem to have two problems, first the field only seem to contain one element after I save, and secondly the date that is added contain both date and time, and not only the date
This is the result after running the code
Running the same kind of code using a multivalue "text" field works fine.
how can I modify my code so that my replace operation in the date list works

to set a date value without the time part
get a DateTime object and call the function setAnyTime() on the NDT object and replace the item
to set a specific time value in a multivalue datetime field
get the field you will get a vector with all the datetime object.
Get the specific timedate in the vector change it and set it back to the vector. and after that replace the item

Related

I have a PDF form where I want to be able to display the date the form was saved

I have a form that I use daily as a transmittal for when I send items out. I would like once I save the form, the date is displayed. I know how to use the current date format, but this will change the next time I open the saved document, and I want to be able to see the last time it was saved, and not the current date.
This works only with Acrobat-JavaScript enabled viewers:
Create a text field where you want to have the last save date
Add the following script in the WillSave event (in Acrobat XI, it is in the JavaScript Tools --> Document Actions --> Will Save dialog):
var now = new Date ;
this.getField("mySaveDate").value = util.printd("yyyy/mmm/dd HH:MM", now) ;
and that should do it.

Set initial value of DateInputElement

I need to set intial value for DateInputElement. The .dart file has a variable dob with initial value:
String dob='01/01/2013'
and html has
<input id='mydob' type='date' name='dob' required='true' bind-value='dob'/>
dob is not shown when UI is displayed. The control shows mm/dd/yyyy.
If I select a date on UI, the date value is populated in dob variable.
Although bind-value sets two way binding, still tried setting the value to dob as follows without success:
<input id='mydob' type='date' name='dob' required='true' value={{dob}} bind- value='dob'/>
Also tried the following in life cycle events but did not work:
DateInputElement e = query('#mydob');
e.value=dob;
The format you are trying to put into the field is wrong. It's supposed to be 2013-01-01 (YYYY-MM-DD) according to the RFC. This is completely independent from dart or any other binding.
I would add that it is nessary to have the 0. So it is 2013-01-01 and not 2013-1-1

Return different datatypes crystal formula

I have a requirement where depending on the parameter selected the table field should be displayed as text or date. For eg, if the user selects a true, the OriginDate field which is a datetime type should be displayed as a date in the report else should be displayed as a text. I tried creating a formula an doing something like below, and then placing the formula in the details section of the report but it doesnt work due to different datatypes returned.
if {?Mailmerge}=true then
ToText({Travel.OriginDatetime}, "M/d/yy")
else
{Travel.OriginDatetime}
Is there a way I can accompalish the above requirement so that I do not end up creating 2 reports one with field displayed as text and other as date?
Try creating a formula that returns your field as a string totext({Travel.OriginDateTime},"M/d/yy") and overlay it with the original field {Travel.OriginDateTime} and conditionally suppress them based on the value of {?MailMerge} such that only one shows in any one instance of the report.
If I'm following you, you want to only show M/d/yy when ?MailMerge is true, otherwise yuo want to show the full date?
You can't show different datatypes in the same formula, so just convert them both parts of the conditional statement into strings:
if {?Mailmerge}=true then
ToText({Travel.OriginDatetime}, "M/d/yy") // 8/30/12
else
ToText({Travel.OriginDatetime}, "M/d/yy hh:mm:ss") // 8/30/12 02:06:00
I don't know what exactly your dates look like in the database, but you can use the above as a guideline into formatting your date based on the ?MailMerge parameter.

VBA to verify if text exists in a textbox, then check if date is in the correct format

I have an excel form that I created in combination with VBA. In the form I have a textbox in which the user is to type in a date.
I have created this VBA clause to ensure the user types in a date that supports the format xx/xx/xxxx.
If Not IsDate(textboxDate1.Text) Then
Call MsgBox("Please select a correct Date format", vbOKOnly)
Exit Sub
End If
However, with this VBA code, the user is required to enter a date, whether the user needs to or not. So when I have a 4 other textboxes to input a date in my form, and the user only needs to enter in 1 date, and not 5, I have the problem where the user is required to put in a date for the other four textboxs in order submit the form.
So my question:
What VBA code is available to first determine whether text exists in the textbox, and then second to determine whether the date is in the correct format or not.
I was trying something similar to this:
If textboxDate1.ListIndex = -1 Then
but I couldn't get it to work with the IsDate clause.
Many thanks in advance.
If (Len(Trim(textboxDate1.Text)) <> 0) And Not IsDate(textboxDate1.Text) Then
Call MsgBox("Please select a correct Date format", vbOKOnly)
Exit Sub
End If

SmartGwt DateItem useTextField=true - how to make text entry field UNeditable

Since I can't figure out how to solve my problem presented here I'm thinking for the moment at a temporary solution.
I have a smartgwt DateItem widget:
DateItem date = new DateItem("Adate");
date.setWidth(120);
date.setWrapTitle(false);
date.setAttribute("useTextField", true);
date.setAttribute("inputFormat", "yyyy/MM/dd");
date.setAttribute("displayFormat", "toJapanShortDate");
Because the attribute useTextField is set to true we can see the text entry field. How can I make this text entry field to be uneditable.
Actually I want to have only the possibility to choose the date from calendar and not to change it manually.
Resolved - the issue exposed above - thanks to #RAS user.
TextItem textItem = new TextItem();
textItem.setAttribute("readOnly", true);
date.setAttribute("textFieldProperties", textItem);
Related link
But I have now another issue (resolved - see here):
The date chooser won't show the date on the text field but Today's date.
For example, enter 30/05/2009 on the text field, go to another field, then come back on click on the date chooser and the selected day will be Today's date instead on June 30th, 2009. Which is the reason for this? Can this be solved?
Also let's say I let to the user to opportunity to manually modify the date - can I put some **validators on it?** (still need an ideea on this)
Thank you.
date.setEnforceDate(true);
http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/form/fields/DateItem.html#setEnforceDate%28java.lang.Boolean%29
You have a lot of different validators. Depending on the context it must be possible to validate cardinality, relation to other data items, datatype(not only date time values) and relations to other external records.