Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / Learn with Subs / Step by step: walkthrough t...

Step by step: walkthrough to manage custom work types for WHMS, X++

Subhad365 Profile Picture Subhad365 7 User Group Leader
 


Whatsup guys? 
This short write-up can help you to work with Custom-work types for WHMS module for mobile devises. 
Let me expain the scenario first, and then the solution.
We are in need of including a custom work type in our Advanced Warehouse Management mobile solutions, which should come as a part of any process (eg: prod pick-up or Prod Put-away or receive bulk orders, posting return order), and most importantly it needs to be prepopulated. When the step should come in your mobile, it must be prepopulated with some value (eg: customer name/ Lorry number/Challan number, etc.) -- which should be editable; user can edit it if he wishes.  


And you need to execute a method to get it executed for this method: called UpdateCustomerName:


Not sure where to start? This write up could help you.
Step 1: Start with Creating a new class, which should extend WHSWorkCustomData:
[ExtensionOf(classstr(WHSWorkCustomData))]
internal final class DemoWHSWorkCustomData_Extension
{
        public static name updateCustomerName(WHSWorkId _workId, str _data)
        {
                    //Write your logic to fetch data from worker Line

        }
}


Look at the method parameters. You must use theparameters WorkId and data as per the base class (WhsWorkCustomData) documentation:


Step 2: Next you need to create the following class thar should implement WhsIWorkTypeCustomProcessorand should be decorated with the signature of your method name: [WhsWorkTypeCustomProcessorFactory('UpdateCustomerName')]
The merthod overall looks like this:
[WhsWorkTypeCustomProcessorFactory('UpdateCustomerName')]
public class DemoWHSWorkTypeCustomProcessorCustomerName implements WhsIWorkTypeCustomProcessor
{
    #WHSRF
    public void process(WhsWorkTypeCustomProcessParameters _parameters)
    {
            //Write your own logic to update necessary tables/execute classes, wherever needed

    }
}
Once, done, the third step is to create the control in your mobile app. To do this, simply override the class: WhsWorkExecuteDisplay and the following method:
[ExtensionOf(classStr(WhsWorkExecuteDisplay))]
final class DemoWhsWorkExecuteDisplay_Extension
{
    if (workTypeCustom.WorkTypeCustomMethod == #UpdateCustomerName && workTypeCustom.CaptureData)
        {            
            ret += [this.buildControl(#RFText, #Custom, workTypeCustom.rfLabel, 1 , WHSWorkCustomData::UpdateCustomerNumber(workLine.workId, ''), extendedTypeNum(CustomerName), '', 0)];
        }
}
The above code checks if the customer method you are using is UpdateCustomerName (I have created a macro previously/static class variable for the same), and then I am using the Build Control method to add a text type control with the logic which you have implemented in step-1.
When you do this, the code will start showing you the data with pre-populated values, in your mobile devise.
Whew!!! So much for today, will return again with another cool hack with some other interesting topic. Till then Namaste and much love 💓💓💓 
​​​​​​​

Comments

*This post is locked for comments