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

Notifications

Announcements

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

  • Martin Dráb Profile Picture
    238,320 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...

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

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 867 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 348 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans