Solved

@cursor_to_col_id with different columns in different screens

  • 28 February 2024
  • 4 replies
  • 45 views

Userlevel 3
Badge +5

Hi I have to use the@cursor_to_col_id in my default for a view.
But that view is exposed on 2 seperate screens and both of them need a different column to get the focus.
But because it is a single view both screens will use the same default…
As far as I'm aware I cannot filter on variant either inside a default? Otherwise I could use 2 variants.
I can't retrieve the parent (both are details of a different parent) as well I think?

 

 

icon

Best answer by Mark Jongeling 28 February 2024, 16:08

View original

4 replies

Userlevel 7
Badge +23

Hey Alban,

One trick you could use is a hidden column that has a default value in your View via its column settings. The View then can have two variants, let's say VariantA and VariantB. The default value for this column can then be altered in the respective variants. That value then can be used in the Default logic of the View.

Example, column named ref_location, in VariantA default value locationA, in VariantB default value locationB

Your code could then do the following:

if @cursor_from_col_id = 'columnA'
and @ref_location = 'locationA'
begin
print 'A'
end

if @cursor_from_col_id = 'columnB'
and @ref_location = 'locationB'
begin
print 'B'
end

So yes, the variant_id is not a given in the Default logic, but you can mimic that using this trick. An idea for that was raised here: variant_id for layouts, contexts, defaults | Thinkwise Community (thinkwisesoftware.com)

Userlevel 3
Badge +5

Hey Alban,

One trick you could use is a hidden column that has a default value in your View via its column settings. The View then can have two variants, let's say VariantA and VariantB. The default value for this column can then be altered in the respective variants. That value then can be used in the Default logic of the View.

Example, column named ref_location, in VariantA default value locationA, in VariantB default value locationB

Your code could then do the following:

if @cursor_from_col_id = 'columnA'
and @ref_location = 'locationA'
begin
print 'A'
end

if @cursor_from_col_id = 'columnB'
and @ref_location = 'locationB'
begin
print 'B'
end

So yes, the variant_id is not a given in the Default logic, but you can mimic that using this trick. An idea for that was raised here: variant_id for layouts, contexts, defaults | Thinkwise Community (thinkwisesoftware.com)

That's an interesting solution :) Thanks!!!!!

Userlevel 1
Badge +4

Hey Mark, does this logic also apply to tables, or only to views? I'm trying to figure this out, but i cannot get this to work. I’ve defined a expresson column with default expression ‘select null’. This is overwritten on the column settings on the variant with a hard coded variant name, but the value is not filled out in the form, when i start editing a record.

Userlevel 7
Badge +23

Hey Mark, does this logic also apply to tables, or only to views? I'm trying to figure this out, but i cannot get this to work. I’ve defined a expresson column with default expression ‘select null’. This is overwritten on the column settings on the variant with a hard coded variant name, but the value is not filled out in the form, when i start editing a record.

Also works for tables. You say you use a default expression, as in the default value expression? It's better to use the expression query. The field itself can be set Hidden, but then always has the value set in the expression query. The default value expression is used for the database table as default value.

Reply