Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Use this event to

...

Handle business logic for the custom RegistrationType.

...

Use this event to

Excerpt

Handle custom Unplanned Functions business logic.


This event is triggered when

  • Header has been accepted
  • Steps has been collected


The request is provided as input tables and be accessed/iterated.

Including :

  • Header Fields values
  • Collected Steps values
  • Current Registrations 
    (if your Unplanned is called from a Planned Functions e.g. Picked Order lines)


Supersedes OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml


Template 01 - Subscribe only to mandatory parameters

    // [Template] 01 - Subscribe only to mandatory parameters (excluded _CurrentRegistration, _SuccessMessage and _RegistrationTypeTracking)
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType''', true, true)]
    local procedure OnPostAdhocRegistrationOnCustomRegistrationType(_RegistrationType: Textvar _RequestElementRequestValuesRecord "MOB NS Request Element"; var _IsHandled: Boolean)
    begin
        if _RegistrationType = 'MyCustomRegistrationType' then begin      // Replace constant 'MyCustomRegistrationType' with your own RegistrationType
            if _IsHandled then
                exit;
            
            // Handle _RequestElement hereRequestValues here
            // ....

            _IsHandled := true;
        end;
    end;


Template 02 - Subscribe to all parameters

    // [Template] 02 - Subscribe to all parameters
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType''', true, true)]
    local procedure T02OnPostAdhocRegistrationOnCustomRegistrationType(_MessageId: Guid_RegistrationType: Textvar _RequestElementRequestValuesRecord "MOB NS Request Element"; var _CurrentRegistrationCurrentRegistrationsRecord "MOB WMS Registration"; var _SuccessMessage: Textvar _RegistrationTypeTracking: Text[200]var _IsHandled: Boolean)
    var
        MobDocQueue: Record "MOB Document Queue";
    begin
        if _RegistrationType = 'MyCustomRegistrationType' then begin      // Replace constant 'MyCustomRegistrationType' with your own RegistrationType
            if _IsHandled then
                exit;


                        // Handle _RequestElement hereRequestValues here
            // ....

            // Optional: Read MobDocQueue to i.e. read device id
            MobDocQueue.GetByGuid(_MessageId, MobDocQueue);

            _SuccessMessage := 'My custom success message';
            _RegistrationTypeTracking := 'My custom description for the document queue (column RegistationType';
            _IsHandled := true;
        end;
    end;


Example (1) - Iteration of _

...

RequestValues and _

...

CurrentRegistrations

    // [Example] 01 - Sample iteration of _RequestElement and RequestValues and _CurrentegistrationCurrentegistrations
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType''', true, true)]
    local procedure Ex01OnPostAdhocRegistrationOnCustomRegistrationType(_RegistrationType: Textvar _RequestElementRequestValuesRecord "MOB NS Request Element"; var _CurrentRegistrationCurrentRegistrationsRecord "MOB WMS Registration"; var _IsHandled: Boolean)
    begin
        if _RegistrationType = 'MyCustomRegistrationType' then begin      // Replace constant 'MyCustomRegistrationType' with your own RegistrationType
            if _IsHandled then
                exit;

            // Sample iteration of requestData (excluding <Order>-element)
            if _RequestElementRequestValues.FindFirst() then
                repeat
                until _RequestElementRequestValues.Next() 0;

            // Sample iteration of "current" registrations from <Order>-element (snapshot of unposted Registrations as they look right now when an adhoc registration is triggered)
            // CurrentRegistration's is included only if attribute sendRegistrationData="Order"|"OrderLine" was used from application.cfg
            if _CurrentRegistrationCurrentRegistrations.FindFirst() then
                repeat
                until _CurrentRegistrationCurrentRegistrations.Next() 0;

            _IsHandled := true;
        end;
    end;


Example (2) - Read values from _

...

RequestValues (and, subscribing only to

...

some parameters

...

(excluded _

...

CurrentRegistrations and _

...

SuccessMessage)

    // [Example] 02 - Read values from _RequestElement RequestValues - and: subscribing only to some parameters (excluded _CurrentRegistration and CurrentRegistrations and _SuccessMessage)
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType''', true, true)]
    local procedure Ex02OnPostAdhocRegistrationOnCustomRegistrationType(_RegistrationType: Textvar _RequestElementRequestValuesRecord "MOB NS Request Element"; var _RegistrationTypeTracking: Text[200]var _IsHandled: Boolean)
    begin
        if (_RegistrationType = 'MyCustomUnplannedProdConsumption') and (not _IsHandledthen begin
            _RegistrationTypeTracking := PostUnplannedProdConsumption(_RegistrationType, _RequestElementRequestValues);
            _IsHandled := true;             true;

            // No SuccessMessage is returned -> default message is automatically added to the XmlResponse
        end;
    end;

    local procedure PostUnplannedProdConsumption(_RegistrationType: Textvar _RequestElementRequestValuesRecord "MOB NS Request Element"_RegistrationTypeTracking: Text[200]
    var
        MobWmsToolbox: Codeunit "MOB WMS Toolbox";
        ProdOrderNo: Code[20];
        ProdOrderLineNo: Integer;
        ItemNo: Code[20];
        VariantCode: Code[2010];
        UnitOfMeasureCode: Code[10];
        Qty: Decimal;
    begin

                // Parse values from Request
        ProdOrderNo := _RequestElementRequestValues.GetValue('ProdOrder').SubString(1, MaxStrLen(ProdOrderNo));
        ProdOrderLineNo := MobWmsToolbox.Text2Int(_RequestElementRequestValues.GetValueGetValueAsInteger('ProdOrderLineNo', true));
        ItemNo := _RequestElementRequestValues.GetValue('Item').Substring(1, MaxStrLen(ItemNo));
        VariantCode := _RequestElementRequestValues.GetValue('Variant', false).Substring(1, MaxStrLen(VariantCode));    // GetValue(.., false) = no error if not exists
        UnitOfMeasureCode := _RequestElementRequestValues.GetValue('UoM', false).Substring(1, MaxStrLen(UnitOfMeasureCode));
        Qty := MobWmsToolbox.Text2Int(_RequestElementRequestValues.GetValueGetValueAsDecimal('Qty'));

        // 
        // Find the Prod. Order Line
        // 
        // ... not implemented in this example

        // 
        // Create Item Journal Line and post  
        //
        // ... not implemented in this example

        // Return information about this request/response to be displayed at the Mobile Document Queue
        _RegistrationTypeTracking := CopyStr(StrSubstNo('%1: ProdOrder=%2; ProdOrderLineNo=%3', _RegistrationType%1 - %2 - %3 - %4 - %5 - %6', ProdOrderNo, ProdOrderLineNo), ItemNo,  1VariantCode,  MaxStrLenFormat(_RegistrationTypeTrackingQty), UnitOfMeasureCode);
    end;

 

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
sorttitle
titleMore examples
excerptTypesimple
cqllabel = "bc" and label = "onpostadhocregistrationoncustomregistrationtype" and label = "example"


Version History

Version

Changes

MOB5.15Introduced
MOB5.17New parameter _MessageId
MOB5.24New helper methods for GetValueAsInteger and GetValueAsDecimal