- Mark as New
- Follow
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Alright, well first with dynamic PDFs you will have to forget all you know about using this.getField(), this does not work anymore, with some exceptions.
If you wish to retrieve the value of a field you must use the xPath or somExpression of a field to be able to access it.
While your text cursor is in the JavaScript editor, you can use the Ctrl+LeftClick command on any object in the design to automatically write the reference syntax for you.
While in the event of the object that you want to access, you can use the common "this" to easily access that same object.
To be able to retrieve the value of a field, you will now have to use the "rawValue" property. There's also the option to use "formattedValue" property or even "value.[oneOfChild].value".. the last option is getting more in details.
Now to be able to get to change the date like you wish to do, there's a lot of documentation on the matter, if you are familiar with script objects you can easily use the XFADate which Bruce (Br001) has developed years ago which ease a lot the date handling with so many functions pre-established. You can study how functions are used and use it to your own benefits. In the long term it's really useful.
If you wish to write down your own JavaScript here is a good way which you can do it:
// form1.Page1.dateStart::exit - (JavaScript, client)
//Let's say the event in which you write this would be the exit event of the start date field
//Access a field's value using the "rawValue" property
if (this.rawValue != null){
//Date format of "rawValue" to be assumed as (YYYY-MM-DD)
//Split Year/Month/Day in an array
var arrDates = this.rawValue.split("-");
//Create a new date object with the parameters as following (Year, Month, Day)
//Month are zero based index when creating a new Date object (-1 is required)
var date = new Date(arrDates[0], arrDates[1]-1, arrDates[2]);
//Same old code
date.setMonth(date.getMonth() + 18);
date.setDate(date.getDate() - 1);
dateEnd.rawValue = util.printd("yyyy-mm-dd", date);
}
I hope this will help.
Views
Replies
Total Likes