Answered by:
Year Data not saved in Database

Question
-
var currentDate = new Date(); var year = currentDate.getYear();
I got the year from the current date.
I created a new attribute fiscalyr int(100)
I am moving the year field to crmForm.all.new_fiscalyr, but if I query the database the value is not stored, what going wrong?
Wednesday, February 2, 2011 6:38 PM
Answers
-
I got it the filed was not added in the form , i added it now.
- Marked as answer by CRMAG Thursday, February 3, 2011 6:44 PM
Thursday, February 3, 2011 6:44 PM
All replies
-
Is the fiscalyr field read-only?
If yes, you will have to set its ForceSubmit attribute to true like below:
crmForm.all.new_fiscalyr.ForceSubmit = true;
Daniel Cai | http://danielcai.blogspot.com- Proposed as answer by Andrii ButenkoMVP, Moderator Wednesday, February 2, 2011 6:50 PM
Wednesday, February 2, 2011 6:42 PM -
I tiried doing forcesubmit not savingWednesday, February 2, 2011 7:00 PM
-
How does your code look like? Is it something like the following?
var currentDate = new Date(); var year = currentDate.getYear(); crmForm.all.new_fiscalyr.DataValue = year; crmForm.all.new_fiscalyr.ForceSubmit = true;
If not, please post your code here.
Daniel Cai | http://danielcai.blogspot.comWednesday, February 2, 2011 8:01 PM -
alert(crmForm.all.new_travelend.DataValue)year = crmForm.all.new_travelend.DataValue.getYear();
alert(year);crmForm.all.new_fiscalyr1 = year;
crmForm.all.new_fiscalyr1.ForceSubmit = true;
alert(crmForm.all.fas_fiscalyr1);I tried changing crmForm.all.new_fiscalyr1 = year;
to crmForm.all.new_fiscalyr1.DataValue = year; (it is throwing an error saying objetc is crmForm.all.new_fiscalyr1.DataValue null)I have declared the crmForm.all.new_fiscalyr1 as Int(100).
Let me know this is a priority for me.
Thursday, February 3, 2011 3:09 PM -
There is no such thing of Int(100) in CRM, are you talking about nvarchar(100)??
I noticed that you are using fas_fiscalyr1 and new_fiscalyr1, one of them must be wrong.
Daniel Cai | http://danielcai.blogspot.comThursday, February 3, 2011 3:17 PM -
If the field is an integer field, your code should be something like this:
var currentDate = new Date(); var year = currentDate.getYear(); crmForm.all.new_fiscalyr1.DataValue = year; crmForm.all.new_fiscalyr1.ForceSubmit = true; alert(crmForm.all.new_fiscalyr1.DataValue);
If it's a nvarchar field, your script should be like this:
var currentDate = new Date(); var year = currentDate.getYear(); crmForm.all.new_fiscalyr1.DataValue = year.toString(); crmForm.all.new_fiscalyr1.ForceSubmit = true; alert(crmForm.all.new_fiscalyr1.DataValue);
Hope it helps.
Daniel Cai | http://danielcai.blogspot.com- Proposed as answer by Daniel Cai - KingswaySoftMVP Thursday, February 3, 2011 3:45 PM
Thursday, February 3, 2011 3:19 PM -
The is an attribute type called int , i had chosen this for the fiscal yr.
year = crmForm.all.new_travelend.DataValue.getYear();
crmForm.all.new_fiscalyr1.DataValue = year;
crmForm.all.new_fiscalyr1.ForceSubmit = true;still throwing an error
Thursday, February 3, 2011 3:45 PM -
OK, then you need to do this:
if (crmForm.all.new_travelend.DataValue != null) { var year = crmForm.all.new_travelend.DataValue.getYear(); crmForm.all.new_fiscalyr1.DataValue = year.toString(); crmForm.all.new_fiscalyr1.ForceSubmit = true; alert(crmForm.all.new_fiscalyr1.DataValue); }
You need to make sure that new_travelend field has value.
Daniel Cai | http://danielcai.blogspot.comThursday, February 3, 2011 3:47 PM -
I do have alert messages which brings the year 2011 from the crmForm.all.new_travelend.DataValue which is a date value
My "year" alert comes as 2011
crmForm.all.new_fiscalyr1.DataValue comes as "undefined"
crmForm.all.new_travelend.DataValue field has value.
alert(crmForm.all.fas_travelend.DataValue)
year = crmForm.all.fas_travelend.DataValue.getYear();
alert(year);crmForm.all.fas_fiscalyr1 = year;
crmForm.all.fas_fiscalyr1.ForceSubmit = true;
alert(crmForm.all.fas_fiscalyr1.DataValue); **********this alert comes as undefined********Thursday, February 3, 2011 4:11 PM -
I got it the filed was not added in the form , i added it now.
- Marked as answer by CRMAG Thursday, February 3, 2011 6:44 PM
Thursday, February 3, 2011 6:44 PM