Action button - Process Guide Framework

WHS Mobile Device Development – Process Guide Framework
Adding an action button to the existing process.
Action class:
#VKProcessGuideSort
/// <summary>
/// An action class for the <c>Back</c> button.
/// </summary>
[ProcessGuideActionName(#VKWHSProcessGuideSortPositionChangeItemAction)]
public class VKWHSProcessGuideSortPositionChangeItemAction extends ProcessGuideAction
{
    public str label()
    {
        return "Change item";
    }

    public void doExecute()
    {
        step.vkExecuteChangeItemAction();
    }

}
#VKProcessGuideSort macros
// action name
#define.VKWHSProcessGuideSortPositionChangeItemAction('VKWHSProcessGuideSortPositionChangeItemAction')

// internal class names, where even classStr function gives warning, that it will be converted into error in future
#define.WHSProcessGuidePopulateLPAndSortPositionPageBuilder('WHSProcessGuidePopulateLPAndSortPositionPageBuilder')
#define.WHSProcessGuidePopulateLPAndSortPositionStep('WHSProcessGuidePopulateLPAndSortPositionStep')
ProcessGuideStep extension. The extension should be done on the actual step class, but in my case WHSProcessGuidePopulateLPAndSortPositionStep is internal and it is the only possible way
/// <summary>
/// CoC for ProcessGuideStep class
/// </summary>
[ExtensionOf(classstr(ProcessGuideStep))]
final class VKProcessGuideStepCls_Extension
{
    #VKProcessGuideSort

    /// <summary>
    /// Method to execute change item action
    /// </summary>
    public final void vkExecuteChangeItemAction()
    {
        if (ClassId2Name(classIdGet(this)) == #WHSProcessGuidePopulateLPAndSortPositionStep)
        {
            WhsrfPassthrough pass = controller.parmSessionState().parmPass();

            if (pass.exists(ProcessGuideDataTypeNames::ItemId))
            {
                pass.remove(ProcessGuideDataTypeNames::ItemId);
            }
            if (pass.exists(ProcessGuideDataTypeNames::ColorId))
            {
                pass.remove(ProcessGuideDataTypeNames::ColorId);
            }
            if (pass.exists(ProcessGuideDataTypeNames::SizeId))
            {
                pass.remove(ProcessGuideDataTypeNames::SizeId);
            }
            if (pass.exists(ProcessGuideDataTypeNames::StyleId))
            {
                pass.remove(ProcessGuideDataTypeNames::StyleId);
            }
            if (pass.exists(ProcessGuideDataTypeNames::SerialId))
            {
                pass.remove(ProcessGuideDataTypeNames::SerialId);
            }
            if (pass.exists(ProcessGuideDataTypeNames::BatchId))
            {
                pass.remove(ProcessGuideDataTypeNames::BatchId);
            }
            this.markAsCompleted();
        }
    }

}
Adding an action button to the page. It should be an extension of the PageBuilder class, however in my case WHSProcessGuidePopulateLPAndSortPositionPageBuilder class is internal and it the only possible way to implement it.
/// <summary>
/// CoC for ProcessGuidePageBuilder class
/// </summary>
[ExtensionOf(classstr(ProcessGuidePageBuilder))]
final class VKProcessGuidePageBuilderCls_Extension
{
    #ProcessGuideActionNames
    #VKProcessGuideSort

    /// <summary>
    /// Adds the controls to the page.
    /// </summary>
    /// <param name = "_page">
    /// The <c>ProcessGuidePage</c> class to which the controls should be added.
    /// </param>
    protected void addControls(ProcessGuidePage _page)
    {
        next addControls(_page);

        if (ClassId2Name(classIdGet(this)) == #WHSProcessGuidePopulateLPAndSortPositionPageBuilder)
        {
            _page.addButton(step.createAction(#VKWHSProcessGuideSortPositionChangeItemAction));
        }
    }
}



 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units and "buy me a coffee" link.
Join us.

Blog Tags