Using setValue to populate a date field.

Not applicable

I'm trying to use the 'variable.setValue' to populate a date field. The formatting of the date value is 28-Sep-2011 and manually putting the value into the date field works perfectly fine. In addition I know my script is working because I pointed it to the text field and it populated just fine.

Anyone else have experience with setValue and date fields?

Thanks!

5 REPLIES 5

ShaneBrazeal
Tera Contributor

Can you share more of your code? Are you using


g_form.setValue('variable', dateValue)
?


Not applicable

Sorry for not being more specific.
I'm not specifically using g_form, but for the example I am following your example.

g_form.setValue('u_mycreated_date_field', dateValue);

Where dateValue is in a format of 28-Sep-2011 and u_mycreated_date_field is a date field.
It works perfectly field if I point it to a text field, like comments, on the form, but not if I'm setting it to a date field. What is even stranger I can copy and paste the date example manually into the field and it works fine.

Thanks


ShaneBrazeal
Tera Contributor

How are you trying to set it out of the following two examples: sounds like you might be doing it server side in a business rule (i.e.


current.dateField.setValue(value);
) vs client side in a client script (i.e.

g_form.setValue('dateField', value);




Not applicable

Nope, we have added a date field to SQL Instances so we can better track when the last time discovery found them. (There is a last discovered for Servers but not Instances)

With the probe we're setting the date value and passing it to the sensor.
Within the sensor we're trying to apply the date value to the date field.

I'm using the g_form.setValue('dateField', value); method as its being used throughout the sensor script to successfully populate all of our other fields. Again, manually the date field will accept the formatted date value and via the sensor I can populate a text field with the result, but the date field will not accept the value.

Thanks again.