Friday, June 28, 2019

GP SQL - Failed to flush the commit table to disk in dbid 12 due to error 2601. Check the errorlog for more information.

https://cowmasterscorner.blogspot.com/2014/01/sql-2008-r2-failed-to-flush-commit.html

Already resolved with
Solution 2 (this one worked for me):
Run a

DBCC CHECKDB (two) WITH NO_INFOMSGS, ALL_ERRORMSGS

then most likely a

ALTER DATABASE two SET SINGLE_USER
GO
DBCC CHECKDB (two,repair_rebuild)
GO
ALTER two SET MULTI_USER
GO



This is a bug, install the latest SQL

https://support.microsoft.com/en-us/help/2603910/fix-backup-fails-in-sql-server-2008-sql-server-2008-r2-or-sql-server-2

It comes from MR enabling change tracking on tables

https://community.dynamics.com/gp/f/32/t/136038


Disable change Tracking, Backup, then enable change tracking
Get a list of all change tracking enabled tables with this
---------------------------------------------------------------------
SELECT * FROM sys.change_tracking_tables sctt

left join sys.tables st on sctt.object_id = st.object_id


------------------------------------------------------------------------
Use this to generate scripts to disable change tracking in all tables with it on
------------------------------------------------------------------
DECLARE @SQL NVARCHAR(MAX)='';
SELECT @SQL = @SQL + 'ALTER TABLE ' + s.name + '.' + t.name +
 ' Disable Change_tracking;'
FROM sys.change_tracking_tables ct
JOIN sys.tables t
 ON ct.object_id= t.object_id
JOIN sys.schemas s
 ON t.schema_id= s.schema_id;
PRINT @SQL;
EXEC sp_executesql @SQL;
-----------------------------------------------------------------

Run the script below against the Company database
---------------------------------------------------------
ALTER TABLE dbo.GL00102 Disable Change_tracking;ALTER TABLE dbo.GL40200 Disable Change_tracking;ALTER TABLE dbo.GL30000 Disable Change_tracking;ALTER TABLE dbo.GL40000 Disable Change_tracking;ALTER TABLE dbo.MC00200 Disable Change_tracking;ALTER TABLE dbo.GL10101 Disable Change_tracking;ALTER TABLE dbo.GL00200 Disable Change_tracking;ALTER TABLE dbo.GL12000 Disable Change_tracking;ALTER TABLE dbo.SY00300 Disable Change_tracking;ALTER TABLE dbo.GL00201 Disable Change_tracking;ALTER TABLE dbo.MC40600 Disable Change_tracking;ALTER TABLE dbo.GL32000 Disable Change_tracking;ALTER TABLE dbo.GL10001 Disable Change_tracking;ALTER TABLE dbo.SY40100 Disable Change_tracking;ALTER TABLE dbo.GL10000 Disable Change_tracking;ALTER TABLE dbo.GL00100 Disable Change_tracking;ALTER TABLE dbo.GL20000 Disable Change_tracking;ALTER TABLE dbo.GL10100 Disable Change_tracking;ALTER TABLE dbo.SY40101 Disable Change_tracking;ALTER TABLE dbo.MC40000 Disable Change_tracking;ALTER TABLE dbo.GL12001 Disable Change_tracking;
------------------------------------------------------------------------
Run script to disable on company
-------------------------------------------
ALTER DATABASE FABRIKAM
SET CHANGE_TRACKING = OFF
---------------------------------------------

Take Backups

enable Change Tracking
----------------------------------------------------------------------------
ALTER DATABASE FABRIKAM
SET CHANGE_TRACKING = ON
(CHANGE_RETENTION = 5 DAYS, AUTO_CLEANUP = ON)

ALTER TABLE dbo.GL00102 Enable Change_tracking;ALTER TABLE dbo.GL40200 Enable Change_tracking;ALTER TABLE dbo.GL30000 Enable Change_tracking;ALTER TABLE dbo.GL40000 Enable Change_tracking;ALTER TABLE dbo.MC00200 Enable Change_tracking;ALTER TABLE dbo.GL10101 Enable Change_tracking;ALTER TABLE dbo.GL00200 Enable Change_tracking;ALTER TABLE dbo.GL12000 Enable Change_tracking;ALTER TABLE dbo.SY00300 Enable Change_tracking;ALTER TABLE dbo.GL00201 Enable Change_tracking;ALTER TABLE dbo.MC40600 Enable Change_tracking;ALTER TABLE dbo.GL32000 Enable Change_tracking;ALTER TABLE dbo.GL10001 Enable Change_tracking;ALTER TABLE dbo.SY40100 Enable Change_tracking;ALTER TABLE dbo.GL10000 Enable Change_tracking;ALTER TABLE dbo.GL00100 Enable Change_tracking;ALTER TABLE dbo.GL20000 Enable Change_tracking;ALTER TABLE dbo.GL10100 Enable Change_tracking;ALTER TABLE dbo.SY40101 Enable Change_tracking;ALTER TABLE dbo.MC40000 Enable Change_tracking;ALTER TABLE dbo.GL12001 Enable Change_tracking;


