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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Populate Product Number on EcoResProductCreate Form

(0) ShareShare
ReportReport
Posted on by 20

I have a problem on this, i need to populate the product number on EcoResproductCreate form automatically, upon clicking new button.

7103.MicrosoftTeams_2D00_image.png

    /// 
    ///
    /// 
    /// 
    [PreHandlerFor(formStr(EcoResProductCreate), formMethodStr(EcoResProductCreate, init))]
    public static void EcoResProductCreate_Pre_init(XppPrePostArgs args)
    {
		str Chem;
        str Tin;
        str dimensionwork;
		//table
        EcoResProduct										 EcoResProduct;

		//objects
        tccpEventscenario6 tccpEventscenario6 = new tccpEventscenario6();
        EcoResProductNumberBuilder EcoResProductNumberBuilder = new EcoResProductNumberBuilder();

        //number seq for chemical
        Chem = tccpEventscenario6.chemicalSequence();
        //number seq for chemical
        Tin = tccpEventscenario6.tinCanSequence();
        dimensionwork = tccpEventscenario6.getWorkerFinDimension();
        if (dimensionwork == '069')
        {
            
            //Chemical
            //number seq for chemical
            Chem = tccpEventscenario6.chemicalSequence();
            info(Chem);
            EcoResProductNumberBuilder.parmProductNumber(Tin);
            EcoResProduct.DisplayProductNumber = Tin;
           

        }
        else if (dimensionwork == '202')
        {

            //TinCan
            //number seq for chemical
            Tin = tccpEventscenario6.tinCanSequence();
            info(Tin);
            EcoResProductNumberBuilder.parmProductNumber(Tin);
            EcoResProduct.DisplayProductNumber = Tin;


        }
    }

    public str chemicalSequence()
    {
        NumberSeq numSeq;
        tccpChemicalPaint id;
        ttsbegin;
        numSeq = NumberSeq::newGetNum(tccpNumSeqClass::tccpChemicalPaint());
        id = numSeq.num();
        ttscommit;
        return id;
      
    }

    public str tinCanSequence()
    {
        NumberSeq numSeq;
        tccpTinCan id2;
        ttsbegin;
        numSeq = NumberSeq::newGetNum(tccpNumSeqClass_1::tccpTinCan());
        id2 = numSeq.num();
        ttscommit;
        return id2;
 
    }

    public str getWorkerFinDimension()
    {
        HcmEmployment                           hcmEmployment;
        DimensionAttributeValueSetItem          setItem;
        DimensionAttributeValue                 dimAttrValue;
        DimensionAttribute                      dimAttribute;
        ;
        
        dimAttribute = DimensionAttribute::findByName('BusinessUnit');
        
        ttsbegin;

        select firstonly * from hcmEmployment
                where hcmEmployment.Worker == HcmWorkerLookup::currentWorker()
                join RecId, DisplayValue from setItem where setItem.DimensionAttributeValueSet == hcmEmployment.DefaultDimension join dimAttrValue
                 where dimAttrValue.RecId == setItem.DimensionAttributeValue && dimAttrValue.DimensionAttribute ==	dimAttribute.RecId && dimAttrValue.IsDeleted == false;
        
        // info(strFmt("Employee = %1 %2 = %3 ",HcmWorker::find(hcmEmployment.Worker).PersonnelNumber, dimAttribute.Name, setItem.DisplayValue));
        ttscommit;

        return setItem.DisplayValue;
    }

I have the same question (0)
  • Martin Dráb Profile Picture
    238,789 Most Valuable Professional on at

    This is a duplicate - we're already discussing the same thing in Populate the Item Number field on Form EcoResProductCreate.

    Also, please post threads about F&O in F&O forums, not in the AX forum. Let me move this thread too...

  • Coders Profile Picture
    20 on at

    codersss.PNG

    I have his error when i click okay. i have his code in X :

     public void init()
        {
            next init();
            
            NumberSeq numSeq;
            str dimensionworker;
            tccpEventscenario6 tccpEventscenario6 = new tccpEventscenario6();
            dimensionworker = tccpEventscenario6.getWorkerFinDimension();
            if(dimensionworker == '069')
            {
                ttsBegin;
                numSeq = NumberSeq::newGetNum(tccpNumSeqClass::tccpChemicalPaint());
                Identification_ProductNumber.text(numSeq.num());
    
                ttsCommit;
            }
    		else if (dimensionworker == '202')
            {
                ttsBegin;
                numSeq = NumberSeq::newGetNum(tccpNumSeqClass_1::tccpTinCan());
                Identification_ProductNumber.text(numSeq.num());
               
                ttsCommit;
    		}
        }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 386

#3
Adis Profile Picture

Adis 259 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans