Using EDT extending from NoYesId in a custom service

Hi guys,

I am building some custom services for our customer but there’s one thing that we can’t get to work: using a datatype that extends from NoYesId.

I have a service that is used to create Service Orders in Ax. This service has been in use for a while now, so the service itself works. Now today i need to add a new field in the service, and this is what i did:

  1. I created a new EDT that extends from NoYesId

  2. I’ve added this field in the service with the following code:

[ SysEntryPointAttribute(true),

AifCollectionTypeAttribute(’_vatRecupEditable’ , Types::Integer)

]

public ServiceOrderId createServiceOrder(…

VATRecupEditable _vatRecupEditable)

After adding those 2 lines of code, i updated my CIL, but when i tried to deploy the service, i got the following error message:
The port XXX could not be deployed.
Error CS1501: No overload for method ‘CreateServiceOrder’ takes 21 arguments

I don’t know what causes this problem, and it only seems to happen when i use datatypes that extend from NoYesId.
Does anybody know whats wrong?

You talk about NoYesId (i.e. an enum with No and Yes) and then you show a piece of code declaring a collection of integer values. I don’t see how these things are supposed to be related.

If VATRecupEditable extends NoYesId, then the attribute doesn’t makes any sense. If you want one NoYes value, throw away the attribute. If you want a collection of integers, replace VATRecupEditable type with a collection (e.g. List or Set).

Hi Martin,

Thanks for your answer, I’ve changed the code by removing the attribute statement, but it’s still not fixed.

This code works perfectly:

[ SysEntryPointAttribute(true),

AifCollectionTypeAttribute(‘return’, Types::String)

]

public ServiceOrderId createServiceOrder(CustAccount _custAccount,

CustAccount _thirdPartyPayer,

CGKCCSRVDamageNumber _damageNumber,

CGKCCSRVInsuranceFranchise _franchise,

CGKCCSRVInsurancePolicyNumber _policyNumber,

LanguageId _language,

CGKCCSRVScenarios _scenario,

CGKCCSRVVATRecup _vatRecup,

CGKCCSRVLicensePlate _licensePlate,

CGKCCSRVVIN _vin,

CGKCCVehicleMakeId _make,

CGKCCVehicleModelId _model,

CGKCCVehicleBodyTypeId _bodyType,

CGKCCVehicleVariantId _variant,

CGKCCSRVDamageDate _damageDate,

CGKCCSRVDamageCauseId _cause,

CGKCCSRVDamageCauseRemarks _causeRemarks,

CGKCCSRVStatus _status,

CGKCCSRVCancelReason _cancelReason,

CGKCCSRVCancelSubReason _cancelSubReason,

CGKCCSRVCancelRemarks _cancelRemarks)

But when i then add the following code, it doesn’t work anymore:

[ SysEntryPointAttribute(true),

AifCollectionTypeAttribute(‘return’, Types::String)

]

public ServiceOrderId createServiceOrder(…

VATRecupEditable _vatRecupEditable)

This gives me the error i described above, with the overload error. The only thing i added is one parameter, the VATRecupEditable.

Man, you really should switch to a data contract class. You already see how difficult is for you to manage this number of arguments.

Now tell me when exactly you get the error.

This is what i did:

  1. Add the parameter VATRecupEditable to the service operation

  2. Generate incremental CIL

  3. Deploy the service

I get the error during the deployment of the service.

I know, but I don’t know what you mean by deploying a service. Deploying an inbound port in AX? If so, review source code generated for your service and tell me what adapter you use.

Nevertheless if I was you, I would move all the parameters to a data contract before doing any additional debugging. I think you’re making your life more complicated than it must be.

I will consider the data contract, but i’ve inherited this from another developer and if i change it to a data contract, the .NET team will have to rewrite their code as well.

When i said deploy a service, i meant deploy the service group. The inbound port is created as basic, with adapter NetTcp. I’ve checked the generated file and i see that all parameters are added except the new VATRecupEditable parameter. That’s is probably the reason why i’m getting that error.

But i have no idea why the new parameter is not added.

You’re changing the number of parameters, which is a breaking change, therefore the .NET team will be forced to change their code anyway. If you already used a data contract class, adding a new property wouldn’t break anything. Therefore you’re doing exactly the opposite thing than what you want.

Ensure yourself that all X++ code is compiled correctly.

Then you could debug AifMessageContractGenerator to see why the code gets generated in that way, nevertheless I wouldn’t bother before converting those 21 parameters to a single data contract class and recompiling the application.

Hi Martin,

I’ve had a meeting with our .NET guys and we have agreed to switch to the use of data contracts instead of loose parameters. The data contracts are working and i am now able to deploy the service with the new parameters included.

Thanks for your help on this issue.