cancel
Showing results for 
Search instead for 
Did you mean: 

How-to extend the Sales Order with the Project ID?

Jacques-Antoine
Active Participant

Hello ByD Community,

My problem is the following:

I want to add an extension field to the Sales Order Header, which would be the Project ID assigned to this Sales Order.

My use case only involve one Project ID per Sales Order, and the task will be the same from a Line Item to another. So I can only use the GetFirst() to retrieve only the first Line Item.

Past week, I asked a similar question for the Purchase Orders and I succeeded to do it after a hint from Dan!

As for the Purchase Order, I thought the Project Assignment was built through the SalesOrder.Item.ItemAccountingCodingBlockDistribution.AccountingCodingBlockAssignment.ProjectReference, but it seems that it is different.

So as soon as I try to check if this Association IsSet() it just returns me that it is not!

I succeeded to bluntly push the TaskUUID in my Extension field for testing purpose, without any check and verification, but not the Project ID neither with good validations.

I also tried to see with the SalesItem Association instead of the Item Node, but it is the same. Any time I try a different check it returns me the N/A for my field, which is my last condition if the association is not set! What is driving me crazy is that you have the Project ID is shown on the top of the Sales Order, but I just cannot find how to retrieve it in the Studio!!!

Here is my sample code in my After-Modify event (I also tried with a On-Save) where the ProjectIDSalesOrder is my extension field in the Cloud Solution:

import ABSL;

if (this.Item.GetFirst().ItemAccountingCodingBlockDistribution.IsSet())

  {

  if (this.SalesItem.GetFirst().ItemProduct.ProductCategoryHierarchyProductCategoryIDKey.ProductCategoryInternalID.Matches("130"))

       {

       this.ProjectIDSalesOrder = this.SalesItem.GetFirst().ItemServiceTerms.ProjectTaskUUID.content.ToString();

     /*what I need actually is : this.ProjectIDSalesOrder =      this.Item.ItemAccountingCodingBlockDistribution.AccountingCodingBlockAssignment.GetFirst().ProjectReference.ProjectID.content;*/

       }

  else {this.ProjectIDSalesOrder = "No project assigned";}

  }

else {this.ProjectIDSalesOrder = "N/A";}

If anybody could help me on this, it would be greatly appreciated.

Thank you community!

Best regards.

Jacques-Antoine

View Entire Topic
michael-schulz
Participant
0 Kudos

Hello all,

it's 2024 and there is still no solution apparently?

Thanks and best regards!