When I upgraded with one of my customers to NAV 2016 workflow was one of the new features I was looking forward to working with. You can imagine how disappointed I was when I found out that there was a huge performance issue with conditional workflows.
Here are a few links:
“When I’m posting a G/L Journal with 8000 lines, then NAV nicely updates the progress bar the first 50 seconds and reaches 100%.
Then NAV freezes for about 8-9 minutes without any sign of life, before it tells me it is done.”
Let’s look at the core reason of this problem (or at least what I’ve found when debugging):
When using filters this piece of code is executed:
LOCAL EvaluateConditionOnTable(SourceRecordId : RecordID;TableId : Integer;TempBlob : Record TempBlob) : Boolean
RecRef.OPEN(TableId);IF NOT RequestPageParametersHelper.ConvertParametersToFilters(RecRef,TempBlob) THEN
EXIT(TRUE);IF RecRef.FINDSET THEN
IF RecRef.RECORDID = SourceRecordId THEN
UNTIL RecRef.NEXT = 0;EXIT(FALSE);
So how do you fix it?
LOCAL AddPrimaryKeyToFilterForPerformanceBoost(VAR RecRef : RecordRef;RecordID : RecordID)
RecRefForKey.SETRECFILTER;FirstPartOfView := RecRefForKey.GETVIEW;
FirstPartOfView := COPYSTR(FirstPartOfView, 1, STRPOS(FirstPartOfView, ‘WHERE(‘) + 5);KeyView := RecRefForKey.GETVIEW;
KeyView := COPYSTR(KeyView, STRPOS(KeyView, ‘WHERE(‘) + 6, STRLEN(KeyView));
KeyView := COPYSTR(KeyView, 1, STRLEN(KeyView) – 1);View := RecRef.GETVIEW;
View := COPYSTR(View, STRPOS(View, ‘WHERE(‘) + 6, STRLEN(View));
View := COPYSTR(View, 1, STRLEN(View) – 1);RecRef.SETVIEW(FirstPartOfView + View + ‘,’ + KeyView + ‘)’);