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

Announcements

News and Announcements icon
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 56

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,573 Moderator on at

    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,843 Moderator on at

    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
    56 on at

    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,573 Moderator on at

    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,843 Moderator on at

    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
    56 on at

    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,573 Moderator on at

    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
    56 on at

    Yes Mohit,

    If yes, then skip the standard

    If no, then call standard

    That I mentioned

  • Mohit Rampal Profile Picture
    12,573 Moderator on at

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

  • @rp@n Profile Picture
    56 on at

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 445 Super User 2026 Season 1

#2
Subra Profile Picture

Subra 407

#3
Martin Dráb Profile Picture

Martin Dráb 274 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans