Display multiple values from flowfiled as concatenated strin

NikolaNikola Member Posts: 7
edited 2013-07-23 in NAV Three Tier
Hi

I'm new to this

I have a FlowField with Lookup that returns multiple values

how do i concatenate the returned multiple values in a single comma separated string to display on the item card



Thanks

Nik




Display multiple values from flowfiled as concatenated string on page
C/AL; Flowfields; Flowfilter

Comments

  • lvanvugtlvanvugt Member Posts: 774
    Nikola wrote:
    I have a FlowField with Lookup that returns multiple values
    Hi Nikola, by default a FlowField evaluates to one value being, for example, the total amount of a number of records within the active filter setting of the FlowField. If you would drilldown from that FlowField you will see a number (0, 1 or more) of records. If these records (or probably only a specific field) are what you would like to display in "a single comma separated string" then I wonder why you are using the FlowField functionality and not code this. But maybe I misunderstand your need.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • NikolaNikola Member Posts: 7
    If these records (or probably only a specific field) are what you would like to display in "a single comma separated string" then I wonder why you are using the FlowField functionality and not code this.
    You are right, thats exactly what i want.
    I just was not sure how to go about this, I do not want the user to drill down to see the records, I already have that functionality.
    I want the user to just see a string of all records in format "1, 2, 3"
    Eventually I want the 1 and 2 and 3 to be links to external pdf documents on which the user can click from the Item card.
    I'm so new to this that i know what i can and want to do but just not to sure where and how.If you can recommend literature to read or point me to some examples on this I would appreciate it.
  • NikolaNikola Member Posts: 7
    ok
    So i did some reading
    and
    Created variable for the recordset and for the string on the item card page
    and did this code in the OnAfterGetRecord()
    // TEST CATALOG PAGE
    //_Catalog_Pages - Record variable
    //_Catalogs_String - Code(50) variable
    
    _Catalog_Pages.SETRANGE("No.","No.");
    IF _Catalog_Pages.FINDSET THEN BEGIN
        REPEAT
                _Catalogs_String := _Catalogs_String + ',' + _Catalog_Pages.Page;
        UNTIL _Catalog_Pages.NEXT = 0;
      END;
    
      _Catalogs_String := DELCHR(_Catalogs_String,'<',',');
    


    is this the right way to do this? is this the right trigger to use? will this create huge performance issue? is there a better way to do this?
    should i put this into a global function so i can call it from other places (like "Item List" or on other pages like fact boxes...)

    Thanks for your help, this is only my second day working in NAV.
  • MMVMMV Member Posts: 99
    Nikola,

    Your work around is ok. It's better to avoid coding in "OnAfterGetRecord" trigger, but there are some unavoidable situations. Anyway, as it's on the "Card" page, there won't be any performance issue (because card page reads only one record at a time.). As it's only a few lines of code, it's ok to be inline than creating a global function.

    BR,
    MMV
  • NikolaNikola Member Posts: 7
    what if i want to do this on Item List, will this be ok there, where i have 10000 records, which trigger is best to use then?
  • DenSterDenSter Member Posts: 8,307
    BlackTiger wrote:
    OnAfterGetRecord() is the only option.
    The only suggestion is to create a flowfield which counts number of linked records and do not call your code if number of records is 0.
    No this is not the only option.

    The BEST option is to figure out a way to make this look/feel like it belongs in NAV, and such a string is NOT it. If they really insist on having the string there, I would create a function in the Item card that returns the string, and set a textbox on the form to this function.

    Let's link this to the same discussion on DUG: http://dynamicsuser.net/forums/t/66522.aspx
  • NikolaNikola Member Posts: 7
    thats what i did
    thanks.


    we chose nav because of its flexibility to allow modifications, It is very important for our business for such information to be available right away.
    this is just one of several that we need to display this way. I will have at least 4-5 more that will use the same logic
  • NikolaNikola Member Posts: 7
    The only suggestion is to create a flowfield which counts number of linked records and do not call your code if number of records is 0.

    Thanks i already have the filed and sounds logical to use it in that way so it does not create unnecessary calls to the function.
  • DenSterDenSter Member Posts: 8,307
    Looks good, it just doesn't look like it belongs in NAV. Don't get me wrong, I am glad you found a way to make it work, I just question the design of the solution.

    The issue that I have with that is that it feels chaotic, not intuitive. This particular one looks like this, another one will look slightly different, and none of it looks like it belongs in NAV, so users will have to be trained on every individual modification. I'd have a count or a sum lookup flowfield that would show as a hyperlink on the page and when you click that it automatically pops up a drilldown page, without writing any code. From a development standpoint this is an easy change that you only do in the table, and it is inherited on all pages that use the table. Users already know about flowfields, they already know they can drill down, they already know what should happen. Add one to a page and they will recognize it immediately and know intuitively how to use it.

    Also, you probably programmed this on the page. This means that for the next page for the table, you will have to do the same programming there. Now you have issues with maintenance, what happens when you have to make a change to one of them, will you remember to also update the other pages? Also, you are limited by the maximum length of the string. Have enough catalog pages over time and at some point the string will be too long to display like that. The problem with that is that the compiler will not warn you about that, you will know about it when the user gets an datatype overflow runtime error message.

    For me it pays to design it like it belongs in NAV, I'll always push for that. In the end I feel strongly you will have the best user acceptance, and maximum efficiency using the program. You're right though, you paid for the ability to modify it however you see fit.
Sign In or Register to comment.