0

Trigger after open problem

I'm trying to do simple switch, but it looks like i cannot select database...

select("Influencers")   -----> without this i got "Field not found", but with i got an error of "identifier exepted"
Status := if To > today() or To = today() then
        true
    else
        false
    end;
    end

5 replies

null
    • Bartosz_Polinski
    • 1 yr agoTue, June 13, 2023 at 11:50 AM UTC
    • Reported - view

    OK i solved it by myself ;)

    select'Influencers'.Status:= if To > today() or To = today() then
            true
        else
            false
        end

    • Fred
    • 1 yr agoTue, June 13, 2023 at 3:14 PM UTC
    • Reported - view

    Congrats on finding the solution.

    You can also write it like this:

    select'Influencers'.Status:= if To >= today() then
            true
        else
            false
        end
    
      • John_Halls
      • 1 yr agoTue, June 13, 2023 at 3:33 PM UTC
      • Reported - view

      Fred Hi Fred. I didn't think you could assign a value via a select statement without looping through the elements, or using first, last. It does work but it can generate some odd results. The following script

      let a := select Test;
      a.Text := a.Text + "s"

      used over four records with initial values for Text of "a", "b", "c", and "d" would expect to generate "as", "bs", "cs", and "ds", but instead it generates "abcds", "abcdsbcds", "abcdsabcdsbcdscds", and "abcdsabcdsbcdsabcdsabcdsbcdscdsds".

      Interesting!

      Regards John

      • Fred
      • 1 yr agoTue, June 13, 2023 at 3:37 PM UTC
      • Reported - view

      I was wondering how it would handle multiple records, but  said it worked so I trust his response. I was just showing how you can use the >= instead of do separate comparisons.

      • John_Halls
      • 1 yr agoTue, June 13, 2023 at 3:41 PM UTC
      • Reported - view

       Thanks Fred. Yes it does if it directly replaces the existing value like this

      let a := select Test;
      a.Text := "s"
      

      but produces odd results when interacting with the existing value.