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

how can we give restriction while creation of item

(0) ShareShare
ReportReport
Posted on by 213

 hello everyone,

How to avoid Special charcter while creation of item .

regards,

pradeep

I have the same question (0)
  • pradeep M B Profile Picture
    213 on at
    RE: how can we give restriction while creation of item

    As per my requirement ,  the feild i want to make validation for itemid that is present in inventtable.,

    so i have wrriten code in validate writemethod

    regards,

    pradeep

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: how can we give restriction while creation of item

    I'm sorry but I can't help since you are not providing the information that was asked.

    I hope you find the solution. I won't be able to provide more assistance without the information.

  • pradeep M B Profile Picture
    213 on at
    RE: how can we give restriction while creation of item

    sir it s not working

    public boolean MyValidateItemId(ItemId id)

    {

       if (this.ItemId =="^[A-Z 0-9]+$")

       {

           return true;

       }

        return checkFailed("Wrong item id");

    }

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: how can we give restriction while creation of item

    Also, perhaps the validation itself works but your code that calls it is not working good.

    Please try this:

    Develop a new method in InventTable:

    public boolean MyValidateItemId(ItemId_id)
    {
        if (your regular expression check fails)
        {
            return checkFailed("Wrong item id");
        }
        return true;
    }

    In InventTable.validateWrite just call your new method:

    ret = ret && this.myValidateItemId(this.ItemId);

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: how can we give restriction while creation of item

    Sorry, we still can't help until you provide information that was asked..

    I also strongly recomment you to develop a new method "myCheckItemId" and call it from validateWrite. It would improve the readability of the code a lot.

    Also, validateWrite should not throw any errors.

    But now, could you please please let us know what item id you used to test? You said that in your job the validation works as expected, but in your InventTable it doesn't. We can't help you without knowing what value you used in testing.

  • pradeep M B Profile Picture
    213 on at
    RE: how can we give restriction while creation of item

     the above is code that i have wriiten in inventtable  method

    /// <summary>
    /// Determines whether data is valid and ready to be written.
    /// </summary>
    /// <param name="_skipProductVariantUnitConversionValidation">
    /// Boolean parameter to determine whether the product variant unit conversion validation must be skipped or not.
    /// </param>
    /// <returns>
    /// Returns true if data is valid; otherwise, false.
    /// </returns>
    public boolean validateWrite(boolean _skipProductVariantUnitConversionValidation = false)
    {
    MCRInventTable mcrInventTableLocal;
    boolean ret;
    RefRecId alternativeProductRecId;
    TextBuffer txt = new TextBuffer();
    txt.setText(this.ItemId);

    txt.regularExpressions(true);
    // <GEERU>
    #ISOCountryRegionCodes
    // </GEERU>

    ret = super();

    ret = ret && this.checkProjCategoryId();
    ret = ret && this.checkInventDimCombination();
    // <GEERU>
    if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoRU]))
    {
    if (this.isModelGroupSetup())
    {
    ret = ret && this.modelGroup().inventModelTypeSecCur_RU().validateWriteInventTable(this);
    }

    if(this.MarkupCode_RU && ! this.isMarkupCodeEnabled_RU() )
    {
    ret = checkFailed(strFmt("@GLS114518",
    enum2str(ItemType::Service)));
    }

    if (this.AlcoholProductionTypeId_RU)
    {
    if (! this.AlcoholStrength_RU)
    {
    ret = checkFailed(strFmt("@GLS103654", "@SYS4002922"));
    }

    if (! this.AlcoholManufacturerId_RU)
    {
    ret = checkFailed(strFmt("@GLS103654", "@SYS4002911"));
    }
    }

    if (this.AlcoholStrength_RU < 0 ||
    this.AlcoholStrength_RU > 100)
    {
    ret = checkFailed(strFmt("@GLS106085", "@SYS4002922"));
    }
    }
    // </GEERU>
    if (this.isModelGroupSetup())
    {
    ret = ret && this.modelGroup().inventModelType().validateWriteInventTable(this);
    }

    // <GBR>
    if (BrazilParameters::isEnabled())
    {
    if(this.isFormDataSource() && this.ItemType == ItemType::Service &&!this.TaxServiceCode_BR)
    {
    ret = checkFailed (strFmt("@SYS26332", fieldPName(InventTable, TaxServiceCode_BR)));
    }

    ret = ret && this.checkICMSOnService_BR();
    }
    // </GBR>

    alternativeProductRecId = InventTable::itemProduct(this.AltItemId);
    if (alternativeProductRecId)
    {
    ret = EcoResProductVariantDimValue::newProductVariantDim_InventColorId().checkExist(alternativeProductRecId, this.AltInventColorId) && ret;
    ret = EcoResProductVariantDimValue::newProductVariantDim_InventStyleId().checkExist(alternativeProductRecId, this.AltInventStyleId) && ret;
    ret = EcoResProductVariantDimValue::newProductVariantDim_InventSizeId().checkExist(alternativeProductRecId, this.AltInventSizeId) && ret;
    ret = EcoResProductVariantDimValue::newProductVariantDim_ConfigId().checkExist(alternativeProductRecId, this.AltConfigId) && ret;
    }
    else
    {
    if ( this.AltInventColorId
    || this.AltInventStyleId
    || this.AltInventSizeId
    || this.AltConfigId)
    {
    ret = checkFailed("@SYS308707");
    }
    }
    ret = EcoResProductVariantDimValue::newProductVariantDim_InventColorId().checkExist(this.Product, this.StandardInventColorId) && ret;
    ret = EcoResProductVariantDimValue::newProductVariantDim_InventStyleId().checkExist(this.Product, this.StandardInventStyleId) && ret;
    ret = EcoResProductVariantDimValue::newProductVariantDim_InventSizeId().checkExist(this.Product, this.StandardInventSizeId) && ret;
    ret = EcoResProductVariantDimValue::newProductVariantDim_ConfigId().checkExist(this.Product, this.StandardConfigId) && ret;

    // If an item's gross volume or weight is zero, warn the user. The user
    // should still be allowed to save the record.
    mcrInventTableLocal = this.mcrInventTable();
    if (MCRPackingBoxLogic::isPackingBoxLogicEnabled() &&
    mcrInventTableLocal.IsPackingBoxable &&
    (this.grossVolume() == 0 || this.grossWeight() == 0))
    {
    warning("@MCR24036");
    }

    if (ret)
    {
    ret = this.pdsValidateBestBeforeDays();
    if (ret && #PmfEnabled)
    {
    ret = this.pmfInventProductType().validatePmfProductType();
    }

    if (ret
    && (this.PmfProductType == PmfProductType::Formula
    || this.PmfProductType == PmfProductType::MainItem)
    && this.PmfYieldPct <= 0)
    {
    ret = checkFailed(strFmt("@PRO214",fieldLabelValue(tableNum(InventTable), fieldNum(InventTable, PmfYieldPct), "")));
    }

    if (ret
    && this.PmfProductType == PmfProductType::MainItem
    && this.orig().PmfProductType == PmfProductType::MainItem)
    {
    ret = this.checkPlanningItemCost();
    }
    }

    if (ret && this.PmfProductType != this.orig().PmfProductType
    && ReqItemTable::pmfExistItemCoverage(this.ItemId))
    {
    info("@PRO2628");
    }

    //
    //notify the user for the correct quality setup if this
    //is a potency item with value registered in quality order
    //
    this.pdsQualOrdWarning();

    // Display a warning if two vendor approval methods are enabled for a single released product.
    if (ret
    && this.orig().PdsVendorCheckItem != this.PdsVendorCheckItem
    && this.PdsVendorCheckItem != PdsVendorCheckItem::NoCheck
    && WHSInventEnabled::exist(this.ItemId)
    && WHSParameters::find().EnableVendFilters == NoYes::Yes)
    {
    warning("@WAX5492");
    }

    if (this.isFormDataSource()
    && this.dataSource().formRun().args().name() == formStr(EcoResProductDetailsExtended))
    {
    _skipProductVariantUnitConversionValidation = true;
    }

    if (ret
    && !_skipProductVariantUnitConversionValidation
    && this.isProductVariantUnitConversionEnabled())
    {
    ret = this.validateProductVariantUnitConversion();
    }

    // ret = super();

    //04/12

    txt.setText(this.ItemId);

    txt.regularExpressions(true);

    if (txt.find("^[A-Z 0-9]+$"))

    {

    ret = true;//info("string contains only numbers");

    }

    else

    {

    this.ItemId="";

    throw error(" Contain the Special Character");

    }


    return ret;
    }

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: how can we give restriction while creation of item

    Thanks. Could you share your table method and job code? Which one is the screenshot from? And the item ids that you are testing with?

    Otherwise it's impossible for us to find out why your job is working and your table method is not.

    And how are you calling your table method? You need to call it from validateWrite method of the table. Where are you calling it from?

  • pradeep M B Profile Picture
    213 on at
    RE: how can we give restriction while creation of item

     s sir,

    pastedimage1575446176112v1.png

     I have written code in jobs 

     it s working,but in table wise it s not working

    regards,

    pradeep

  • pradeep M B Profile Picture
    213 on at
    RE: how can we give restriction while creation of item

    i have wriiten code in invent table

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: how can we give restriction while creation of item

    I can only ask you to read my previous message again.

    These are the steps that you should take when developing such task:

    1) Define and test the regular expression outside AX

    2) Write logic in AX that validates a text value with the regular expression

    3) Link this validation in your process

    Could you let us know which steps you have already completed succesfully? If none, please start from 1 and proceed to next step when you have completed the previous one succesfully.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 844 User Group Leader

#2
André Arnaud de Calavon Profile Picture

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

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 553

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans