Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

AIF Custom Service Parameter is a List of objects that ha a List parameter on them

Posted on by 50

We're on Dynamics Ax 2012 R2 CU6.

I'm building a custom service that takes a List of objects.  Each of these objects has a parameter on it that is a List of another object.  Basically it's a list of parent/child objects I'm passing in.

Contracts

The parent class/contract is:

[DataContractAttribute]
public class InventoryAddPackageContract
{
    List PackageDetails;
}

The parameter that holds the details as:

[DataMemberAttribute('packDetails')]
public List packDetails(List _PackageDetails = PackageDetails)
{
    PackageDetails = _PackageDetails;

    return PackageDetails;
}

The PackageDetails there is another class with the appropriate attributes to make it a contract.

[DataContractAttribute]
public class InventoryPackDetailContract
{
    //variables for parameters here
}

So the addition object can have 1 to many detail objects on it.

Service

The service definition is as such:

[
    AifCollectionTypeAttribute('return', Types::Class, classStr(InventoryResultContract)),
    AifCollectionTypeAttribute('additions', Types::Class, classStr(InventoryAddPackageContract)),
    AifCollectionTypeAttribute('InventoryAddPackageContract.packDetails', Types::Class, classStr(InventoryPackDetailContract)),
    SysEntryPointAttribute(false)
]
public List AddPackage(List additions)
{
    //Do some work here
}

Notice that third AIF collection declaration there that doesn't actually work.  With or without that declaration, I will always get this error when I try and activate the service.

The service 'TILInventoryService' could not be generated.\n  
Error: An attribute of type 'AifCollectionTypeAttribute' has not been defined. 
Method: 'TILInventoryAddPackageContract.packDetails', Parameter: ''.

I've tinkered with everything under the sun for the third AIF collection type attribute on the AddPackage method.  I've tried using _PackageDetails, PackDetails, packDetails, PackageDetails, etc and I can't get it to activate and stop that error message.

I've already spent a lot of time searching and hoping to find some sort of answer, but I'm stumped.  I've even tried to attach the debugger to the activation logic on the inbound ports, but the debugger next attaches for me (maybe it's always CIL so I need VS 2010 to do it?).  Any thoughts or help would be much appreciated.  Thanks in advance.

  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: AIF Custom Service Parameter is a List of objects that ha a List parameter on them

    Please create a thread and show your code to us, so we can review it.

  • PeetRaki2 Profile Picture
    PeetRaki2 5 on at
    RE: AIF Custom Service Parameter is a List of objects that ha a List parameter on them

    Hi Richard,

    I know its been long time since this posted. I am running into similar situation. Did you find a solution for this, can you pls let me know.

  • Richard K Profile Picture
    Richard K 50 on at
    RE: AIF Custom Service Parameter is a List of objects that ha a List parameter on them

    Good catch on the extra space in there.  I fixed that issue, tried again, and got the same error.  Unfortunately I got the same result with adding a return attribute.

    [
        DataMemberAttribute('packDetails'),
        AifCollectionTypeAttribute('_PackageDetails', Types::Class, classStr(InventoryPackDetailContract)),
        AifCollectionTypeAttribute('return', Types::Class, classStr(InventoryPackDetailContract))
    ]
    public List packDetails(List _PackageDetails = PackageDetails)
    {
        PackageDetails = _PackageDetails;
    
        return PackageDetails;
    }

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: AIF Custom Service Parameter is a List of objects that ha a List parameter on them

    You actually missing  AifCollectionTypeAttribute("return"...) as well, because it returns something. And there is extra space '_PackageDetails ' here.

  • Richard K Profile Picture
    Richard K 50 on at
    RE: AIF Custom Service Parameter is a List of objects that ha a List parameter on them

    I'd tried this one as well in my many iterations.  Just reimplemented it as well to try it again.

    [
        DataMemberAttribute('packDetails'),
        AifCollectionTypeAttribute('_PackageDetails ', Types::Class, classStr(InventoryPackDetailContract))
    ]
    public List packDetails(List _PackageDetails = PackageDetails)
    {
        PackageDetails = _PackageDetails;
    
        return PackageDetails;
    }

    Same error.

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: AIF Custom Service Parameter is a List of objects that ha a List parameter on them

    You should use AifCollectionTypeAttribute when you define "public List packDetails" instead of doing it during entry point declaration.

    Something like

    [DataMemberAttribute('packDetails'),

    AifCollectionTypeAttribute('_PackageDetails ', Types::Class, classStr(InventoryPackDetailContract)]

    public List packDetails(List _PackageDetails = PackageDetails)

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans