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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

List in Data Contract not decoding properly.

(0) ShareShare
ReportReport
Posted on by 15

When passing Json data to a custom service with data contract

[DataContract]
public final class ProductionOrderPickingListContract extends ProductionOrderJournalContractBase
{
     private List pickingListLines;


     [
           DataMember('pickingListLines'),
           SysOperationLabel("@ManufacturingExecutionCommon:PickingListLines"),
           DataCollection(Types::Class, classStr(ProductionOrderPickingListLineContract)),
           Hookable(false)
     ]

}

the contract object does not properly decode the child List objects as seen below:

pastedimage1674679541680v1.png

The JSON being passed is below:

{
"contract": {
"ProductionOrderNumber": "P04298",
"JournalNameId": null,
"ProductionDate": "2023-01-25T00:00:00-05:00",
"ProductionShift": null,
"pickingListLines": [
{
"ItemNumber": "800001",
"ConsumptionBOMQuantity": 0.0,
"ProposalBOMQuantity": 0.0,
"ScrapBOMQuantity": 0.0,
"BOMUnitSymbol": null,
"ConsumptionInventoryQuantity": 1.0,
"ProposalInventoryQuantity": 1.0,
"ConsumptionCatchWeightQuantity": 0.0,
"ProposalCatchWeightQuantity": 0.0,
"ConsumptionDate": "0001-01-01T00:00:00",
"OperationNumber": 0,
"LineNumber": 0.0,
"PositionNumber": null,
"InventoryLotId": null,
"IsConsumptionEnded": 0,
"ErrorCause": 0,
"ProductColorId": null,
"ProductConfigurationId": null,
"ProductSizeId": null,
"ProductStyleId": null,
"ProductVersionId": null,
"ItemBatchNumber": null,
"ProductionWarehouseId": "W032",
"ProductSerialNumber": null,
"ProductionSiteId": null,
"InventoryDimension1": null,
"InventoryDimension2": null,
"InventoryDimension3": null,
"InventoryDimension4": null,
"InventoryDimension5": null,
"InventoryDimension6": null,
"InventoryDimension7": null,
"InventoryDimension8": null,
"InventoryDimension9": null,
"InventoryDimension10": null,
"InventoryDimension11": null,
"InventoryDimension12": null,
"InventoryStatusId": null,
"LicensePlateNumber": null,
"InventoryGtdId": null,
"InventoryOwnerId": null,
"InventoryProfileId": null
},
{
"ItemNumber": "800001",
"ConsumptionBOMQuantity": 0.0,
"ProposalBOMQuantity": 0.0,
"ScrapBOMQuantity": 0.0,
"BOMUnitSymbol": null,
"ConsumptionInventoryQuantity": 1.0,
"ProposalInventoryQuantity": 1.0,
"ConsumptionCatchWeightQuantity": 0.0,
"ProposalCatchWeightQuantity": 0.0,
"ConsumptionDate": "0001-01-01T00:00:00",
"OperationNumber": 0,
"LineNumber": 0.0,
"PositionNumber": null,
"InventoryLotId": null,
"IsConsumptionEnded": 0,
"ErrorCause": 0,
"ProductColorId": null,
"ProductConfigurationId": null,
"ProductSizeId": null,
"ProductStyleId": null,
"ProductVersionId": null,
"ItemBatchNumber": null,
"ProductionWarehouseId": "W032",
"ProductSerialNumber": null,
"ProductionSiteId": null,
"InventoryDimension1": null,
"InventoryDimension2": null,
"InventoryDimension3": null,
"InventoryDimension4": null,
"InventoryDimension5": null,
"InventoryDimension6": null,
"InventoryDimension7": null,
"InventoryDimension8": null,
"InventoryDimension9": null,
"InventoryDimension10": null,
"InventoryDimension11": null,
"InventoryDimension12": null,
"InventoryStatusId": null,
"LicensePlateNumber": null,
"InventoryGtdId": null,
"InventoryOwnerId": null,
"InventoryProfileId": null
}
]
}
}

I have the same question (0)
  • huijij Profile Picture
    19,813 on at

    Hi DSAnderson,

    From the code you've shared so far, there seems to be not any problems, have you debugged it? You must specify the AifCollectionTypeAttribute attribute if you use an X++ collection as a parameter to or as a return value from a service operation. Then you can loop through the list values using ListEnumerator.

  • DSAnderson Profile Picture
    15 on at

    I did decode it and the information does get imported but appears to be imported as a list of JSON strings instead of as a List of objects.  I can even iterate through the List of strings.

  • Martin Dráb Profile Picture
    240,055 Most Valuable Professional on at

    My understanding of the information from the debugger is that you're getting JObject instances, not strings.

    Note that you can look at the actual types, while we're limited to the single screenshot you showed us.

  • DSAnderson Profile Picture
    15 on at

    Apologies, you are correct that it is a Jobject - I was expecting it to be a List of objects.  Where I actually run into an issue is when I am iterating through the list.  The enumerator.current() returns a JObject without parameters and methods.  

           ListEnumerator enumerator = pickingListLines.getEnumerator();

           while (enumerator.moveNext())

           {

               ProdJournalBOM prodJournalBom = enumerator.current().parmProdJournalBom(prodTable, journalData);

               this.validate(prodJournalBom, allowValidationFailure);

               prodJournalBom.insert();

           }

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

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

#1
Subra Profile Picture

Subra 386

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 382 Super User 2026 Season 1

#3
Martin Dráb Profile Picture

Martin Dráb 270 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans