web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Finding the start of string

(0) ShareShare
ReportReport
Posted on by

Im looking to write an if statement as follows:

If the string begins with "abc" then changecompany to 1

If not then changecompany to 2.

Im new to c/al so I do not know how to do this.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Zaid Tariq Profile Picture
    2,274 on at

    Hi,

    Do like as follow:

    TextToCompareWith := 'abc';
    IF COPYSTR(MyString,1,STRLEN(TextToCompareWith)) = TextToCompareWith THEN
    MyRec.CHANGECOMPANY('MyCompanyName 1')
    ELSE
    MyRec.CHANGECOMPANY('MyCompanyName 2');

    For more details have a look:

    [View:https://msdn.microsoft.com/en-us/library/dd338929.aspx:750:50]

    [View:https://msdn.microsoft.com/en-us/library/dd338944.aspx:750:50]

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans