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

Community site session details

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

Update table on insert when no insert method

(0) ShareShare
ReportReport
Posted on by 313

Hello,

This is in continuation of post
Correct COC sequence - Dynamics 365 Finance Forum Community Forum
but I wanted this to be a separate post.

When a planned order is approved, then we want a log of it completed.  The table exists but only has the following methods show

initFromKanban

initFromReqTrans

exist

find

shouldThrowExceptionOnZeroDelete

In AX2012 our code was put inside the class ReqTransPoMarkFirm in the method createReqTransFirmLog

protected void createReqTransFirmLog(
        ReqTrans            _reqTrans,
        InventTransType     _inventTransType,
        InventTransRefId    _inventTransRefId,
        InventTransId       _inventTransId)
    {
        ReqTransFirmLog reqTransFirmLog;

        if (!_reqTrans.IsDerivedDirectly)
        {
            reqTransFirmLog = this.initReqTransFirmLog();
            reqTransFirmLog.initFromReqTrans(_reqTrans);

            reqTransFirmLog.InventTransType     = _inventTransType;
            reqTransFirmLog.InventTransRefId    = _inventTransRefId;
            reqTransFirmLog.InventTransId       = _inventTransId;

            reqTransFirmLog.insert();
        }
    }

basically it's the same as the post above, where I would want to add some lines in the if statement updating some more records in that table.

Since I know now that is not best practice, or even possible, I thought I would try the same as before and extend the Update method.  But since this one is calling the insert method, I thought I would extend that.  

But I don't see it in the methods of that table.  Do I just call it anyway?  How will I reference what record I'm dealing with at that time?

I hope this makes sense. Please help.

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Update table on insert when no insert method

    You can use Chain of Command on insert method of a table even when it's not overridden on that particular table. You reference the record by "this" keyword.

  • Andrew Huisman Profile Picture
    313 on at
    RE: Update table on insert when no insert method

    Thanks again!  Here is what I did and it's working great

    [ExtensionOf(tableStr(ReqTransFirmLog))]
    final class ReqTranFirmLogTableTCI_Extension
    {
        public void insert()
        {
            ReqPO               reqPO;
            ReqTrans            reqTrans;
            InventTransOrigin   inventTransOrigin;
    
            select reqPO
                join reqTrans
                where reqPO.RefId == this.RefId
                && reqTrans.RefId == reqPO.RefId
                && reqTrans.RefType == reqPO.RefType
                && reqTrans.PlanVersion == reqPO.PlanVersion;
    
            this.TCI_ReqApproveDateTime     = reqPO.TCI_ReqApproveDateTime;
            this.TCI_ReqApproveUserId       = reqPO.TCI_ReqApproveUserId;
            this.TCI_PeggedRefType          = reqTrans.RefType;
            this.TCI_PeggedRefId            = reqTrans.RefId;
    
            inventTransOrigin               = reqTrans.InventTransOrigin();
    
            this.TCI_PeggedInventTransId    = inventTransOrigin.InventTransId;
            
            this.ReqDateDlv                 = reqPO.ReqDateDlv;
    
            next insert();
        }
    
    }

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,882

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 525 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans