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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Take Enum Field Data From PurchEditLines to VendPackingSlipJour

(2) ShareShare
ReportReport
Posted on by 86

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?

Capture.PNG
I have the same question (0)
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    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

  • Ahmer Profile Picture
    86 on at
        [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
    9,039 Super User 2025 Season 2 on at
     
    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
    86 on at
    Tried this approach ,still the same problem
  • Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
     
    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

  • Verified answer
    Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at
    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().
  • Ahmer Profile Picture
    86 on at
    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
    Ahmer Profile Picture
    86 on at
    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;
            }
        }
    }
     

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…

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 669 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 384 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans