Skip to main content

Notifications

Community site session details

Community site session details

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

Take Enum Field Data From PurchEditLines to VendPackingSlipJour

(1) ShareShare
ReportReport
Posted on by 78

I added three custom rating enums (VendorRating, TimeRating, QualityRating) on the PurchEditLines(PurchParmTable datasource) form using a base enum ReceiveRating (values 1–5). Users select these ratings before posting a product receipt.

 

I want to save these values to the VendPackingSlipJour like after the user generated the receipt and after posting, source is VendPackingSlipJour Table in the VendPackingSlipJournal Form. I tried select for update matching with purchid on both datasource in the OK button handler of PurchEditLines, but it fails—no record found, possibly because VendPackingSlipJour isn't created yet.

 

How can I achieve this?

  • Verified answer
    Ahmer Profile Picture
    78 on at
    Take Enum Field Data From PurchEditLines to VendPackingSlipJour
    Hi Martin, I extended the class method and found the solution just by referring fields to the buffers , really appreciate your suggestion, thanks.
     
    [ExtensionOf(classStr(PurchPackingSlipJournalCreate))]
    final class PurchPackingSlipJournalCreate_Evs_PurchaseOrderRating1_Extension
    {
        public void initHeader()
        {
            next initHeader();
    
            if(purchParmTable.RecId)
            {
                vendPackingSlipJour.VendorRating = purchParmTable.VendorRating;
                vendPackingSlipJour.TimeRating = purchParmTable.TimeRating;
                vendPackingSlipJour.OrderRating = purchParmTable.QualityRating;
            }
        }
    }
     
  • Ahmer Profile Picture
    78 on at
    Take Enum Field Data From PurchEditLines to VendPackingSlipJour
    Hi Martin, 

    Yes I was thinking the same but how can I add these fields by the initheader do coc, extend that method or what approach should I take?
  • Verified answer
    Martin Dráb Profile Picture
    234,037 Most Valuable Professional on at
    Take Enum Field Data From PurchEditLines to VendPackingSlipJour
    The idea of doing it on the OK button is really bad, for quite a few reasons. For instance, the posting may be executed asynchronously, therefore your code would run before the posting. Another problem of your code is the assumption that just a single order is being posted, which doesn't have to be the case.
     
    The correct place for this logic is PurchPackingSlipJournalCreate.initHeader().
  • Waed Ayyad Profile Picture
    8,550 Super User 2025 Season 1 on at
    Take Enum Field Data From PurchEditLines to VendPackingSlipJour
     
    Did you trace the code? Try it and check the values, in order to know where is the issue.
     
    Also try to use COC instead of event handler:
     
    [ExtensionOf(formControlStr(PurchEditLines, Ok))]
    final class XXPurchEditLinese_FormControl_Extension
    {
    
    public void clicked()
    
    {
      next clicked();
      Info("Ok button clicked on generating receipt");
            FormControl formButtonControl = any2Object(this) as FormControl;
            FormRun formRun = formButtonControl.formRun();
            FormDataSource PurchParmtable_ds = formRun.dataSource(formDataSourceStr(PurchEditLines,PurchParmTable)) as FormDataSource;
            PurchParmTable _PurchParmTable  = PurchParmtable_ds.cursor();
           
           // SysDictEnum SysDictEnum = new SysDictEnum(enumNum(ReceiveRating));
            VendPackingSlipJour _vendpackingslipjour;
            Info(strFmt(" Purch id check: %1",_PurchParmTable.PurchId));
    
           
            ttsbegin;
    
            select forupdate _vendpackingslipjour where 
               _vendpackingslipjour.PurchId == _PurchParmTable.PurchId;
    
             if(vendpackingslipjour.Recid > 0)
             {
                _vendpackingslipjour.VendorRating = _PurchParmTable.VendorRating;
                _vendpackingslipjour.TimeRating = _PurchParmTable.TimeRating;
                _vendpackingslipjour.OrderRating = _PurchParmTable.QualityRating;
                _vendpackingslipjour.update();
             }
            
            ttscommit;
    
            Info("Vendpackingslipjour updated");
    
    }

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

  • Ahmer Profile Picture
    78 on at
    Take Enum Field Data From PurchEditLines to VendPackingSlipJour
    Tried this approach ,still the same problem
  • Suggested answer
    Waed Ayyad Profile Picture
    8,550 Super User 2025 Season 1 on at
    Take Enum Field Data From PurchEditLines to VendPackingSlipJour
     
    Check the following code.
       [FormControlEventHandler(formControlStr(PurchEditLines, OK), FormControlEventType::Clicked)]
        public static void OK_OnClicked(FormControl sender, FormControlEventArgs e)
        {
            Info("Ok button clicked on generating receipt");
            FormRun formRun = sender.formRun();
            FormDataSource PurchParmtable_ds = formRun.dataSource(formDataSourceStr(PurchEditLines,PurchParmTable)) as FormDataSource;
            PurchParmTable _PurchParmTable  = PurchParmtable_ds.cursor();
           
           // SysDictEnum SysDictEnum = new SysDictEnum(enumNum(ReceiveRating));
            VendPackingSlipJour _vendpackingslipjour;
            Info(strFmt(" Purch id check: %1",_PurchParmTable.PurchId));
    
           
            ttsbegin;
    
            select forupdate _vendpackingslipjour where 
               _vendpackingslipjour.PurchId == _PurchParmTable.PurchId;
    
             if(vendpackingslipjour.Recid > 0)
             {
                _vendpackingslipjour.VendorRating = _PurchParmTable.VendorRating;
                _vendpackingslipjour.TimeRating = _PurchParmTable.TimeRating;
                _vendpackingslipjour.OrderRating = _PurchParmTable.QualityRating;
                _vendpackingslipjour.update();
             }
            
            ttscommit;
    
            Info("Vendpackingslipjour updated");
        }
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

  • Ahmer Profile Picture
    78 on at
    Take Enum Field Data From PurchEditLines to VendPackingSlipJour
        [FormControlEventHandler(formControlStr(PurchEditLines, OK), FormControlEventType::Clicked)]
        public static void OK_OnClicked(FormControl sender, FormControlEventArgs e)
        {
            Info("Ok button clicked on generating receipt");
            FormRun formRun = sender.formRun();
            FormDataSource PurchParmtable_ds = formRun.dataSource("PurchParmTable");
            PurchParmTable _PurchParmTable = PurchParmtable_ds.cursor();
            SysDictEnum SysDictEnum = new SysDictEnum(enumNum(ReceiveRating));
            VendPackingSlipJour _vendpackingslipjour;
            Info(strFmt(" Purch id check: %1",_PurchParmTable.PurchId));

            //Info(str
            ttsbegin;
            select forupdate _vendpackingslipjour where _vendpackingslipjour.PurchId == _PurchParmTable.PurchId;
            _vendpackingslipjour.VendorRating = _PurchParmTable.VendorRating;
            _vendpackingslipjour.TimeRating = _PurchParmTable.TimeRating;
            _vendpackingslipjour.OrderRating = _PurchParmTable.QualityRating;
            _vendpackingslipjour.update();
            Info("Vendpackingslipjour updated");
            ttscommit;
        }
  • Suggested answer
    Waed Ayyad Profile Picture
    8,550 Super User 2025 Season 1 on at
    Take Enum Field Data From PurchEditLines to VendPackingSlipJour
    Hi,
     
    Can you share your code? Also did you try to use the COC instead of Event handler?
    Did you trace the code?
     
     
     
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Product updates

Dynamics 365 release plans