Globally adding similiar code to many forms at onc

Has anyone ever done anything like this before in Navision? 1) Export all form objects to a text file 2) Globally replace certain field names with additional lines of code 3) Import the text back into Navision What I’d like to do is add the following lines of code to specific fields to allow them not to be displayed unless the user is ‘ALL’: //xxx Start IF USERID <> ‘ALL’ THEN VISIBLE := FALSE; //xxx End Has anyone ever done something like this before with a global replace on a large text file of all Navision form objects? Or has anyone written a program to do this before?

Yes, I did it many times and it can be done almost without danger. This is in fact my preferred method of making similar changes to a large number of objects. ------- With best regards from Switzerland Marcus Fabian

Yes, I have done global search and replace (examining each occurance) to change the name of a field, or change the field size. It is possible to do what your suggesting, I would recommend using a language such a PERL to manipulate the text. The PERL language is very good for complex text editing. You first need to develop the conditions of where you want to place the code, which trigger, start/end, code placement. Navision plays attention to position, and delimining characters when it comes to the text file. You first need to examine the text output to learn the rules.

quote:


Originally posted by PBerberich: What I’d like to do is add the following lines of code to specific fields to allow them not to be displayed unless the user is ‘ALL’: //xxx Start IF USERID <> ‘ALL’ THEN VISIBLE := FALSE; //xxx End


Just one point Paul try to avoid hard coding if possible add the default user to a setup menu somewhere. When new people come to work at your Customers they may have different Idea’s on what the “ALL” User shoulds be called //xxx Start SalesSetup.GET; SalesSetup.TESTFIELD(“Default User”); IF USERID <> SalesSetup.“Default User” THEN VISIBLE := FALSE; //xxx End OR gives the ability to switch of the feature by blanking the “Default User” if working practices change //xxx Start SalesSetup.GET; IF SalesSetup.“Default User” <> ‘’ THEN IF USERID <> SalesSetup.“Default User” THEN VISIBLE := FALSE; //xxx End David Cox MindSource (UK) Limited Navision Solutions Partner Email: david@mindsource.co.uk Web: www.mindsource.co.uk

quote:


Originally posted by PBerberich: Has anyone ever done anything like this before in Navision? 1) Export all form objects to a text file 2) Globally replace certain field names with additional lines of code 3) Import the text back into Navision What I’d like to do is add the following lines of code to specific fields to allow them not to be displayed unless the user is ‘ALL’: //xxx Start IF USERID <> ‘ALL’ THEN VISIBLE := FALSE; //xxx End


I agree with the comments the other guys made. If it’s the same code in every form— then you really really really should write a function in an external codeunit ONCE rather than copying the code itself over and over again. This is a pain because you have to create approximately two new variables on every form, but it will save you a lot of grief. Of course, you MIGHT want to copy the code itself and save yourself the trouble of creating those variables— that would be a good approach IF the user will NEVER upgrade to a new version of Navision and IF you know that you will NEVER need to modify your new code. ------- Tim Horrigan horrigan@aol.com Edited by - horrigan on 2001 Jul 16 00:52:16

Considering the licence agreement, most have to upgrade to keep within two versions… Its easier to put even a small function on a code unit now rather than later. Having said that, the code in the codeunit might be less than the code required to call it! Craig Bradney Technical Manager Navision Solutions & Services, Deloitte Touche Tohmatsu Email:cbradney@deloitte.com.au

Thank you everyone for the helpful advise! For those of you that have done this before, what tool did you use to do it with? Alan mentioned PERL, but I’m not familiar with it. Has any of you written a program to do this? Or recommend any good text editors or utility that could handle this?