web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

error contract class list should have a public constructor with no argument

(0) ShareShare
ReportReport
Posted on by 2,050

Greeting everyone

when i try to use my DP class  

pastedimage1615293368801v1.png

i've checked my contract also did full compile and there's no error

and here my contract 

[DataContractAttribute,    SysOperationContractProcessingAttribute(classstr(LeaveReportUIBuilder))]
public class LeaveReportContract implements SysOperationValidatable
{
    HcmWorkerRecId hcmWorkerRecId;
    List    hcmPositionRecId;
    List    hcmLeaveTypeRecId;
    LeaveReportStatuse  leaveReportStatuse;
    FromDate                    fromDate;
    ToDate                      toDate;
}

[DataMemberAttribute('FromDate')]
public FromDate parmFromDate(FromDate _dateFrom = fromDate)
{
    fromDate = _dateFrom;
    return fromDate;
}


[DataMemberAttribute('ToDate')]
public ToDate parmToDate(ToDate _toDate = toDate)
{
    toDate = _toDate;
    return toDate;
}


[DataMemberAttribute('WorkerRecId')]
public HcmWorkerRecId parmHcmWorkerRecId(HcmWorkerRecId _hcmWorkerRecId = hcmWorkerRecId)
{

hcmWorkerRecId= _hcmWorkerRecId;
return hcmWorkerRecId;

}


[DataMemberAttribute('LeaveReportStatuse')]
public LeaveReportStatuse parmLeaveReportStatuse(LeaveReportStatuse _leaveReportStatuse = leaveReportStatuse )
{

leaveReportStatuse = _leaveReportStatuse;

return leaveReportStatuse;

}


[DataMemberAttribute('PositionRecId')]
public List parmHcmPositionRecId(List _hcmPositionRecId = hcmPositionRecId)
{

hcmPositionRecId= _hcmPositionRecId;
return hcmPositionRecId;

}


[DataMemberAttribute('HcmLeaveTypeRecId')]
public List parmHcmLeaveTypeRecId(List _hcmLeaveTypeRecId = hcmLeaveTypeRecId)
{

hcmLeaveTypeRecId= _hcmLeaveTypeRecId;
return hcmLeaveTypeRecId;

}



public boolean validate()
{
    boolean isValid = true;

           if (isValid && (fromDate > toDate))

{
  isValid = checkFailed(strfmt("Can't be form date bigger than to date"));

}

     if (!fromDate && toDate)

{
  isValid = checkFailed("you must enter From date or let them both blank");

}

     if (fromDate && !toDate)

{
  isValid = checkFailed("you must enter To date or let them both blank");

}

  return isValid;
}

what should to fix that issue

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    You didn's specify types of your lists.

    Decorate the methods (accepting and retunring lists) with DataCollectionAttribute, if it exists already in AX 2012 (sorry, I don't remember). If not, use AifCollectionTypeAttribute.

    For example:

    [
        DataMemberAttribute('PositionRecId'),
    	DataCollection(Types::Int64)    
    ]
    public List parmHcmPositionRecId(List _hcmPositionRecId = hcmPositionRecId)
    {
    	hcmPositionRecId = _hcmPositionRecId;
    	return hcmPositionRecId;
    }

    or

    [
        DataMemberAttribute('PositionRecId'),
    	AifCollectionTypeAttribute("_hcmPositionRecId", Types::Int64),
        AifCollectionTypeAttribute("return", Types::Int64)
    ]
    public List parmHcmPositionRecId(List _hcmPositionRecId = hcmPositionRecId)
    {
    	hcmPositionRecId = _hcmPositionRecId;
    	return hcmPositionRecId;
    }

    By the way, the name is misleading. hcmPositionRecId suggests that the value is a record ID, while it's a collection of record IDs. It's not irrelevant; wrong names can easy lead to errors.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 464 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans