Skip to main content

Notifications

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;
    }

  • Coders Profile Picture
    Coders 20 on at
    RE: Populate Product Number on EcoResProductCreate Form

    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;
    		}
        }

  • Martin Dráb Profile Picture
    Martin Dráb 230,846 Most Valuable Professional on at
    RE: Populate Product Number on EcoResProductCreate Form

    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...

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,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans