Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV forum
Answered

FlowField based on code

Posted on by Microsoft Employee

I am disappointed to find that a FlowField cannot use a small amount of CAL code.
I am trying to calculate a substring of a UK Postcode on the Customer table, e.g.: AB12 3CD -> AB12
I have done this outside NAV in Excel reports by: PostcodeDistrict = Delete3CharsFromTheEnd(StripSpaces(Postcode))

What is the best way to do this in NAV to act just like a FlowField? In other words:

  • Is not stored in the database
  • Is available on the customer page
  • Is available on the web service

Thanks!
(For anyone wondering, I did it this way because the first part is not a fixed length.)

  • Jeremy Vyska Profile Picture
    Jeremy Vyska 727 on at
    RE: FlowField based on code

    If you add the variable to the Page and add the variable to the page just like you would a field, and the Web Service exposes the Page object, then you will see the variable just like any field.  Sounds like that will hit your needs.  Hope that helps!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: FlowField based on code

    Would the variable be defined on the Page or the Table?

    And once I added it to the page, would the Web Service (based on that page) automatically get that variable?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: FlowField based on code

    Thanks for the reply Jeremy.

    I prefer your first variable solution over creating and updating a new database field, since the data is already in the database.

  • Verified answer
    Jeremy Vyska Profile Picture
    Jeremy Vyska 727 on at
    RE: FlowField based on code

    Sadly, you just can't put code logic or even functions into FlowFields.

    Generally, you'd have to, on the Customer Page and in the Web Service you're exposing, set a variable, populate that variable with your logic during OnAfterGetRecord, then add the Variable to the page.

    Given the nature of the challenge you have, what you *could* do is make a new field that contains only the data you want.  Then, a quick bit of additional validation on the field when it changes to update the new PostPrefix field, along with a one-time run Processing Only routine that populates the data initially.

    Then you can do FlowFields all over the place against it.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans