SmartBusinessEntityLookup
 
Forums / SmartComponent Library - Developer Forum / SmartBusinessEntityLookup

SmartBusinessEntityLookup

6 posts, 1 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    19 Nov 2018
    Link to this post
    We just started trying to use these and have them working. Is there a way to add an extra entry to the select dialog that is not in the DB table? For example, we support values of 0 or "" depending on data type which would be the initial value. After selecting a record from the SME Lookup in order to reset that back to 0 or "" the user would have to clicking into the field and clear the value. We would prefer to set READ-ONLY = TRUE for the control and force the user to click the editor button and choose a record with 0 and a Description of "None".

    Maybe  in "AfterInitializeBusinessEntityAdapter" I can add the extra record? Is there a better place?
  2. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    Answered
    20 Nov 2018 in reply to Roger Blanchard
    Link to this post
    I typically solve those requirements by adding a second editor-button with a "clear" function.

    Injecting an empty record is something I have never tried.

    I would expect that the AfterInitializeBusinessEntityAdapter event is too early. As the RetrieveData is called after that. However in that event you are receiving the reference to the actual SmartBusinessEntityAdapter. I would actually try to solve this on the backend - use the AfterInitializeBusinessEntityAdapter event to set the Business Entity Adapter's "CustomContext" property to a value like "IncludeFlagValue". Then in the Business Entities's override of the FetchData() method (the one with the IFetchDataRequest parameter), do the 

    SUPER:FetchData (poFetchDataRequest) .

    and then 

    IF poFetchDataRequest:CustomContext = "IncludeFlagValue" THEN DO:
      /* create the extra record */
    END.

    There may be complications with batching that require fine tuning though. Is it o.k. to set the BatchSize to 0 ?

    For small sets of data, I'd go with the SmartComboEditor instead. This supports a "flag" value which is typically either the "none" or "all" kind of entry.
  3. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    20 Nov 2018 in reply to Mike Fechner
    Link to this post
    batch-size of 0 would be fine.

    I will look at the smartcombo.

    thanks.
  4. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    20 Nov 2018 in reply to Mike Fechner
    Link to this post
    Hi Mike,

    I ended up going with the SmartComboEditor as you suggested. The FlagText and FlagValue are extremely useful.

    For larger sets of data we will use the SmartBusinessEntityLookup and add a "RESET" button.

    Thanks!!
  5. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    20 Nov 2018 in reply to Roger Blanchard
    Link to this post
    Please use the SmartComboEditor - not the SmartCombo.
  6. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    25 Nov 2018 in reply to Mike Fechner
    Link to this post
    Yes, that is what we used and it is working great. 

    Thanks
6 posts, 1 answered