Anything similar to a getDisplayValue in client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2011 12:56 PM
We're attempting to do a database query from a client script (I know, generally not a good idea). Running into an issue when setting the form fields to the results, its setting the fields to the field value, not the display value. For example in incident, rather than setting the field to "Resolved", its setting it to the value "6".
Wondering if there's anything similar to getDisplayValue() in a client script as there is in a business rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2011 06:13 PM
Please post your script. When setting choice values, you should use the value and not the display value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2011 07:15 PM
Tried a different way to get rid of the database query. Same results using the getReference function.
None of the fields we're trying to set is a choice field, they're all either date/time fields or just string fields.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//If the page isn't loading
if (!isLoading) {
//If the new value isn't blank
if(newValue != '') {
if (newValue != oldValue) {
var incid = g_form.getReference('u_incident');
g_form.setValue('u_incident_severity', incid.severity);
g_form.setValue('u_incident_state', incid.incident_state);
g_form.setValue('u_short_desc', incid.short_description);
g_form.setValue('u_impacted_business_unit', incid.u_impacted_business_units);
if(g_form.getValue('u_incident_opened') == '') {
g_form.setValue('u_incident_opened', incid.opened_at);
}
if(g_form.getValue('u_incident_resolved') == '') {
g_form.setValue('u_incident_resolved', incid.u_resolved_at);
}
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2011 07:40 PM
2 things:
This is an onChange script which will only execute on the designated field change.
Have you thrown alert in for debugging? For example:
alert(incid.severity);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2012 06:20 AM
Not much documentation exists on this g_form method but it seems to be similar to the server-side getDisplayValue()
g_form.getDisplayBox('field name').value