Replace a text in a Field
                
                    niimodin                
                
                    Member Posts: 142                
            
                        
            
                    Hello Experts,
I have a client who has a customized module which creates a field for batch nos in the Item table.
I use to update is using dataport.
I am finally handing over the system to the client and what to design a simple where the client can click a button and the system is updated
for example: I want to replace all : 09C/_ with 10D/_ in the item table.
What function should I use?
Can someone help me
Thanks
                I have a client who has a customized module which creates a field for batch nos in the Item table.
I use to update is using dataport.
I am finally handing over the system to the client and what to design a simple where the client can click a button and the system is updated
for example: I want to replace all : 09C/_ with 10D/_ in the item table.
What function should I use?
Can someone help me
Thanks
0                
            Comments
- 
            check out in Help STRPOS (String) function..
Use this function to search for a substring inside a string.0 - 
            maybe it is not what you are looking for.. Simplest way without the code is - user hit CTR+H (replace) on list form and use it like in any other application. List form must be editable.. at last for this field
If You like to use function then use some filter, loop table and replace what you have to replace0 - 
            Hello,
Thank you very much.
How do I loop through the data.
I am replace all items in the data
Thanks0 - 
            JedrzejT wrote:CONVERTSRT(StringVariable,'09C/_','10D/_');
edit..
maybe it is not what you are looking for.. Simplest way without the code is - user hit CTR+H (replace) on list form and use it like in any other application. List form must be editable.. at last for this field
If You like to use function then use some filter, loop table and replace what you have to replace, You can use CONVERTSR if this only part of string you want replace.
Hi
CONVERTSRT use second and third parameter like a mask, non a search text.
If the string is '09C/_0999' you will obtain '10C/_1000'...
The best solution is to use strpos to find the position of the substring, and do a DELSTR and next INSSTR.
bye
MatteoReno Sistemi Navision Developer0 - 
            
IF rec.FINDSET THEN REPEAT UNTIL rec.NEXT=0
for example, but.. if You don't know this one I think you should read app. designer guide to know what you are doing
Eto: thanks - i know that.. just made a mistake :whistle:0 - 
            since i was working on a real str_replace function here my solution
STRREPLACE(haystack : Text[1024];needle : Text[1024];replace : Text[1024]) : Text[1024] i := STRPOS( haystack, needle ); IF ( i > 0 ) THEN BEGIN // clear first needle in haystack haystack := DELSTR( haystack, i, STRLEN( needle ) ); // return previous + replace + rest EXIT( COPYSTR( haystack, 1, i - 1 ) + replace + STRREPLACE( COPYSTR( haystack, i, STRLEN( haystack ) - i + 1 ), needle, replace ) ); END; // needle found
avoids to replace any already replaced values who contain the needle again. \:D/0 - 
            Thanks for sharing. The previous stringreplace function i found was running forever if you replaced "needle" by "needle two".. ](*,)0
 
Categories
- All Categories
 - 73 General
 - 73 Announcements
 - 66.6K Microsoft Dynamics NAV
 - 18.7K NAV Three Tier
 - 38.4K NAV/Navision Classic Client
 - 3.6K Navision Attain
 - 2.4K Navision Financials
 - 116 Navision DOS
 - 851 Navision e-Commerce
 - 1K NAV Tips & Tricks
 - 772 NAV Dutch speaking only
 - 617 NAV Courses, Exams & Certification
 - 2K Microsoft Dynamics-Other
 - 1.5K Dynamics AX
 - 323 Dynamics CRM
 - 111 Dynamics GP
 - 10 Dynamics SL
 - 1.5K Other
 - 990 SQL General
 - 383 SQL Performance
 - 34 SQL Tips & Tricks
 - 35 Design Patterns (General & Best Practices)
 - 1 Architectural Patterns
 - 10 Design Patterns
 - 5 Implementation Patterns
 - 53 3rd Party Products, Services & Events
 - 1.6K General
 - 1.1K General Chat
 - 1.6K Website
 - 83 Testing
 - 1.2K Download section
 - 23 How Tos section
 - 252 Feedback
 - 12 NAV TechDays 2013 Sessions
 - 13 NAV TechDays 2012 Sessions