Hello guys,
I did a custom service like this:
Contract Class where i defined all return parameters
[DataContractAttribute]
public class PurchAgreementContractLine
{
//AgreementLine
AgreementLineNum_PSN lineNumber;
CurrencyCode currencyCode;
ItemId itemId;
//PurchAgreementHeader
AgreementState agreementState;
EffectiveDate effectiveDate;
ExpirationDate expirationDate;
VendAccount vendAccount;
DataAreaId dataAreaId;
PurchAgreementId purchAgreementId;
//DirParty
Name vendorName;
//InventDim
EcoResItemSizeName sizeName;
EcoResItemColorName colorName;
EcoResItemStyleName styleName;
Description sizeDescription;
Description styleDescription;
//AgreementLineQuantityCommitment
UnitOfMeasureSymbol productUnitOfMeasure;
PriceUnit pricePerUnit;
//EcoResProductTranslation
EcoResDescription ecoResDescription;
}
for each parameter a parm method like this:
[DataMemberAttribute(‘Agreement State’)]
public AgreementState agreementState(AgreementState _agreementState = agreementState)
{
agreementState = _agreementState;
return agreementState;
}
Then a service class with exposed method findAgreement which returns the contract class:
class PurchAgreementListService
{
}
[AifCollectionTypeAttribute(’_legalEntity’, Types::String), //companyId
AifCollectionTypeAttribute(’_vendor’, Types::String),
AifCollectionTypeAttribute(‘return’, Types::Class, classStr(AVY0010_PurchAgreementContractLine)),
SysEntryPointAttribute(true)]
public List findAgreement( DataAreaId _legalEntity,
VendAccount _vendor,)
{
PurchAgreementContractLine agreementContractLine;
AgreementLine agreementLine;
List agreements;
Query q = new Query();
QueryRun qr;
QueryBuildDataSource qbds, qbds1;
agreements = new List(Types::Class);
qbds = q.addDataSource(tableNum(PurchAgreementHeader));
if (_vendor)
qbds.addRange(fieldNum(PurchAgreementHeader, VendAccount));
q.dataSourceTable(tableNum(PurchAgreementHeader)).addDataSource(tableNum(AgreementLine)).addLink(fieldNum(PurchAgreementHeader,RecId),fieldNum(AgreementLine,Agreement));
q.dataSourceTable(tableNum(AgreementLine)).addDataSource(tableNum(InventDim)).addLink(fieldNum(AgreementLine, InventDimId), fieldNum(InventDim, InventDimId));
qr = new QueryRun(q);
while (qr.next())
{
agreementLine = qr.get(tableNum(AgreementLine));
agreementContractLine = new PurchAgreementContractLine();
agreementContractLine.purchAgreementId(agreementLine.PurchAgreementHEader().PurchNumberSequence);
agreementContractLine.agreementState(agreementLine.PurchAgreementHEader().AgreementState);
agreementContractLine.vendAccount(agreementLine.PurchAgreementHeader().VendAccount);
agreementContractLine.vendorName(agreementLine.PurchAgreementHEader().vendName());
…
agreements.addEnd(agreementContractLine);
}
return agreements;
}
CIl incremental and full done, Registered the service, added to the service group, deployed and inbound port active:
when I try to invoke the service I got this error:
error CS0234: The type or namespace name ‘Application’ does not exist in the namespace ‘Microsoft.Dynamics.Ax’ (are you missing an assembly reference?)
Modifying the return type from type class
AifCollectionTypeAttribute(‘return’, Types::Class, classStr(AVY0010_PurchAgreementContractLine)),
to a List of Types:string it works without issues… any idea?