-------------------------------------------------------------
Run the script below against the Dynamics database
ALTER TABLE dbo.MC00100
ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = OFF);
GO
ALTER TABLE dbo.SY01500
ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = OFF);
GO

Monday, June 24, 2019

NAV - XML Ports - How to reference fields within XMLPort for CAL

VendorItemNo - Export::OnBeforePassVariable()
VendorItemNo := Sub.GetVendorItemNo("Purchase Header"."Buy-from Vendor No.","Purchase Line"."No.");


"Table Element Name"."Field Element Name"

Saturday, June 22, 2019

NAV CAL - Open another Page by clicking on a record

Entering any code in the Onlookup trigger will trigger onmouseover click on a page

Instructions - OnLookup(VAR Text : Text) : Boolean
PAGE.RUN(PageID);

NAV Setup Checklist - Assisted Setup

P1801 - Assisted Setup
Available on Business Manager User Personalization Role

NAV CAL - How to update other fields after updating one field. Unable to change an earlier version of the record. The record should be read from the database again. This is a programming error.

This relates to the specific situation where a field on a list page causes other fields to update when ticked. The other fields do not immediately update when the tickbox is ticked.

Add this code on the page to get the latest version of the record, and maintain the value of the tickbox.

The "Errors" field is updated by other subscriptions when the "Confirmed by Vendor" is ticked.


Confirmed by Vendor - OnValidate()
IF "Confirmed by Vendor" = TRUE THEN BEGIN
  Rec.GET(Rec."PO Number");
  Errors := Rec.Errors;
  "Confirmed by Vendor" := TRUE;
END ELSE BEGIN
  Rec.GET(Rec."PO Number");
  Errors := Rec.Errors;
  "Confirmed by Vendor" := FALSE;
END;

Friday, June 21, 2019

NAV - Import XML using XMLPort by removing namespaces

Related: You cannot create an Automation object “AutomationVariable” on Microsoft Dynamics NAV Server. You must create it on a client computer.




CREATE(AutomationVariable,FALSE,TRUE)

-------------------------

This is the only solution that actually worked, which involved ignoring XMLports completely, and using the XML DOM Management functions to read the XML file using a codeunit and a function.

Monday, June 17, 2019

NAV - XMLPort xmlns and namespace definitions

Define namespaces and prefixes by going to the properties of the XMLPort, or each one of the specific lines.

Friday, June 14, 2019

NAV CAL - How to open a windows folder



  HYPERLINK('C:\Temp\');

NAV - How to create a silent export XMLPort

Name DataType Subtype Length
POXMLFile File
XMLStream OutStream
IsExported Boolean
FromFile Text
ToFile Text
POStat Record PO Status
TheFileName Text



  //Create File
  TheFileName :=  POStat."PO Number" +'-'+ DATE2YYYYMMDD(POStat."PO Order Date")+ '.xml';
  POXMLFile.CREATE(XMLTemplate."Output File Location" + TheFileName);
  POXMLFile.CREATEOUTSTREAM(XMLStream);
  IsExported := XMLPORT.EXPORT(XMLPORT::"PO Export XML", XMLStream,POStat);
  POXMLFile.CLOSE;
 
IF IsExported THEN
BEGIN
  MESSAGE( TheFileName   + ' Exported to XML');
END
ELSE
  MESSAGE(Text001);

Smartconnect - Failed to get CRM Organizations : An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.

Friday, June 7, 2019

NAV - How to create an XMLPort to export a PO

http://dynamicslancer.blogspot.com/2016/09/how-to-use-xmlport-to-create-file-in.html

  • Create Codeunit to execute XMLPort
ExportPOXML(PO : Text[50])
POHdr.SETFILTER("No.",PO);
IF POHdr.FINDFIRST THEN BEGIN
  POXMLFile.CREATE(TEMPORARYPATH + 'PO.xml');  
  POXMLFile.CREATEOUTSTREAM(XMLStream);  
  IsExported := XMLPORT.EXPORT(XMLPORT::"PO Export XML", XMLStream,POHdr);  
  FromFile := POXMLFile.NAME;  
  ToFile := 'VendorPO.xml';  
  POXMLFile.CLOSE;  
END;
IF IsExported THEN  
BEGIN  
  DOWNLOAD(FromFile,'Download file','C:\Temp','Xml file(*.xml)|*.xml',ToFile);  
  ERASE(FromFile);  
  MESSAGE(Text000);  
END  
ELSE  
  MESSAGE(Text001);  
  • Create Button on Page to call codeunit and pass current record
Export PO to XML - OnAction()
Sub.ExportPOXML(Rec."PO Number");