Friday, August 3, 2018

Simple tool to replace a string or character in Microsoft Dynamics NAV


Image result for replace image
Ever got a task to replace a string or character in a string in Microsoft Dynamics NAV but unable to find the simplest solution for this problem.

Don't worry I have a simple solution for this task.



I have created a Codeunit which you can find below:


OBJECT Codeunit 50003 String Replaced
{
  OBJECT-PROPERTIES
  {
    Date=03-08-18;
    Time=12:10:48 PM;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    OnRun=BEGIN
            OldStringG    := 'OldString';
            ReplaceWithG  := 'New';
            SearchStringG := 'Old';

            NewStringG := ReplaceString(OldStringG,SearchStringG,ReplaceWithG);
            MESSAGE(OldStringG);
            MESSAGE(NewStringG);
          END;

  }
  CODE
  {
    VAR
      OldStringG@1000000001 : Text[250];
      SearchStringG@1000000002 : Text[250];
      ReplaceWithG@1000000003 : Text[250];
      NewStringG@1000000000 : Text[250];

    PROCEDURE ReplaceString@1000000007(OldStringP@1000000000 : Text[250];SearchStringP@1000000001 : Text[250];ReplaceWithP@1000000002 : Text[250]) NewStringL : Text[250];
    BEGIN

      NewStringL:= DELSTR(OldStringP,STRPOS(OldStringG,SearchStringP)) + ReplaceWithP + COPYSTR(OldStringP,STRPOS(OldStringP,SearchStringP) + STRLEN(SearchStringP));
    END;

    BEGIN
    END.
  }
}



You can modify this code according to your needs to make it suitable for your requirements.

Enjoyed the topic, Please do subscribe to our newsletter to get updated with every post without a miss.






Thanks for reading,
Shubin Dongre


5 comments:

  1. Listen to heard about this site many times. swankyonline slot machines I decided to go try. I really liked the design. Large selection of slots and slot machines

    ReplyDelete
    Replies
    1. I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts.
      Cyber Security Projects for Final Year

      JavaScript Training in Chennai

      Project Centers in Chennai

      JavaScript Training in Chennai

      Delete
  2. Microsoft Help is available online at their official website and it provides comprehensive Microsoft Help quickly and easily.reset windows 10 password

    ReplyDelete
  3. If you are looking for information on Cultural Blogs, Blogs Motorcycles and Cars Magazines, Blogs literature, Travel blogs and places around the world, Blogs Science and Technology, Blogs Books and Novel, Blog Latin American literature, visit the page CULTURAL BLOGS , is very interesting.

    ReplyDelete
  4. If you are new user to sage 50 accounting software and looking for the sage 50 technical support.If yes than you have come to right place as we provide efficient technical support service to customers who show complete faith in us. With our efficient and highly qualified team ,we never disappoint our customers.You can reach us at 1800-910-4754 at any hour of the day. You can also visit our website at https://www.geekaccounting247.com/ for the complete knowledge of the sage products and services.

    The Services we offered are following-
    Sage 50 Technical Support Number
    Sage 100 Technical Support Number
    Sage 50 live chat
    Sage 50 Technical Support phone Number
    Sage 50 support phone number

    ReplyDelete