How to hide custom picker field and display a textbox for creating new record when there is no matching data in selection

Certified Associate Developer

How to hide custom picker field and display a textbox for creating new record when there is no matching data available in custom picker in selection coming from DB & Vice-versa.

Can anyone help me out for this logic??

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    There are no ways to do this automatically within a custom picker, but about a thousand ways to handle it slightly more manually.  Such as, a button next to it that says "click here if no results are found..." or something else along those lines.

  • One note to add here is that how I sometimes implement this is by appending the search itself to the custom picker datasubset, so that if it is not present, it can still be selected within the same picker.  Downstream logic can identify if this entry is new or not.

    This snippet is from a Meeting Minutes app I have where meetings are linked by topic, if a new topic is being added it can be done via the same custom picker even if no related meetings are present:

    /* local!data from a!queryEntity().data */
    
      local!topics: append(property(local!data,"topic",null),ri!search),
      
      local!distinctTopics: reject(fn!isnull,rule!APN_distinct(local!topics)),
      local!top10: index(local!distinctTopics,enumerate(min(10,length(local!distinctTopics)))+1,null),
      a!dataSubset(
        startIndex: 1,
        batchSize: 10,
        totalCount: length(local!distinctTopics),
        data: local!top10,
        identifiers: local!top10
      )

  • 0
    Certified Lead Developer
    in reply to Chris

    By that same logic I suppose you could hard-code a selection along the lines of "<New Entry>" to always appear along with search options, and if that one is selected, trigger additonal on-form logic to type in text/etc (allowing for additional instructions and/or validations perhaps).  Honestly I haven't messed with this very much, other than a reusable component I made a long time ago to replace a people picker box with a people-from-DB-table picker (allowing even deactivated usernames to be chosen).