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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Suggested Answer

Override createWork to Prevent New License Plate Creation

(1) ShareShare
ReportReport
Posted on by 634
Hi Experts, 

I need to modify the logic in the code below to avoid creating a new license plate. Instead, I want to receive the quantity into the same license plate that was shipped in the transfer order. I attempted to achieve this by extending the WhsWorkExecuteDisplayTOReceiving class and overriding the createWork() method. However, the system still creates a new target license plate due to standard behavior.

Can anyone advise if this requirement can be fulfilled through extensions, or if a different approach is needed?
 
protected WHSWorkBuildId createWork(InventTransferLine _transferLine)
    {
        WHSLicensePlate licensePlate = WHSLicensePlate::createLicensePlate(pass.lookup(#LicensePlateId), true, this.getDefaultContainerTypeCode());
        WHSWorkCreateTransferLine workCreateTransferLine = new WHSWorkCreateTransferLine(_transferLine);
        workCreateTransferLine.parmInventQty(WHSCatchWeightHelper::convertInventQuantity(pass.lookup(#ItemId), pass.lookup(#CurrentUOM), pass.lookupNum(#CurrentQty), _transferLine.InventDimId));
        WHSTransWeight calcCatchWeight;
        boolean isCWItem = PdsGlobal::pdsIsCWItem(_transferLine.ItemId);
        if (isCWItem)
        {
            InventHandlingQty totalReceiptQty = WHSCatchWeightHelper::convertInventQuantity(pass.lookup(#ItemId), pass.lookup(#UOM), pass.lookupNum(#Qty), _transferLine.InventDimId);
            if (WHSDeferredPOReceivingHandleCatchWeightFlight::instance().isEnabled())
            {
                calcCatchWeight = WHSCatchWeightHelper::calculateCatchWeightAndUpdatePass(_transferLine.ItemId, workCreateTransferLine.parmInventQty(), totalReceiptQty, pass);
            }
            else
            {
                if (WHSInventTable::shouldCaptureAggregateWeight(_transferLine.ItemId))
                {
                    calcCatchWeight = WHSCatchWeightHelper::calculateAverageWeight(workCreateTransferLine.parmInventQty(),
                                                                            totalReceiptQty - pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightQtySum),
                                                                            pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeight) - pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightWeightSum),
                                                                            InventTable::inventDecimals(_transferLine.ItemId));
                }
                else
                {
                    // If not capturing aggregate weight use work creation handling quantity rounded to correct decimal precision.
                    calcCatchWeight = WHSCatchWeightHelper::calculateAverageWeight(workCreateTransferLine.parmInventQty(),
                                                                            workCreateTransferLine.parmInventQty(),
                                                                            pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeight),
                                                                            InventTable::inventDecimals(_transferLine.ItemId));
                    pass.remove(WHSWorkExecuteDisplayCatchWeightControls::CatchWeight);
                }
                if (workCreateTransferLine.parmInventQty() != (totalReceiptQty - pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightQtySum)))
                {
                    pass.insert(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightQtySum, pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightQtySum) + workCreateTransferLine.parmInventQty());
                    pass.insert(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightWeightSum, pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightWeightSum) + calcCatchWeight);
                }
            }
        }
        // Auto Generate catch weight tag records based on configs
        if (isCWItem
            && WHSInventTable::isCatchWeightTagTracked(_transferLine.ItemId)
            && WHSInventTable::shouldCaptureAggregateWeight(_transferLine.ItemId)
            && WHSRFMenuItemTable::find(pass.lookup(#MenuItem)).GenerateCatchWeightTag)
        {
            WHSCatchWeightTagCreationSource tagSource = WHSCatchWeightTagCreationSource::instantiateFromSource(_transferLine, pass);
            WHSCatchWeightTagCreationMethod tagMethod = WHSCatchWeightTagCreationMethod::newAutoTagCreation(workCreateTransferLine.parmInventQty(), calcCatchWeight);
            WHSCatchWeightTagCreator tagCreator = WHSCatchWeightTagCreator::construct();
            this.trackAutoGeneratedCatchWeightTags(tagCreator.createCatchWeightTags(tagSource, tagMethod));
        }
        workCreateTransferLine.parmCreatedBy(userId);
        workCreateTransferLine.parmInventTransferLine(_transferLine);
        workCreateTransferLine.parmUnitization(pass.lookup(#Unitization));
        workCreateTransferLine.parmTargetLicensePlateId(licensePlate.LicensePlateId);
        workCreateTransferLine.parmWorkTemplateCode(WHSRFMenuItemTable::find(pass.lookup(#MenuItem)).WorkTemplateCode);
        workCreateTransferLine.parmDispositionCode(pass.lookupStr(#Disposition));
        workCreateTransferLine.parmReceiptId(pass.parmReceiptId());
        WHSWorkBuildId workBuildId = workCreateTransferLine.createWork();
        if (isCWItem && pass.exists(WHSWorkExecuteDisplayCatchWeightControls::ScannedCatchWeightTagList))
        {
            WHSCatchWeightTagLastRegistration::updateCatchWeightTagRegistrationWorkLine(str2con(pass.lookupStr(WHSWorkExecuteDisplayCatchWeightControls::ScannedCatchWeightTagList)),
                WHSWorkTable::findSingleInboundWorkByWorkBuildId(workBuildId).WorkId);
        }
        return workBuildId;
    }
 
 
 
I have the same question (0)
  • Suggested answer
    Zain Mehmood Profile Picture
    4,187 Most Valuable Professional on at

    Hi,

    By default, the system creates a new license plate during transfer order receiving to separate inbound and outbound movements. Overriding createWork() alone may not be enough, as the target LP generation logic may be coming from lower-level framework classes (like WHSWorkCreate or containerization logic).
     
    Before suggesting a workaround — can you clarify why the same license plate is required at the receiving site? Understanding the business reason will help determine if this is best handled via extension or a process change.
     
    Regards,
    Zain
  • D365  beginner Profile Picture
    634 on at
    Hi Mr. Zain,
     
    Maintaining the same license plate is our business requirement to ensure better traceability. I attempted to achieve this through the extension below, but it does not work as expected
     
    [ExtensionOf(classStr(WHSWorkExecuteDisplayTOReceiving))]
    final class WHSWorkExecuteDisplayTOReceiving_Extension
    {     
        #define.ItemId("ItemId")
        #define.CurrentUOM("CurrentUOM")
        #define.CurrentQty("CurrentQty")
        #define.MenuItem("MenuItem")
        #define.Unitization("Unitization")
        #define.Disposition("Disposition")
        protected WHSWorkBuildId createWork(InventTransferLine _transferLine)
        {
            // Use the existing license plate from the transfer order
            WHSLicensePlate licensePlate = WHSLicensePlate::find(_transferLine.InventDimId);
            // Call the next method in the chain
            WHSWorkBuildId workBuildId = next createWork(_transferLine);
            // Create the work transfer line object
            WHSWorkCreateTransferLine workCreateTransferLine = new WHSWorkCreateTransferLine(_transferLine);
            workCreateTransferLine.parmInventQty(WHSCatchWeightHelper::convertInventQuantity(pass.lookup(#ItemId), pass.lookup(#CurrentUOM), pass.lookupNum(#CurrentQty), _transferLine.InventDimId));
            
            // Set the target license plate to the existing license plate
            workCreateTransferLine.parmTargetLicensePlateId(licensePlate.LicensePlateId);
            // Set other parameters
            workCreateTransferLine.parmCreatedBy(userId);
            workCreateTransferLine.parmInventTransferLine(_transferLine);
            workCreateTransferLine.parmUnitization(pass.lookup(#Unitization));
            workCreateTransferLine.parmWorkTemplateCode(WHSRFMenuItemTable::find(pass.lookup(#MenuItem)).WorkTemplateCode);
            workCreateTransferLine.parmDispositionCode(pass.lookupStr(#Disposition));
            workBuildId = workCreateTransferLine.createWork();
            return workBuildId;
        }
    }
  • D365  beginner Profile Picture
    634 on at
    I'd really appreciate any help. 

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 301 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 120 Super User 2025 Season 2

#3
Siv Sagar Profile Picture

Siv Sagar 105 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans