Record Race Condition – 2 users block each other

A forum user needed help for a typical situation in dynamics nav. 2 users are working on the same sales order at the same time. both make changes. as a result one gets the error: the current record has an old load status, record was changed by an other user.

this is a so called race condition, means two persons want to change the same record or the value of the same field. at the time were the second person, who edited the record, wants to save his changes, the system realizes, that the status of the loaded record is old, because the first person has already saved his changes.

the question was: how to lock the sales order, when one user edits the record, so that a 2. user cannot edit the record.

how to solve the problem:

  • the process answer: i most cases that should not be an issue, because only one user should work with one record at a time, e.g. one sales order. it makes no sense that 2 persons work at the same time with the same order. if that occurs, the work process in the company needs some optimization. So some consultancy is needed.
    • situation 1: 2 persons do different things with the same order. In that case a workflow has to be defined, so that person 1 does his work first, then in step 2 person 2 his work step. result: never work 2 persons at the same time with the same order.
    • situation 2: both do the same. then it’s needed to set the field assigned user, so that each person can filter the sales order list by that field and get so the assigned work load. as a result there is never a situation, where 2 persons work with the same order.
  •  tech answer: the issue is also solvable technically, but i recommend the process change.
    • table sales header: add 2 fields InUse – boolean, UsedBy – code.20
    • page 42 sales order, add following code to
      trigger OnQueryClosePage

      IF UsedBy = USERID THEN BEGIN

      UsedBy := ”;
      InUse := FALSE;
      modify;

      END;

      trigger OnAfterGetCurrRecord()
      IF NOT InUse THEN BEGIN

      InUse := TRUE;
      UsedBy := USERID;
      modify;

      END ELSE

      IF UsedBy <> USERID THEN
      ERROR(‘in use by %1’, UsedBy);

cheers

Workflows in Dynamics Nav/BC

Hallo,

ich beschäftige mich aktuell mit Workflows in Dynamics Nav.
Ich bin seit vielen Jahren Senior Consultant für Dynamics Nav und hatte keinen einzigen Kunden, der das Workflow Modul im Einsatz hat, was schade ist, weil das Modul durchaus was kann. Gestern ist mir jedoch klar geworden, dass man keine Genehmigungsrollen in einem Workflow benutzen, nur mit spezifischen Benutzern arbeiten kann. Tasks von einer Rolle zu einer anderen Rolle weiterzuleiten ist aber ein typisches Thema in Workflowszenarien, etwa beim Eingangsrechnungsworkflow.

Dazu ein paar Fragen:
* Lässt sich das Thema Genehmigungsrolle mit dem Standard Nav Workflow umsetzen bzw. gibt es dafür entsprechende Erweiterungen von Drittherstellern?
* Welche konkreten, typischen Anforderungen haben die Kunden, die das Workflow Modul benutzen? Mussten hier Anpassungen vorgenommen werden oder reichten die Features des Standard Nav Workflow Moduls?

Würde mich über Feedback freuen.

beste Grüße
Dipl.Ing. Franz Kalchmair

Do you know Uniconta?

Because working with D365 BC is not that fun and the features are for small customers too much (they pay for many, what they don’t need), i started with Uniconta. First of all, it is far away from big ERP Systems like NAV and BC. The marketing propaganda says it’s easy to use … So what is the reality?

Uniconta is a new cloud based ERP System. At first view some nice features, quite cheap, very fast, but lacks in some kind in the areas configuration, usability and business logic. It’s quite hard to customize it in that way we know it from NAV. It’s easy to add fields in tables, but not easy to add a button with it’s on functionality. It’s not possible too change existing code, e.g. the posting routines like in Nav often done.

Examples:

  • Often needed information is not available on the current point, e.g. item ledger entries (i.e. inventory posting entries in uniconta) are not available in the shipment list.
  • Shipment can be created from an order multiple times without changing anything in the system except that there is a new shipment in the list. That’s really disturbing.
  • Creating a shipment does not reduce the item stock. That’s also really disturbing.
  • To post an order only for delivering, but without invoicing was really hard to find out, how this simple basic erp process works in uniconta. that after some needed configuration (sales preferences, activating of some inventory module features) the item quantity of the sales line is removed from stock immediatly when you set up the quantity in the sales line and not after posting, is quite strange. seems that this is a kind of reservation. is this a well considered erp process? not sure …

I tested a lot, found a huge number of programming/logic/translation failures and irritating and/or not translated error messages (some of them are like “error has occured”), wrote a lot, lot mails to the austrian support. It’s tedious … Nevertheless, maybe i will continue, will see, if i have the time …

In the end, who knows, maybe it will be developed into the right direction. Hopefully the bugs will be fixed and the usability & the business logic will be better.

For more details see:

cheers

 

What i learned from summit emea, bc day, in amsterdam

i visited amsterdam the first time in my life, it was also the first summit i joined. the event is quite well organized, but there are to less nibbles for coffee break. but this is not the point.

so what is the point? a bit surprisingly many sessions were a kind of a marketing show from and for ISVs and/or partners. this can be interesting, if someone has a special interest in the products of the ISV, for sales people, but it’s not really interesting for the public, for techies, for people who are interested in news about BC in general.

or … power bi is a quite interesting tool and it’s nice, that someone can make basic analysis reporting for BC data, but it’s not specific BC. what i saw, there was no session for “BC in the deep”, what are the features in detail, what can be done with BC and what not. there was only the starting session about BC, a very quick, facile overview, no news. the speaker spoke very quiet, a sleeping pill, so the first impession was not so good.

questions like “is a web based client a solution for everyone or not?” were not discussed, should have been. what about the current/future direction of BC, is it stable now or will we have extensions 3.0 in one year and every ISV has to update their addons? will customizations be stable with BC upgrades or not? these are important questions. there was no session about these topics and no tech session, especially a session about standard reporting in BC would have been interesting. the session about bio diesel was quite ok, it showed a successful BC project with quite complicated processes, which were handled as it should be. it was not really great, normal project work, but it showed, that BC projects can be done like NAV projects.

one exception: the last session i visited was the session of eva dupont, microsft team lead for help/documentation. one word: chapeau!
only 4 people visited the session, what a shame.
mrs. dupont told the history of nav/bc documentation from the beginning, what were the changes, what is now, how can partners/customers use and modify it for their own purposes. all presented with a humour, intelligence and competence of that kind, which are very, very rare. i was fascinated and excited. as always these kind of flowers are not cherished that way it should be.

at last, during one coffee break, i sat in the rest room with my coffee, thinking about whats going on here, suddenly a strange person came to me, sat down, and asked me why i sit here alone and do not talk to others and some more pushy questions. and this person was much too narrow too me. what the hell?! is that the american way to contact a strange person? this was very rude! i can’t stand that at all! we are here in europe, not in the states. this is not the manner how we contact strange persons here! for sure, that is one of the reasons, why the dynamics communities do not work in europe. first of all: keep distance!

so, that was it, this was also my last summit or that kind of event. that’s not that kind of events i like, it costs money, it’s time and power consuming. and in the end, not sure, what it brings. i will also reduce, maybe stop my community activities. spent over the last 5 years huge amount of my spare time, will do other things, which make more sense for me.

Read & process CSV files programmaticaly

LOCAL ReadCsvFile()
fmode := fmode.Open;
fstream := fstream.FileStream(‘c:\temp\test.csv’,fmode);
enc := enc.UTF8; // read text as UTF8 charset, can also be Default (Windows) or Ascii
reader := reader.StreamReader(fstream,enc);
REPEAT
Line := reader.ReadLine;
//MESSAGE(Line);
ColNo := 1;
REPEAT
CellValue := StringSplit(Line,’;’);
Column[ColNo] := CellValue;
ColNo += 1;
UNTIL Line = ”;
// Process columns
UNTIL reader.EndOfStream;
reader.Close;
fstream.Close;

//variables: all .net vars RunClient=Yes
CellValue Text
Column Text, Dim 20
Line Text
ColNo Integer
reader DotNet System.IO.StreamReader.’mscorlib
fstream DotNet System.IO.FileStream.’mscorlib
fmode DotNet System.IO.FileMode.’mscorlib
enc DotNet System.Text.Encoding.’mscorlib

LOCAL StringSplit(VAR Text : Text[1024];Separator : Text[1]) Token : Text[1024]
Pos := STRPOS(Text,Separator);
IF Pos > 0 THEN BEGIN
Token := COPYSTR(Text,1,Pos-1);
IF Pos+1 <= STRLEN(Text) THEN
Text := COPYSTR(Text,Pos+1)
ELSE
Text := ”;
END ELSE BEGIN
Token := Text;
Text := ”;
END;

//variables
Pos Integer

Also have a look at:
https://www.olofsimren.com/xml-buffer-and-csv-buffer-tables/
http://www.dynamics.is/?tag=csv-file

Access protected file share

There was a post, where a user wanted to get read/write acces to a file share outside the current domain from within Nav.

This can be done via .Net:

NetworkCredential := NetworkCredential.NetworkCredential(username, password, domain); // Credentials for domain 2
CredentialCache := CredentialCache.CredentialCache;
Uri := Uri.Uri(‘\\server’); // the server name from domain 2
CredentialCache.Add(Uri, ‘Basic’, NetworkCredential);
Dirs := SysDir.GetDirectories(‘\\server\directory’); // get folder list from the file share
FOR i:=1 TO Dirs.GetLength(0) DO
DirListTxt := DirListTxt + FORMAT(Dirs.GetValue(i-1))+’\’; //.net index starts with 0
MESSAGE(DirListTxt); // print out the dir list

variables
NetworkCredential DotNet System.Net.NetworkCredential.’System
CredentialCache DotNet System.Net.CredentialCache.’System
Uri DotNet System.Uri.’System
Dirs DotNet System.Array.’mscorlib
SysDir DotNet System.IO.Directory.’mscorlib
DirListTxt Text
i Integer