Thursday, July 4, 2019
Welcome to the last part of our WHS mobile device development series where we’ll introduce some common functions and best practices that can boost your mobile device development experience.
Useful WHSWorkExecuteDisplay methods
You can use these methods in classes that extend WHSWorkExecuteDisplay class.
getControlDataFromContainer(container _displayCon, str _controlName) – This method is useful when you need to get the data control from the display container. Alternatively, you could run the setControlDataFromContainer(container _displayCon, str _controlName, str _newValue) method to set the control data for the display container.
Example of these methods:
container ret = this.getReturnContainer();
WHSLicensePlateId licensePlateId = this.getControlDataFromContainer(ret, #LicensePlateId);
ret = this.setControlDataFromContainer(ret, #LicensePlateId, 'NewLicensePlateId');
addErrorLabel(container _con, str _error, WHSRFColorText _color) – use this method when you need to display an error, warning or other notification to the mobile device.
Note: you specify the notification type using WHSRFColorText enum
Example of the method:
container ret = this.addErrorLabel(connull(), "@WAX866", WHSRFColorText::Success);
resetPassthrough(container _con, boolean _useOld) – use this method when you need to reset the passthrough object or copy it from the display container.
Example of the method:
container ret = this.getReturnContainer();
WHSRFPassthrough pass = this.resetPassthrough(ret, false);
indexOfBuildControlFromContainer(container _displayCon, str _controlName) – use this method when you need to get the index position of a certain control of display container. It’s often used for getting the error control container.
Example of the method:
container ret = this.getReturnContainer();
int errorIndex = this.indexOfBuildControlFromContainer(ret, #RFError);
updateModeStepPass(container _con, WHSWorkExecuteMode _mode, int _step, WHSRFPassthrough _pass) – use this method to update specified container with step, mode or WHSRFPassthrough of your choice.
Example of the method:
container ret = this.getReturnContainer();
ret = this.updateModeStepPass(ret, mode, step, pass);
WHSRFPassthrough::create(container _con) – use this method if you want to retrieve the WHSRFPassthrough object from the container.
Example of the method:
container ret = this.getReturnContainer();
WHSRFPassthrough returnedPass = WHSRFPassthrough::create(conPeek(ret, #PassthroughInfo));
Useful Macros for WHS Mobile Device Development
Use #WHSWorkExecuteControlElements macro to access the specific control elements of the display container.
Example use of this macro:
container ret = this.getReturnContainer();
container lpCon = conPeek(ret, LP);
Boolean lpEnabled = conPeek(lpCon, #enabled);
In this example we checked if the license plate id control element is enabled in a specified display container (ret).
Use #WHSRF macro for control related purposes like getting a specific control or getting a WHSRFPassthrough element from the display container.
Example use of this macro:
container ret = this.getReturnContainer();
WHSLicensePlateId licensePlateId = this.getControlDataFromContainer(ret, #LicensePlateId);
In this example we get a WHSLicensePlateId control value from a specified display container.
We hope you found these WHS mobile device development tips useful, along with the rest of 1ClickFactory’s Dynamics 365 WHS mobile device development series. In case you missed it, part 1 of the blog series looks at how to replace or insert field values, part two covers how to skip a standard step and part three covers how to add a new list window. If you have any questions on Dynamics 365 WHS mobile device development don’t hesitate to contact us at services@1ClickFactory.com we look forward to hearing from you!