SBX - Search With Button

SBX - Forum Post Title

Changes to the document are only allowed in state Draft, because change management is activated.

Dynamics 365 for Finance and Operations Forum

Vinayak Chingunde asked a question on 14 Jun 2019 10:28 AM
My Badges

Question Status

Suggested Answer

Hi All,

I am trying to update the PO information through code where Change management is active for that PO. I can able to update update the information successfully but when i open the PO through front end i am getting the error as "Changes to the document are only allowed in state Draft, because change management is activated." 

Code looks like 

VersioningPurchaseOrder versioningPurchaseOrder;

versioningPurchaseOrder = VersioningPurchaseOrder::newPurchaseOrder(purchTable, true);
versioningPurchaseOrder.createChangeRequest();
..
purchtable.update();
..
purchLine.update();
..
versioningPurchaseOrder.submitChangeRequest();
versioningPurchaseOrder.approveChangeRequest();

can any one tell me whats going wrong, am i missing some step through code.

Reply
Vinayak Chingunde responded on 14 Jun 2019 12:43 PM
My Badges

its very weird that while opening the PurchTable form system triggers update() on some tables, below is the call stack for error while opening the form

Dynamics.AX.ApplicationPlatform.1.netmodule!Dynamics.AX.Application.Info.`add(Dynamics.AX.Application.Exception _exception, string _txt, string _helpUrl, Microsoft.Dynamics.Ax.Xpp.XppObjectBase _sysInfoAction, bool buildprefix, string _label, bool @_helpUrl_IsDefaultSet, bool @_sysInfoAction_IsDefaultSet, bool @buildprefix_IsDefaultSet, bool @_label_IsDefaultSet) Line 286

X++

Dynamics.AX.ApplicationPlatform.1.netmodule!Dynamics.AX.Application.Global.`error(string txt, string helpUrl, Dynamics.AX.Application.SysInfoAction _sysInfoAction, bool @helpUrl_IsDefaultSet, bool @_sysInfoAction_IsDefaultSet) Line 2406

X++

Dynamics.AX.ApplicationSuite.146.netmodule!Dynamics.AX.Application.VersioningDocument.`change(Microsoft.Dynamics.Ax.Xpp.Common _newRecord, Microsoft.Dynamics.Ax.Xpp.Common _oldRecord) Line 130

X++

Dynamics.AX.ApplicationSuite.146.netmodule!Dynamics.AX.Application.VersioningPurchaseOrder.`change(Microsoft.Dynamics.Ax.Xpp.Common _newRecord, Microsoft.Dynamics.Ax.Xpp.Common _oldRecord) Line 841

X++

Dynamics.AX.ApplicationSuite.85.netmodule!Dynamics.AX.Application.PurchLineForeignTradeCategory.`update() Line 146

 

    public void update()

    {

        VersioningPurchaseOrder::newPurchaseOrder(PurchLine::findInventTransId(this.PurchLineInventTransId).purchTable(true)).change(this, this.orig());

        this.IsModified = NoYes::Yes;

        super();

    }

 

X++

[External Code]

 

Dynamics.AX.ApplicationPlatform.0.netmodule!Dynamics.AX.Application.FormDataUtil.`DBOpInTransaction(Microsoft.Dynamics.Ax.Xpp.Common _record, bool _isWriteOperation) Line 906

X++

[External Code]

 

Dynamics.AX.ApplicationSuite.Forms.14.netmodule!Dynamics.AX.Application.Forms.PurchTable.FormDataSource.PurchLineForeignTradeCategory.write() Line 5191

X++

[External Code]

 

Reply
Vinayak Chingunde responded on 16 Jun 2019 8:48 AM
My Badges

Anyone have any suggestions ?

Reply

Hi Vinayak,

I have not done this myself. Using the client user interface, you first have to click the action 'Request change'. Have you looked at the coding behind this button?

Reply
Sourav Dam responded on 18 Jun 2019 9:32 AM
My Badges
Suggested Answer

Hi Vinayak,

Same I found few days back while trying to click anywhere in the PO (other than 'Request change' tab), this notification pops up.

The scenario is below.

--- The PO was created say for example on 1st Jan 2019.

--- Both sales tax and item sales tax group were selected in PO line. User had confirmed the PO also.

--- Then there was a requirement from the client to change the tax effective date as they were not yet registered to VAT authority by that time. Therefore, we changed the From date (for example changed from 1st Jan to 1st March 2019) in 'Value' form in sales tax code.

After that when user was trying to proceed with that PO, he got this notification.

The reason what I identified and my understanding on this as per below.

--- As there is a change / update made in sales tax code in later stage; therefore, system was trying to validate the same tax code (which is linked with sales tax and item sales tax group) as it was recorded first time in PO. 

--- Now while validating the tax code as recorded before, it was not able to match and update the same just because I modified the Start date in tax code.

Below solution measure I had taken to sort out this.

--- Clicked on 'Request change' first.

--- Removed both sales tax group and item sales tax group from each line of that PO.

--- Selected back again the same sales tax group and item sales tax group in each line in the PO.

After that, it was allowing to proceed further as usual.

Though this sounds typical but this is how it worked :)

Best regards
Sourav Dam

Reply
Sourav Dam responded on 18 Jun 2019 9:32 AM
My Badges
Suggested Answer

Hi Vinayak,

Same I found few days back while trying to click anywhere in the PO (other than 'Request change' tab), this notification pops up.

The scenario is below.

--- The PO was created say for example on 1st Jan 2019.

--- Both sales tax and item sales tax group were selected in PO line. User had confirmed the PO also.

--- Then there was a requirement from the client to change the tax effective date as they were not yet registered to VAT authority by that time. Therefore, we changed the From date (for example changed from 1st Jan to 1st March 2019) in 'Value' form in sales tax code.

After that when user was trying to proceed with that PO, he got this notification.

The reason what I identified and my understanding on this as per below.

--- As there is a change / update made in sales tax code in later stage; therefore, system was trying to validate the same tax code (which is linked with sales tax and item sales tax group) as it was recorded first time in PO. 

--- Now while validating the tax code as recorded before, it was not able to match and update the same just because I modified the Start date in tax code.

Below solution measure I had taken to sort out this.

--- Clicked on 'Request change' first.

--- Removed both sales tax group and item sales tax group from each line of that PO.

--- Selected back again the same sales tax group and item sales tax group in each line in the PO.

After that, it was allowing to proceed further as usual.

Though this sounds typical but this is how it worked :)

Best regards
Sourav Dam

Reply

SBX - Two Col Forum

SBX - Migrated JS