Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

like to skip the method on if condition

(0) ShareShare
ReportReport
Posted on by

Hi team,

Class - InventMovementQuantityValidator

private str buildMinQtyDialogStr(Qty _lowestQty, Qty _transQty)
    {
        str minQtyDialogStr = strFmt("@SCM:MinimumAllowedQuantityMessage", _transQty, _lowestQty);

        if (lowerLimitErrorCorrectionMethod == InventMovementQuantityErrorCorrectionMethod::PromptUser)
        {
            minQtyDialogStr  = strFmt("@SCM:ReplaceQuantityMessage", _lowestQty);
        }

        return minQtyDialogStr;
    }

I like to put if condtion on method buildMinQtyDialogStr

If the parameter is set to YES then I like to skip above method else it should work as standard behaviour.

Kindly let me know how will approch this.

thanks!

  • @rp@n Profile Picture
    @rp@n on at
    RE: like to skip the method on if condition

    Hi Mohit,

    I go through the code and found you have added few new piece of code.

    Kindly let me know what is does? and why it is required?

    protected Qty resolveLowerLimitConflict(Qty _requestedQuantity, UnitOfMeasureSymbol _requestedUnitId)
    {
    boolean isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabledLocal = isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled;

    if (isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabledLocal)
    {
    isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled = false;
    }
    next resolveLowerLimitConflict(_requestedQuantity, _requestedUnitId);

    if (isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabledLocal && !isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled)
    {
    isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled = isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabledLocal;
    }

    Qty acceptableQuantity = _requestedQuantity;
    InventMovementQuantityValidatorDialogsContext dialogContext = InventMovementQuantityValidatorDialogsContext::current();
    boolean skipLowerLimitConflictCheck = isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled && dialogContext && dialogContext.parmIsLowerLimitDialogPrompted();

    Kindly elaborate pls

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: like to skip the method on if condition

    If I understood you requirement correctly, Then it should be straight forward, the code I shared will by pass the standard code always.. That's why I copied all standard code of resolveLowerLimitConflict method after next statement. now, you can add one more condition to check the parameter. Check my code and see I have written YourCustomParameter, you can replace it with PurchParameters (your field).

    Let me know if still not clear.

  • @rp@n Profile Picture
    @rp@n on at
    RE: like to skip the method on if condition

    PurchParameters

    We can do like this.

    purchParameters = PurchParametes::find();

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: like to skip the method on if condition

    In which table is your parameter? Can you access it in resolveLowerLimitConflict or buildMinQtyDialogStr method?

  • @rp@n Profile Picture
    @rp@n on at
    RE: like to skip the method on if condition

    Yes Mohit,

    If yes, then skip the standard

    If no, then call standard

    That I mentioned

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: like to skip the method on if condition

    You mentioned that your requirement is 'If the parameter is set to YES then I like to skip above method else it should work as standard behaviour.' Anyways, I have provided your a way to manipulate standard code, you can try it for changing quantity.

  • @rp@n Profile Picture
    @rp@n on at
    RE: like to skip the method on if condition

    My requirement is to

    If the parameter is set to Yes then while creating a PO add lines the qty should be always 0. User can later modify it .

    If parameter is set to NO, then the qty should work like standard behaviour.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: like to skip the method on if condition

    The method "buildMinQtyDialogStr" is called inside "resolveLowerLimitConflict".

    //see whether you can bypass this if condition. Check in which method lowestQtyRequestedUnit or
    _requestedQantity value is assigned. Try to extend that method and write COC to change the value
    according to the parameter.
    if (lowestQtyRequestedUnit > _requestedQuantity)
    {
        str minQtyDialogStr = this.buildMinQtyDialogStr(lowestQtyRequestedUnit, _requestedQuantity);
    
        if (this.mustCorrectQty(lowerLimitErrorCorrectionMethod, minQtyDialogStr))
        {
            acceptableQuantity = lowestQtyRequestedUnit;
        }
    }

    I am not familiar with this functionality but you need to check while byepassing it does effects the standard functionality.

    If none of them works you need to duplicate that class with your custom code and call that class where it is called.

    Thanks,

    Girish S.

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: like to skip the method on if condition

    You can manipulate isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled value to skip the standard method. Create extension class for InventMovementQuantityValidator and try adding below code

    protected Qty resolveLowerLimitConflict(Qty _requestedQuantity, UnitOfMeasureSymbol _requestedUnitId)
    {
        boolean isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabledLocal = isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled;
        
        if (isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabledLocal)
        {
            isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled = false;
        }
        next resolveLowerLimitConflict(_requestedQuantity, _requestedUnitId); 
        
        if (isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabledLocal && !isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled)
        {
            isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled = isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabledLocal;
        }
        
        Qty acceptableQuantity = _requestedQuantity;
        InventMovementQuantityValidatorDialogsContext dialogContext = InventMovementQuantityValidatorDialogsContext::current();
        boolean skipLowerLimitConflictCheck = isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled && dialogContext && dialogContext.parmIsLowerLimitDialogPrompted();
        
        if (this.isCheckNeeded(lowerLimitErrorCorrectionMethod) && !skipLowerLimitConflictCheck)
        {
            Qty lowestQtyModuleUnit = inventItemOrderSetupMap.lowestQty();
            if (lowestQtyModuleUnit != 0)
            {
                Qty lowestQtyRequestedUnit = this.convertQty(lowestQtyModuleUnit, this.moduleUnitId(), _requestedUnitId);
                lowestQtyRequestedUnit = decRound(lowestQtyRequestedUnit, UnitOfMeasure::unitOfMeasureDecimalPrecision(UnitOfMeasure::unitOfMeasureIdBySymbol(_requestedUnitId)));
            
                //Add your parameter to skip this.buildMinQtyDialogStr
                if (lowestQtyRequestedUnit > _requestedQuantity)
                {
                    if (YourCustomParameter)
                    {
                        str minQtyDialogStr = this.buildMinQtyDialogStr(lowestQtyRequestedUnit, _requestedQuantity);
                    }
                    
                    if (this.mustCorrectQty(lowerLimitErrorCorrectionMethod, minQtyDialogStr))
                    {
                        acceptableQuantity = lowestQtyRequestedUnit;
                    }
                    
                    if (dialogContext && isInventMovementQuantityValidatorNoRepeatDialogsFlightEnabled)
                    {
                        dialogContext.parmIsLowerLimitDialogPrompted(true);
                    }
                }
            }
        }
        
        return acceptableQuantity;
    }

  • @rp@n Profile Picture
    @rp@n on at
    RE: like to skip the method on if condition

    Hi Mohit and Girish,

    Both messages need to skip while adding new line in PO. if the parameter is set to YES.

    else 

    It should work as it is.

    As you said, COC not supported private method then how to skip both messages?

    Kindly guide me pls

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans