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, ...
Unanswered

Purchline table map versioning extension

(0) ShareShare
ReportReport
Posted on by 60

Hi,

I have a requirement to add a field to the PurchLine and PurchLineHistory tables extensions for the purchase order versioning.

I was following the following link to do the required customization and I feel like I'm missing something, since it seems that it when it goes to version that field it cannot find it hence it throws "Object reference not set to an instance of an object.

Extend table maps that are used for versioning - Finance & Operations | Dynamics 365 | Microsoft Learn

As mentionned in the Microsoft documentation linked, I've done the following:

1) Added a new field on the PurchLine and PurchLineHistory table extensions

2) Created a new table map and added the new field to it.

3) On the PurchLine and PurchLineHistory table extensions, under mapping, I've added the new table map from point 2 and mapped the new field

4) I've created a new class that implements the PurchLineIVersioningFieldSet with the same methods as the PurchLineVersioningFieldSet class, to use the new table map that i've created. below is the code:

I get the error in the class VersioningPurchaseOrderArchivePurchLine method initFieldMapping, the selectDictField and insertDictField are null, hence on the next line when it uses those variables I get the 'Object reference not set to an instance of an object'. It seems that I cannot find the new field from the new table map that I've created.

I'm probably missing something but not sure. Any help is welcome.

internal final class PurchLineVersioningFieldSet_NAP implements PurchLineIVersioningFieldSet
{      
    [Wrappable(false)]
    protected PurchLineMap_NAP purchLineMapFieldSet(PurchLineVersioning _purchLineVersion)
    {
        return _purchLineVersion.parmPurchLineVersion();
    }
    public boolean isChangeConfirmationRequired(PurchLineVersioning _currentPurchLineVersion, PurchLineVersioning _archivedPurchLineVersion)
    {
        PurchLineMap_NAP currentPurchLineMap_NAP    = this.purchLineMapFieldSet(_currentPurchLineVersion);
        PurchLineMap_NAP archivedPurchLineMap_NAP   = this.purchLineMapFieldSet(_archivedPurchLineVersion);

        boolean ret = false;
                
        if (currentPurchLineMap_NAP.NoOfTimesVendClickedToSuggestChangesOnConfirmedPO_NAP != archivedPurchLineMap_NAP.NoOfTimesVendClickedToSuggestChangesOnConfirmedPO_NAP)
        {
            ret = true;
        }

        return ret;
    }

    [Hookable(false), Wrappable(false)]
    public void copyVersion(PurchLineVersioning _targetPurchLineVersion, PurchLineVersioning _sourcePurchLineVersion)
    {
        PurchLineMap_NAP targetPurchLineMap_NAP     = this.purchLineMapFieldSet(_targetPurchLineVersion);
        PurchLineMap_NAP sourcePurchLineMap_NAP     = this.purchLineMapFieldSet(_sourcePurchLineVersion);
        targetPurchLineMap_NAP.data(sourcePurchLineMap_NAP.data());
    }

    [Hookable(false), Wrappable(false)]
    public TableId fieldSetTableMapId()
    {
        return tableNum(PurchLineMap_NAP);
    }
}

I have the same question (0)
  • Brightlin Profile Picture
    60 on at
    RE: Purchline table map versioning extension

    I've done all of that but something was off. After I've updated to V30, the same code is working now.

    Thanks for the help!

  • Martin Dráb Profile Picture
    236,192 Most Valuable Professional on at
    RE: Purchline table map versioning extension

    First of all, make sure that your solution is compiled and synchronized with database. Then debug the code in VersioningPurchaseOrderArchivePurchLine class.

    Do you have the expected field in mapDictField variable (in initFieldMapping())? What value gets returned from versionedFieldId()? It should be the ID of your field in PurchLine extension, but it likely fails to find it for some reason.

  • Brightlin Profile Picture
    60 on at
    RE: Purchline table map versioning extension

    Thanks!

    it's VersioningPurchaseOrderArchivePurchLine class

  • Martin Dráb Profile Picture
    236,192 Most Valuable Professional on at
    RE: Purchline table map versioning extension

    Please make sure that you post code with line indentation, because it's then much easier to read. Use Insert > Code (in the rich formatting view) to paste the code. This is the result:

    [Wrappable(false)]
    protected PurchLineMap_Custom purchLineMapFieldSet(PurchLineVersioning _purchLineVersion)
    {
    	return _purchLineVersion.parmPurchLineVersion();
    }
    
    public boolean isChangeConfirmationRequired(PurchLineVersioning _currentPurchLineVersion, PurchLineVersioning _archivedPurchLineVersion)
    {
    	PurchLineMap_Custom currentPurchLineMap = this.purchLineMapFieldSet(_currentPurchLineVersion);
    	PurchLineMap_Custom archivedPurchLineMap = this.purchLineMapFieldSet(_archivedPurchLineVersion);
    
    	boolean ret = false;
    
    	if (currentPurchLineMap.NewField != archivedPurchLineMap.NewField)
    	{
    		ret = true;
    	}
    
    	return ret;
    }
    
    [Hookable(false), Wrappable(false)]
    public void copyVersion(PurchLineVersioning _targetPurchLineVersion, PurchLineVersioning _sourcePurchLineVersion)
    {
    	PurchLineMap_Custom targetPurchLineMap = this.purchLineMapFieldSet(_targetPurchLineVersion);
    	PurchLineMap_Custom sourcePurchLineMap = this.purchLineMapFieldSet(_sourcePurchLineVersion);
    	targetPurchLineMap.data(sourcePurchLineMap.data());
    }
    
    [Hookable(false), Wrappable(false)]
    public TableId fieldSetTableMapId()
    {
    	return tableNum(PurchLineMap_Custom);
    }

    I don't have any VersioningPurchaseOrdreArchivedPurchLine in my environment, and VersioningPurchaseOrderArchivedPurchLine either. What is the correct class name?

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 2,351

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 638 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans