Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Method 'parmPurchTable' is protected and can be called only from methods in 'PurchCancel' - D365FO

(0) ShareShare
ReportReport
Posted on by 1,376
Hi All,
 
We have a requirement where the PO's are coming from third party application and that needs to be cancelled based on some conditions in D365FO.
 
Trying the below code from one of the blog for testing purpose but getting the below error;
class RunnableClasstst
{
    /// <summary>
    /// Class entry point. The system will call this method when a designated menu 
    /// is selected or when execution starts and this class is set as the startup class.
    /// </summary>
    /// <param name = /_args/>The specified arguments.</param>
    public static void main(Args _args)
    {
        PurchTable          pt;
        PurchFormLetter     Purch;
        PurchTable          PurchTable;
        PurchCancel         PurchCancel;

        select pt where pt.PurchId == 'PO-006671';
        PurchCancel = PurchCancel::construct(); 
        PurchCancel.parmPurchTable(pt);
        PurchCancel.run();

        
    }
}
 
error:
 
Method 'parmPurchTable' is protected and can be called only from methods in 'PurchCancel', or from classes or tables that derive from 'PurchCancel'
 
 
 
 
Please advice how we can resolve this error as we need to create a batch job to get the PO's from third party application and cancelled the PO's based on some conditions every week.
 
Regards,
Akbar
 
  • Akbar Pasha Profile Picture
    Akbar Pasha 1,376 on at
    Method 'parmPurchTable' is protected and can be called only from methods in 'PurchCancel' - D365FO
    Thank you very much Martin, the code which you have provided worked for us.
     
    Regards,
    Akbar
  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    Method 'parmPurchTable' is protected and can be called only from methods in 'PurchCancel' - D365FO
    You can create a new class extending PurchCancel class and use that class. You can call that parm method in the extended class.
     
    Thanks,
    Girish S.
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,994 Most Valuable Professional on at
    Method 'parmPurchTable' is protected and can be called only from methods in 'PurchCancel' - D365FO
    The error message is right - you need to call the method from PurchCancel class. You can either use an existing public method (if available), create a class inheriting from PurchCancel and do it there or add a public method through an extension.
     
    Try the first approach:
    Args args = new Args();
    args.record(PurchTable::find('PO-006671'));
    PurchCancel::main(args);

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…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,234 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,994 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans