|
|
prepopulate date field
Hi,
I am using javascript to exract data from the CRM database and would like to
populate the fields. For eg when the contact is selected populate the date of
birth.
My Client side script is as follows
var connection = new ActiveXObject("ADODB.Connection");
var connectionString =
"Provider=SQLOLEDB;Server=MPWEB;Database=mp_mscrm;Integrated Security=sspi";
connection.Open(connectionString);
var name = crmForm.all.new_customernameid.DataValue[0].name;
var query = "select accountidname, telephone1, birthdate, emailaddress1,
jobtitle, mobilephone, accountid from dbo.FilteredContact C where C.fullname
= '" + name + "'";
var rs = new ActiveXObject("ADODB.Recordset");
rs.Open(query, connection, /*adOpenKeyset*/1, /*adLockPessimistic*/2);
rs.moveFirst();
if(rs.Fields(2).Value== null)
{
alert("It is mandatory to have birthdate of the person. To enter details in
the contact form, click on the name ");
}
var date1 = rs.Fields(2).Value;
var list = new Array();
list[0] = new LookupControlItem(rs.Fields(6).Value, 1,rs.Fields(0).Value);
crmForm.all.new_companyid.DataValue = list;
crmForm.all.new_phone.DataValue = rs.Fields(1).Value;
crmForm.all.new_dob.DataValue = date1;
crmForm.all.new_email.DataValue = rs.Fields(3).Value;
crmForm.all.new_position.DataValue=rs.Fields(4).Value;
crmForm.all.new_mobileno.DataValue=rs.Fields(5).Value;
connection.Close();
I get the error property or method not supported. Could someone please
suggest a way to automatically populate the date field
Thanks
|
|
0
|
|
|
|
Reply
|
Utf
|
8/1/2007 5:54:00 AM |
|
Found the answer...
All fields are extracted as strings and hence need to convert the datefield
from string to datetime.
"Sharon" wrote:
> Hi,
> I am using javascript to exract data from the CRM database and would like to
> populate the fields. For eg when the contact is selected populate the date of
> birth.
> My Client side script is as follows
>
> var connection = new ActiveXObject("ADODB.Connection");
> var connectionString =
> "Provider=SQLOLEDB;Server=MPWEB;Database=mp_mscrm;Integrated Security=sspi";
> connection.Open(connectionString);
> var name = crmForm.all.new_customernameid.DataValue[0].name;
> var query = "select accountidname, telephone1, birthdate, emailaddress1,
> jobtitle, mobilephone, accountid from dbo.FilteredContact C where C.fullname
> = '" + name + "'";
> var rs = new ActiveXObject("ADODB.Recordset");
> rs.Open(query, connection, /*adOpenKeyset*/1, /*adLockPessimistic*/2);
> rs.moveFirst();
>
>
> if(rs.Fields(2).Value== null)
> {
> alert("It is mandatory to have birthdate of the person. To enter details in
> the contact form, click on the name ");
> }
>
> var date1 = rs.Fields(2).Value;
>
> var list = new Array();
> list[0] = new LookupControlItem(rs.Fields(6).Value, 1,rs.Fields(0).Value);
>
> crmForm.all.new_companyid.DataValue = list;
> crmForm.all.new_phone.DataValue = rs.Fields(1).Value;
> crmForm.all.new_dob.DataValue = date1;
> crmForm.all.new_email.DataValue = rs.Fields(3).Value;
> crmForm.all.new_position.DataValue=rs.Fields(4).Value;
> crmForm.all.new_mobileno.DataValue=rs.Fields(5).Value;
> connection.Close();
>
>
> I get the error property or method not supported. Could someone please
> suggest a way to automatically populate the date field
>
> Thanks
>
>
>
|
|
0
|
|
|
|
Reply
|
Utf
|
8/3/2007 12:12:03 AM
|
|
|
1 Replies
182 Views
(page loaded in 0.035 seconds)
|
|
|
|
|
|
|
|
|