You need to sign in to do that
Don't have an account?
satakshi
Record size is not as required
Hello,
I am writing a code where i have created two formula field which gives me number of days for particular month like this
Formula field= Febrary: To check number of days in febrary
IF( ISPICKVAL( Month__c , 'February') , TEXT(IF( OR((ISPICKVAL(Year__c, '2016')),(ISPICKVAL(Year__c,'2020')), ((ISPICKVAL(Year__c, '2024')))) , 29, 28)), null)
Formula field= NumberOfDays
VALUE(
CASE(Month__c,
"January","31",
"March","31",
"April","30",
"May","31",
"June","30",
"July","31",
"August","31",
"September","30",
"October","31",
"November","30",
"December","31",
""))
My query is i am writing a code where i can create records for those particular days of particular month but by my code i am able to create only 30 records. I want that in picklist field if month is jan then it should create 31 records, if month is feb then accordingly leap year it should create 29/28 days. and if month is of 30 days then it should create 30 records. Now with my code i am able to create only 30 records for any month. In debug statement System.debug('***************dy size******************'+dy); I am getting size 30. Can anyone please help me with this??
Controller:
public with sharing class Calender {
public List<DTP__c> mydtpList {set;get;}
public Calender(ApexPages.StandardController controller)
{
tid = ApexPages.currentPage().getParameters().get('id');
System.debug('***************dtp added*******************'+tid);
}
public Decimal dy;
public id tid{get;set;}
public PageReference createdtp() {
System.debug('***************tid tid*******************'+tid);
List<MTP__c> obj = [Select Id, Month__c, Year__c, February__c, NumberOfDays__c from MTP__c];
for(MTP__c mt:obj)
{
if(mt.Month__c=='February')
{
String str=mt.February__c;
dy=Decimal.ValueOf(str);
}
else
{
Decimal str= mt.NumberOfDays__c;
dy=str;
}
}
List<DTP__c> newdtp= new List<DTP__c>();
System.debug('***************dy size******************'+dy);
for(Integer i = 1; i<=dy; i++)
{
DTP__c dt = new DTP__c();
dt.MTP__c=tid;
newdtp.add(dt);
System.debug('****************dtp added********************'+tid);
//insert newdtp;
}
insert newdtp;
return null;
}
public List<DTP__c> getMydtpList(){
List<DTP__c> mydtpList =[select Name, Expenses__c, MTP__c, Food_Expenses__c, Date__c, Visit_type__c from DTP__c where MTP__c=:tid];
return mydtpList ;
}
//List<DTP__c> mydtpList = [select Expenses__c, Name, MTP__c, Food_Expenses__c, Visit_type__c from DTP__c where id=:tid];
}
VF PAge:
<apex:page standardController="MTP__c" extensions="Calender" action="{!createdtp}">
</apex:page>
Thanks & Regards,
Satakshi
I am writing a code where i have created two formula field which gives me number of days for particular month like this
Formula field= Febrary: To check number of days in febrary
IF( ISPICKVAL( Month__c , 'February') , TEXT(IF( OR((ISPICKVAL(Year__c, '2016')),(ISPICKVAL(Year__c,'2020')), ((ISPICKVAL(Year__c, '2024')))) , 29, 28)), null)
Formula field= NumberOfDays
VALUE(
CASE(Month__c,
"January","31",
"March","31",
"April","30",
"May","31",
"June","30",
"July","31",
"August","31",
"September","30",
"October","31",
"November","30",
"December","31",
""))
My query is i am writing a code where i can create records for those particular days of particular month but by my code i am able to create only 30 records. I want that in picklist field if month is jan then it should create 31 records, if month is feb then accordingly leap year it should create 29/28 days. and if month is of 30 days then it should create 30 records. Now with my code i am able to create only 30 records for any month. In debug statement System.debug('***************dy size******************'+dy); I am getting size 30. Can anyone please help me with this??
Controller:
public with sharing class Calender {
public List<DTP__c> mydtpList {set;get;}
public Calender(ApexPages.StandardController controller)
{
tid = ApexPages.currentPage().getParameters().get('id');
System.debug('***************dtp added*******************'+tid);
}
public Decimal dy;
public id tid{get;set;}
public PageReference createdtp() {
System.debug('***************tid tid*******************'+tid);
List<MTP__c> obj = [Select Id, Month__c, Year__c, February__c, NumberOfDays__c from MTP__c];
for(MTP__c mt:obj)
{
if(mt.Month__c=='February')
{
String str=mt.February__c;
dy=Decimal.ValueOf(str);
}
else
{
Decimal str= mt.NumberOfDays__c;
dy=str;
}
}
List<DTP__c> newdtp= new List<DTP__c>();
System.debug('***************dy size******************'+dy);
for(Integer i = 1; i<=dy; i++)
{
DTP__c dt = new DTP__c();
dt.MTP__c=tid;
newdtp.add(dt);
System.debug('****************dtp added********************'+tid);
//insert newdtp;
}
insert newdtp;
return null;
}
public List<DTP__c> getMydtpList(){
List<DTP__c> mydtpList =[select Name, Expenses__c, MTP__c, Food_Expenses__c, Date__c, Visit_type__c from DTP__c where MTP__c=:tid];
return mydtpList ;
}
//List<DTP__c> mydtpList = [select Expenses__c, Name, MTP__c, Food_Expenses__c, Visit_type__c from DTP__c where id=:tid];
}
VF PAge:
<apex:page standardController="MTP__c" extensions="Calender" action="{!createdtp}">
</apex:page>
Thanks & Regards,
Satakshi
showme ant one of janvery month record in standard page .
Regards ,
Harish.r
Its not added in site. How can i show you standard page?
Regards ,
Satakshi