You need to sign in to do that
Don't have an account?
順 佐藤
I got this error: Month : SObject constructor must use name=value pairs
public with sharing class Month {
private List<Week> weeks;
private Date upperLeft;
public Date firstDate;
public List<Date> getValidDateRange() {
List<Date> ret = new List<Date>();
ret.add(upperLeft);
ret.add(upperLeft.addDays(5*7));
return ret;
}
public String getMonthName() {
return DateTime.newInstance(
firstDate.yaer(),
firstDate.month,
firstDate.day())
.format('MMMM');
}
public String getYearName() {
return DateTime.newInstance(
firstDate.yaer(),
firstDate.month,
firstDate.day())
.format('yyyy');
}
public String[] getWeekdayNames() {
Date today = system.today.toStartOfWeek();
DateTime dt = DateTime.newInstanceGmt(
today.year(),
today.month(),
today.day());
List<String> ret = new List<String>();
for (Integer i = 0; i < 7; i++) {
ret.add(dt.formatgmt('EEEE'));
dt = dt.addDays(1);
}
return ret;
}
public Date getfirstDate() {
return firstDate;
}
public Month(Date value) {
weeks = new List<Week>();
firstDate = value.toStartOfMonth();
upperLeft = firstDate.toStartOfWeek();
Date tmp = upperLeft;
for(Integer i = 0; i< 5; i++) {
Week w = new Week(i+1, tmp, value.month());
system.assert(w != null);
this.weeks.add(w);
tmp = tmp.addDays(7);
}
}
public void setEvents(List<Event> ev) {
for (Event e:ev) {
for (Week w:weeks) {
for (Day c:w.getDays()) {
if (e.Activity.isSameDay(c.theDate)) {
c.eventsToday.add(new Event(e));
}
}
}
}
}
public List<Week> getWeeks() {
system.assert(weeks != null, 'could not create weeks list');
return this.weeks;
}
}
Anyone understand thie error ??
private List<Week> weeks;
private Date upperLeft;
public Date firstDate;
public List<Date> getValidDateRange() {
List<Date> ret = new List<Date>();
ret.add(upperLeft);
ret.add(upperLeft.addDays(5*7));
return ret;
}
public String getMonthName() {
return DateTime.newInstance(
firstDate.yaer(),
firstDate.month,
firstDate.day())
.format('MMMM');
}
public String getYearName() {
return DateTime.newInstance(
firstDate.yaer(),
firstDate.month,
firstDate.day())
.format('yyyy');
}
public String[] getWeekdayNames() {
Date today = system.today.toStartOfWeek();
DateTime dt = DateTime.newInstanceGmt(
today.year(),
today.month(),
today.day());
List<String> ret = new List<String>();
for (Integer i = 0; i < 7; i++) {
ret.add(dt.formatgmt('EEEE'));
dt = dt.addDays(1);
}
return ret;
}
public Date getfirstDate() {
return firstDate;
}
public Month(Date value) {
weeks = new List<Week>();
firstDate = value.toStartOfMonth();
upperLeft = firstDate.toStartOfWeek();
Date tmp = upperLeft;
for(Integer i = 0; i< 5; i++) {
Week w = new Week(i+1, tmp, value.month());
system.assert(w != null);
this.weeks.add(w);
tmp = tmp.addDays(7);
}
}
public void setEvents(List<Event> ev) {
for (Event e:ev) {
for (Week w:weeks) {
for (Day c:w.getDays()) {
if (e.Activity.isSameDay(c.theDate)) {
c.eventsToday.add(new Event(e));
}
}
}
}
}
public List<Week> getWeeks() {
system.assert(weeks != null, 'could not create weeks list');
return this.weeks;
}
}
Anyone understand thie error ??
you should use Sobject (Account, Contact, Customobject__c) or premitive type (Integer, Double, String) in your list.
1) Please week Class Construtor and pass all required value according to construtor.
2) Please try to rename then class from Month. Because month is also standard method.
Please let us know if this will help you
There should not be a List<Week> created , since its not supported in by any programming language.
PLEASE SELECT THIS AS THE BEST ANSWER IF IT SOLVES.
Thanks,
Roh