web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

like to skip the method on if condition

(0) ShareShare
ReportReport
Posted on by 30

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!

I have the same question (0)
  • Mohit Rampal Profile Picture
    12,563 Moderator on at
    RE: like to skip the method on if condition

    Hi, Its a private method, you can't extend it. Right click on this method and find references to check where its used. Probably there you can skip it.

  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: like to skip the method on if condition

    As Mohit mentioned you cannot write COC for private method.

    But you can do find reference on lowerLimitErrorCorrectionMethod buffer and see where the value is assigned.

    If you find out that you can see whether there is any possibility to write COC to change the buffer value based on the parameter value.

    Thanks,

    Girish S.

  • @rp@n Profile Picture
    30 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

  • Suggested answer
    Mohit Rampal Profile Picture
    12,563 Moderator 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;
    }

  • GirishS Profile Picture
    27,825 Moderator 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.

  • @rp@n Profile Picture
    30 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.

  • Mohit Rampal Profile Picture
    12,563 Moderator 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
    30 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
    12,563 Moderator 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
    30 on at
    RE: like to skip the method on if condition

    PurchParameters

    We can do like this.

    purchParameters = PurchParametes::find();

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 696 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 569

#3
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans