Thursday, December 7, 2023

Code to update data for custom fields in SubBillScheduleLine lines which are created from milestone allocation in D365 f&o X++

[Extensionof(tableStr(SubBillScheduleLine))]

internal final class DaxSubBillScheduleLine_Extension

{

   public void recreateMilestoneSubItems(SubBillMilestoneAllocationHeader _milestoneAllocationHeader)

   {

       SubBillScheduleLine milestoneSubLine;

       SubBillMilestoneAllocationLine  allocationLine;

       while select allocationLine

           where allocationLine.SubBillSchedLineRecId == _milestoneAllocationHeader.SubBillSchedLineRecId

       {

           select forupdate milestoneSubLine

               where milestoneSubLine.RecId == allocationLine.SubBillSchedLineRecId;

           ttsbegin;

           milestoneSubLine.DaxEnum = DaxEnum::Advanced; //custom field

           milestoneSubLine.update();

           ttscommit;

       }

       next recreateMilestoneSubItems(_milestoneAllocationHeader);

   }

   public void insert()

   {

       SubBillScheduleLine milestoneSubLine;

       select milestoneSubLine

           where milestoneSubLine.SubBillMilestoneHeaderRecId == this.SubBillMilestoneHeaderRecId;

       this.DaxStatus = milestoneSubLine.DaxStatus; //custom field

       next insert();

   }

}

..............

Subsription billing > All Billing Schedules

Create a header and line and click on Milestone Allocation.




Lines from milestone will be created in SubBillScheduleLines. And custom fields will be updated.