Have you ever had the need to replace some values from a list of values? For example, you need to change the Postal/Zip Code for a number of your customers. Most of the time you would need to write a codeunit or report to accomplish that or even have the customer update each entry by hand. What if you needed to do the same with your vendors? That would require either modifying the previous codeunit/report or possibly just creating a new object to handle this or again having the customer update each entry by hand.
Here is another option – a Replace page that you can add to any page with just a few lines of code.
Fig 1. Replace Page
How to implement the page:
If you import the attached object text file and follow these steps you will be able to add this to almost any page (at least where it makes sense). For this example I will be updating the Customer List (Page 22).
1. Import and compile the attached object “Replace NAV2013.txt”.
2. Design the Customer Page (21).
3. Add a global variable named Replace and point it to Page 50050 (or whatever you may have changed it to prior to import)
4. Create a new action.
5. Go to the OnAction trigger for your new action and add the following code …
6. Compile your object and you should be ready to use it.
How it works:
Note: When use this Replace page, keep in mind that the TIME and DATETIME fields are very sensitive from a matching perspective. Even though the TIME may only appear to be HH:MM:SS on the page, there will probably be a millisecond component to the TIME as well. So, to have the best luck, it would probably be best to copy the value of the cell that you want to replace and use that as the value in “Find What” field. This is true with the DATETIME fields as well.
These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.
Where is the attachment?
Of course, this could be a risky function, because it allows you to replace values in non-editable fields. It means, user could go around the Editable=No property and change values in such a field... just want to mention this...
How can null values be replaced?
Really nice function. :)
@RFO There are no null values in NAV, it's not allowed. To replace empty fields just use ''.
Top man! Thanks
PS: Why did Microsoft remove this? -.-'
Great concept, I like it alot.
Ive tested this in NAV 2015
I had to do some corrections in order for it to work properly for my purpose, which was for Sales Order List ( page 9305).
Firstly, the GETFILTERS doesn't return the SourceTableView, which is "WHERE(Document Type=CONST(Order))", so a manual SETRANGE was applied before the LoadDataset function.
Secondly, because I run on a danish version, the filters were not applied correctly because it formats fields names instead of captions.
Also, filters on Options didn't get applied properly.
I will list my changes here, so if anyone else runs into the same problems, it might help.
I had to change the LOCAL_ApplyFilters function.
Added an local variable 'intTemp' of type Integer.
changed the following lines:
Line No.(in txt document) Before After
line 492 "IF FilteredFldRef.NAME = Filters[ICount] THEN BEGIN" "IF FilteredFldRef.CAPTION = Filters[ICount] THEN BEGIN"
line 534 "TempOption := FilteredFldRef.OPTIONSTRING;" "TempOption := FilteredFldRef.OPTIONCAPTION;"
and the whole 'OPTION' case to:
TempOption := FilteredFldRef.OPTIONCAPTION; //already listed above
OptionCount := 0;
FOR intTemp := 1 TO STRLEN(TempOption) DO BEGIN
IF TempOption[intTemp] = ',' THEN
OptionCount += 1;
FOR intTemp := 1 TO OptionCount+1 DO BEGIN
IF Filters[ICount] = SELECTSTR(intTemp,TempOption) THEN BEGIN
OptionNo := intTemp;
intTemp := OptionCount+1
The reason for using a intTemp is because the ICount is a reference to which filter its trying to apply,
and by using the same variable in the FOR loops, that connection is lost.
Under the 'OPTION' case, the ICount in "IF Filters[ICount]" is wrongly being incremented by the FOR loop.
I hope this made sense for you :)
I have implement your tool and works great when updating journals. The problem I'm facing now is that tool is updating all journals in all companies.
Example: Have 3 journal (Jnl1, jnl2, jnl3) on 5 different companies.
If I run the tool to update description field on Jnl1-Company1, it will apply the changes on all journals for all 5 companies.
@Alex: And you are sure the DataPerCompany is not changed to No for the table? Or the OnModify() trigger isn't doing syncing with the other companies? Nothing in the tool indicates it should do anything outside the current company.