Hi,
I've built an Editor for inputting times patterned after the provided Editor-DateSpinLists under Defined Controls. I want the Editor to capture a full datetime, though, not simply the time so I pass in an optional field name to the Editor using a simple text value in "settings" containing the name of the date field in the formview I want to use as default. If the setting (called "defaultDateField") is not set the Editor falls back to using the current date.
Here's the code in the Editor's "Set value in editor" property:
This works fine if I have a date field in my formview since I can reference the date value using the settings.data object (settings.data[settings['defaultDateField']]).
However, i now need to reference a date value from a parent record. For example, I have a "Date Audited" field in an "Audit" record, and the formview I'm working with represents a child record of the "Audit" table. As a result I cannot simply reference a field in the formview to pass in my default date value.
Finally, my question: is there a way to reference the parent table's data in the "Set value for editor" property? Or do I have to find that value using a javascript function to set the value for a "User defined editor and template settings" setting and pass it in to my Time Editor that way? I've tried to write a javascript function to do this unsuccessfully. Perhaps I'm not defining the javascript function and calling it in the Setting editor correctly. An example of such might help (the help provided in the settings definition editor says to use "Javascript:your_function_name" for the setting value but I had trouble getting the results I wanted this way).
Any advice/help appreciated. Thanks!
Here's the code in the Editor's "Get value from editor" property in case it's helpful for others trying to make the same kind of Editor:
I've built an Editor for inputting times patterned after the provided Editor-DateSpinLists under Defined Controls. I want the Editor to capture a full datetime, though, not simply the time so I pass in an optional field name to the Editor using a simple text value in "settings" containing the name of the date field in the formview I want to use as default. If the setting (called "defaultDateField") is not set the Editor falls back to using the current date.
Here's the code in the Editor's "Set value in editor" property:
Code:
var defDate; if (typeof settings['defaultDateField'] != 'undefined') { defDate = settings.data[settings['defaultDateField']]; } else { d = new Date(); defDate = (d.getMonth() + 1) + '/' + d.getDate() + '/' + d.getFullYear(); } var hEle = {dialog.Object}.getPointer('CONTAINER_DATEFORTIME'); hEle.innerHTML = defDate; var sHour = {dialog.object}.getControl("EDITORTIME_S_HOUR"); var sMinute = {dialog.object}.getControl("EDITORTIME_S_MINUTE"); var sAMPM = {dialog.object}.getControl("EDITORTIME_S_AMPM"); sHour.refresh(); sMinute.refresh(); sAMPM.refresh();
However, i now need to reference a date value from a parent record. For example, I have a "Date Audited" field in an "Audit" record, and the formview I'm working with represents a child record of the "Audit" table. As a result I cannot simply reference a field in the formview to pass in my default date value.
Finally, my question: is there a way to reference the parent table's data in the "Set value for editor" property? Or do I have to find that value using a javascript function to set the value for a "User defined editor and template settings" setting and pass it in to my Time Editor that way? I've tried to write a javascript function to do this unsuccessfully. Perhaps I'm not defining the javascript function and calling it in the Setting editor correctly. An example of such might help (the help provided in the settings definition editor says to use "Javascript:your_function_name" for the setting value but I had trouble getting the results I wanted this way).
Any advice/help appreciated. Thanks!
Here's the code in the Editor's "Get value from editor" property in case it's helpful for others trying to make the same kind of Editor:
Code:
var sHour = {dialog.object}.getControl("EDITORTIME_S_HOUR"); var sMinute = {dialog.object}.getControl("EDITORTIME_S_MINUTE"); var sAMPM = {dialog.object}.getControl("EDITORTIME_S_AMPM"); var defDate; if (typeof settings['defaultDateField'] != 'undefined') { defDate = settings.data[settings['defaultDateField']]; } else { d = new Date(); defDate = (d.getMonth() + 1) + '/' + d.getDate() + '/' + d.getFullYear(); } return defDate+' '+sHour.value+':'+sMinute.value+' '+sAMPM.value;
Comment