Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Added a new method the IventItemPurchSetup table and it can't find it.

(0) ShareShare
ReportReport
Posted on by 527

So I created a code extension to the InventItemPurchSetup table and created a mirror method of finding the lowest Qty to use in the ReqTranspo form inside a grid control(gridreqpo) I have rebuilt and it still doesn't recognize it. Is there something else special I need for it to access this method that I am not knowing about?

pastedimage1678818927238v1.png

pastedimage1678818944658v2.png

  • KeithM Profile Picture
    KeithM 527 on at
    RE: Added a new method the IventItemPurchSetup table and it can't find it.

    Ok... so the method is working. I threw some errors in there to display data. But the data doesn't post on the grid. Is there something special I need to set on that field? It only gives me the error with the information when I click on it.

    pastedimage1678983334707v1.png

  • KeithM Profile Picture
    KeithM 527 on at
    RE: Added a new method the IventItemPurchSetup table and it can't find it.

    Updated accordingly, no errors, but no data coming back.  I am unable to debug until microsoft looks into the problem.

    I am getting a warning, "BPErrorLabelIsText: BP Rule: [BPErrorLabelIsText:BPErrorLabelIsText: 'ReqPO' is not a label ID."

    pastedimage1678981196692v2.png

    [ExtensionOf(formDataSourceStr(ReqTransPo,InventItemPurchSetup))]
    final class ReqTransPO_IPSetup_Extension
    {
        display public QtyLowest getMOQQty(InventItemPurchSetup  _inventItemPurchSetup)
        {
            InventItemPurchSetup    inventItemPurchSetupDefault;
            
            FormRun frun = this.formRun();
            FormDataSource fds = frun.dataSource("ReqPO");
    
            ReqPO reqpo = fds.cursor();
    
            if (reqpo.ItemId)
            {
                inventItemPurchSetupDefault = InventItemPurchSetup::findDefault(reqpo.ItemId);
    
                if (inventItemPurchSetupDefault.RecId != reqpo.RecId)
                {
                    return inventItemPurchSetupDefault.LowestQty;
                }
            }
    
           return 0;
        }

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Added a new method the IventItemPurchSetup table and it can't find it.

    To get the ReqPo cursor you can try like below.

    [ExtensionOf(formDataSourceStr(ReqTransPo,InventItemPurchSetup))]
    final class ReqTransPO_IPSetup_Extension
    {
        display public QtyLowest getMOQQty(InventItemPurchSetup  _InventItemPurchSetup)
        {
            //get the formrun
            FormRun frun = this.formRun();
            //get the form datasource
            FormDataSource fds = frun.datasource("ReqPo");
            //get the current buffer
            ReqPo reqPo = fds.cursor();
        }
    }

    Thanks,

    Girish S.

  • KeithM Profile Picture
    KeithM 527 on at
    RE: Added a new method the IventItemPurchSetup table and it can't find it.

    I was hoping to grab the current itemid from the row which is in reqpo.  I won't know the itemid in the inventitempurchsetup.

    pastedimage1678977730628v1.png

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Added a new method the IventItemPurchSetup table and it can't find it.

    You are adding a display method under InvenItemPurchSetup DataSource. But in the argument, you are passing ReqPO table buffer which is wrong. Thats the reason why you got the cast error. Change that to InventItemPurchSetup and check and also update the code accordingly.

    Thanks,

    Girish S.

  • KeithM Profile Picture
    KeithM 527 on at
    RE: Added a new method the IventItemPurchSetup table and it can't find it.

    So I adjusted it and added it the new call to the Datamethod on the field in the form and getting this error now.

    pastedimage1678975510886v1.png

    pastedimage1678975602022v2.png

    /// 
    /// class: ReqTransPO_IPSetup_Extension
    ///   method: getMOQQty
    ///      returns: Lowest Qty
    /// 
    [ExtensionOf(formDataSourceStr(ReqTransPo,InventItemPurchSetup))]
    final class ReqTransPO_IPSetup_Extension
    {
        display public QtyLowest getMOQQty(ReqPO  _reqpo)
        {
            InventItemPurchSetup    inventItemPurchSetupDefault;
    
            if (_reqpo.ItemId)
            {
                inventItemPurchSetupDefault = InventItemPurchSetup::findDefault(_reqpo.ItemId);
    
                if (inventItemPurchSetupDefault.RecId != _reqpo.RecId)
                {
                    return inventItemPurchSetupDefault.LowestQty;
                }
            }
    
            //if (_set)
            //{
            //this.LowestQty = 0;
            //}
    
            return 0;
        }
    }

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Added a new method the IventItemPurchSetup table and it can't find it.

    If the Datasource name doesn't work, try like below to get current cursor.

    [ExtensionOf(formDataSourceStr(ReqTransPo,InventItemPurchSetup))]
    final class ReqTransPO_IPSetup_Extension
    {
        display public QtyLowest getMOQQty(ReqPO  _reqpo)
        {
            InventItemPurchSetup    inventItemPurchSetupDefault;
            //get the formrun
            FormRun frun = this.formRun();
            //get the form datasource
            FormDataSource fds = frun.datasource("DataSourceName");
            //get the current buffer
            TableName name = fds.cursor();
            return 0;
        }
    }

    Thanks,

    Girish S.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Added a new method the IventItemPurchSetup table and it can't find it.

    Use DatasourceName.ItemId instead of this keyword.

    Thanks,

    Girish S.

  • KeithM Profile Picture
    KeithM 527 on at
    RE: Added a new method the IventItemPurchSetup table and it can't find it.

    Ok, so I think I got this added semi correctly.. I need to get the lowest qty from InventItemPurchSetup based on the ReqPo line itemid.  It doesn't like the this variable.

    [ExtensionOf(formDataSourceStr(ReqTransPo,InventItemPurchSetup))]
    final class ReqTransPO_IPSetup_Extension
    {
        display public QtyLowest getMOQQty(ReqPO  _reqpo)
        {
            InventItemPurchSetup    inventItemPurchSetupDefault;
    
            if (this.ItemId)
            {
                inventItemPurchSetupDefault = InventItemPurchSetup::findDefault(this.ItemId);
    
                if (inventItemPurchSetupDefault.RecId != this.RecId)
                {
                    return inventItemPurchSetupDefault.LowestQty;
                }
            }
    
            return 0;
        }
    }

    pastedimage1678971885978v1.png

    pastedimage1678972030344v2.png

  • KeithM Profile Picture
    KeithM 527 on at
    RE: Added a new method the IventItemPurchSetup table and it can't find it.

    pastedimage1678968982261v1.png

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