Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / Learn with Subs / Control your Warehouse mana...

Control your Warehouse management mobile app form controls, D365FO

Subhad365 Profile Picture Subhad365 5 User Group Leader
What Is Warehouse Management? | Sortly

Have you ever encountered a situation where you needed to induce validations, in Warehouse Management mobile apps, before letting the user finally submit data?
The problem is that with D365FO WHMS mobile apps, most methods are marked as 'Private' and 'internal', and as a result, it becomes difficult to include your validation at the intended place.
For example: there is a validation that your users need you to ascertain, every time they use their 'gun' for cycle counting, the Qty to be counted should not go more than a certain Qty, say 1000.  If the users scan any Qty more than this limit, the system should be stopped from posting the counting journal, from being posted.
The solution is simple: you can use WHMS setup >> UNder General tab >> Mobile devise >> Scanned Qty limit:


But where do you think, you can put this validation?
Logically, this should restrict the record from being updated in the table WHSWorkLineCycleCount's  update() method:
if (abs(this.QtyCounted) > whsParm.ScannedQtyLimit)
        {
            throw error("Exceeded the scanned qty limit. Please recheck with validation parameters.");
        }
Where whsParm is our WHSParameters table.
But there is a problem. If there is a setup already that actually posts the data, automatically, once scanned -- then a pseudo journal would be created and 'attempted' to be posted, along with your error. This 'Pesudo' journal doesn't exist anywhere -- the system tried to create the journal and attempted to post it, but because of your above code, it got it aborted.

It gives a confusing message to the client, doesn't it? It's saying the journal was created and posted, though the journal doesn't really exist -- and also an error has come: scanned limit has exceeded. Please check. Which means our code didn't get triggered at the correct place. We have to call our validation, even before the cycle table gets into further steps of processing and journal creation. 
But where?
This is the problem with WHMS codes: the class method that calls this update() is : is from the class: WHSWorkExecuteDisplayCycleCount, in a method: processStepThreeIncorrectCount.

But this method is a private method, and obviously, we cannot control anything in here. Not just this, most, if not all, methods in the caller stack are marked as private.  
To know the perfect place, for writing the validation, could be understood -- if we first identify at which step, this is happening. For example, if you see the sequence of operations of WHMS apps for the cycle counting -- this happens at step number three. And if you debug the above code, you could see exactly this is getting called from the method:

This is a protected method and yes!!!! -- we can extend it. 
Hence we can write the code, creating an extension to this method: 
 protected container finalizeStepThreeCycleCounting(
    container             _ret,
    container             _cycleCountFormControls,
    Qty                   _totalQty,
    WhsWorkLineCycleCount _workLineCycleCount,
    InventDim             _inventDimCycleCount)
    {
        WHSParameters   whsParm = WHSParameters::find();
        if (abs(_totalQty) > whsParm.ScannedQtyLimit)
        {
            throw error("Scanned limit exceeded. Please check.");
        }
        return next finalizeStepThreeCycleCounting(_ret, _cycleCountFormControls, _totalQty, _workLineCycleCount, _inventDimCycleCount);
    }


And bingo!!! Now the code is gonna arrest the creation of the journal and subsequent steps: and would terminate with just the error. 
Moral of the story: you need to find out the step which is controlling the step of your desired execution, where you need to include your customization. 

Comments

*This post is locked for comments