[Thisrow].[before] for a column in app

Hello. I have a โ€˜CUSTOMERโ€™ table with a column named โ€˜CUSTOMER IDโ€™ , โ€˜CUSTOMER NAMEโ€™.
I understand that I can get current rowโ€™s customerโ€™s name by using [CUSTOMER NAME] expression.
My question is: When I edit a certain row, if I want to refer to initial value of โ€˜CUSTOMER NAMEโ€™ (the valued being stored in database, not currently editing value), what should I do?
p/s: I can get it by
SELECT(CUSTOMER[CUSTOMER NAME] , [CUSTOMER ID] = [_THIS].[CUSTOMER ID])
Is there any shorter, more elegant way to do? I tried [_THISROW].[CUSTOMER NAME] but it does not return the text from that column.

Solved Solved
0 5 1,043
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Not really. The most succinct way is like this:

LOOKUP(
  [_THISROW].[CUSTOMER ID],
  "CUSTOMER",
  "CUSTOMER ID",
  "CUSTOMER NAME"
)

View solution in original post

5 REPLIES 5

Steve
Platinum 4
Platinum 4

Not really. The most succinct way is like this:

LOOKUP(
  [_THISROW].[CUSTOMER ID],
  "CUSTOMER",
  "CUSTOMER ID",
  "CUSTOMER NAME"
)

Thank you very much Steve.
While this partially resolved my problem, it is not exactly what I wanted.
My CUSTOMER TABLE has following columns: CUSTOMER ID (key column) , CUSTOMER NAME, CUSTOMER ADDRESS, SEX (with value {Male , Female}), and a virtual column named TEST.

I understand that if I want to get value from SEX column and assign it to TEST, then I simply put [SEX] at App formula field of column TEST. This works perfectly well.
But, example, row 1 of my CUSTOMER table has following value:
{โ€˜CUSTOMER IDโ€™ : โ€˜id01โ€™ , โ€˜CUSTOMER NAMEโ€™ : โ€˜Jane Doeโ€™ , โ€˜CUSTOMER ADDRESSโ€™ : โ€˜n/aโ€™ , โ€˜SEXโ€™ : โ€˜Maleโ€™ , โ€˜TESTโ€™ : โ€˜Maleโ€™}

During EDIT mode, which mean when I am editing โ€˜id01โ€™ customer, when SEX column value changed to โ€˜Femaleโ€™, I want the TEST column still holds the value of โ€˜Maleโ€™ as it is being stored in the database, not the value that user is changing.
Now, I can get this by using App formula:
SELECT (CUSTOMER[SEX] , [CUSTOMER ID] = [_THIS].[CUSTOMER ID])
or, I may use your suggested solution as
LOOKUP ([_THIS].[CUSTOMER ID] , 'CUSTOMER' , 'CUSTOMER ID' , 'SEX')
but it is way too long syntaxโ€ฆ
I thought that [_THISROW].[SEX] would return my expected value, but it doesnโ€™t.
Is there anything explicitly like [_THISROW].[SEX].[SERVER-STORED-VALUED] ?
If there isnโ€™t, then I am glad that I am using best of Appsheet already. Thank you very muchโ€ฆ

You want to set the Initial Value to [SEX]. Then it wonโ€™t change after edit unless you forcefully edit it.

No, thereโ€™s no simple way to reference the stored value. Youโ€™ll have to use SELECT() as you already are or LOOKUP() as I suggested. Both are equivalent.

Thank you. I have marked your answer as resolved solution.
P.s I still prefer SELECT to LOOKUP for easier syntax.

Top Labels in this Space