0

Double Search

I have a double search formula ( Name & Format)

let me := this;
let myArray := (select Albums);
if Search_1 then
    myArray := myArray[Name = me.Search_1]
end;
if Search_2 then
    myArray := myArray[Format = me.Search_2]
end;
myArray

But the problem is with Format (is a N:1 Relation from Albums) 

The Format is CD, Cd'2, Cd'3, MP3 etc 

Don't work 

17 replies

null
    • Fred
    • 8 mths ago
    • Reported - view

    Since Format is a relationship field. Data from that field will be returned in an array. You can use the contains() command to do searches in an array. If Search_2 returns record Id from the Format table, then it would look something like:

    myArray[contains(Format,me.Search_2)]
    
      • Rafael Sanchis
      • Rafael_Sanchis
      • 8 mths ago
      • Reported - view

      Fred Greetings

      No works give me a error.

      • Fred
      • 8 mths ago
      • Reported - view

       forgot that contains() likes the parts to be same data type. so you can wrap Format in a text() command. 

      myArray := myArray[contains(text(Format),me.Search_2)]
      
      • Rafael Sanchis
      • Rafael_Sanchis
      • 8 mths ago
      • Reported - view

       Hi Again

      No errors but only works with iD, if place text don't give me nothing

      • Fred
      • 8 mths ago
      • Reported - view

      Since Format is a reference field, so at the root level you only get record Id. If you want to search by data, i.e. MP3 or CD. Then you need to reference the field name in Format that stores that data.

      May I suggest that you change the Format search field into a dynamic choice field that points to Format so when you make a selection you get the same record Id then you can do easy searches.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 8 mths ago
      • Reported - view

      ok thanks I will try to change to dynamic filed. 

      • Rafael Sanchis
      • Rafael_Sanchis
      • 8 mths ago
      • Reported - view

       Hi Fred,  Works now with Dynamics Choice.

      Thanks.

      • Sam.1
      • 3 mths ago
      • Reported - view

       Hi Rafael,

      Do you have a small sample database with the double search (using the dynamic choice) to share?

      Thank you,

      Sam

      • Rafael Sanchis
      • Rafael_Sanchis
      • 3 mths ago
      • Reported - view

       

      Very simple Databse with double search by Name and Date From Date End

      • Sam.1
      • 3 mths ago
      • Reported - view

        Thanks Rafael!

      • Rafael Sanchis
      • Rafael_Sanchis
      • 3 mths ago
      • Reported - view

       I hope this help

      • Sam.1
      • 3 mths ago
      • Reported - view

       I'm Sure it will. However, I do not see the array code that is presented in this post.

      is it there? 

    • John_Halls
    • 8 mths ago
    • Reported - view

    Hi Rafael

    Try changing Line 7 to this

    myArray := myArray[contains(Format,me.Search_2)]

    Regards John

      • Rafael Sanchis
      • Rafael_Sanchis
      • 8 mths ago
      • Reported - view

       Hi John

      It doesn't work either, I'm doing something wrong.

    • Ninox developper
    • Jacques_TUR
    • 8 mths ago
    • Reported - view

    What is the type of the me.Seach_2 field?

    What is the type of the Albums.Format field?

      • Ninox developper
      • Jacques_TUR
      • 8 mths ago
      • Reported - view

       

      It seems that Albums.Format is a nid (pointer to the Format table) and not a text. Which field in the Format table is the text stored in?

      • Rafael Sanchis
      • Rafael_Sanchis
      • 8 mths ago
      • Reported - view

        The search_2 field is a text field and the Format is is a N:1 Relation from Album

Content aside

  • Status Answered
  • 3 mths agoLast active
  • 17Replies
  • 154Views
  • 5 Following