- Mark as New
- Follow
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Alright, well first of all you'll have to forget all you know about this.getField() method when using Dynamic Fields.
Dynamic forms are using XPath or "somExpression" to access different fields. You can access any field's path by having your text cursor in the JavaScript editor and then use the Ctrl+Left_Click on any object in the design and this will insert the reference syntax based on the current object's event you are accessing the wanted object.
You can also use the common "this" to access the same object of the event that you are in.
Any value of a field can now be accessed using the rawValue property. You can also use the formattedValue property to retrieve the displayed value to the user.
Back to the date issue, there's plenty of documentation that can help you achieved such a thing on the web. One of the best tools that I've found is using a Script Object which Bruce (BR001) has developped. This will provide many different pre-established functions to use for dates. In the long run, this script object is very useful for general use. Take a bit of time to look how the script object is being used and you will be able to handle dates really easily.
If you'd like to create your own JavaScript to achieve it, here's one way on how you can do it:
// form1.Page1.dateStart::exit - (JavaScript, client)
//This code is within the exit event of the start date field
//Always verify that the rawValue is different than null when handling it with functions
if (this.rawValue != null){
//Separate the date's value into an array assuming the rawValue's format is (YYYY-MM-DD)
var arrDates = this.rawValue.split("-");
//Creating a new date object with the following parameters (Year, Month, Day)
//Month parameter is zero based index when creating new Date() object, therefor -1 is needed
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.
Let me know if you need more assistance for this issue or the next step regarding different lengths of program
Views
Replies
Total Likes