Use Update Trigger to Chnage the value in Linked Record
Hi,
I hope you can help. I want to change the value on a linked table field Features.'Features (English)' to the value "Disposable". It is driven by a change in a field on the Products table with the following code in the after update section. Any ideas why it does not work?
let t := this;
let x := text('Main Category (English)'.'Product Type (English)');
let y := t.Features.'Features (English)';
if x = "Cups" or x = "Napkins - Christmas" or x = "Napkins - Party" or x = "Plates - Baby" or x = "Napkins - Wedding" or x = "Plates - Christmas" or x = "Plates - Party" then
y := "Disposable"
end
10 replies
-
I should have mention it is all doen from within the Products form.
-
Try:
let t := this;
let x := text('Main Category (English)'.'Product Type (English)');
if x = "Cups" or x = "Napkins - Christmas" or x = "Napkins - Party" or x = "Plates - Baby" or x = "Napkins - Wedding" or x = "Plates - Christmas" or x = "Plates - Party" then
t.Features.'Features (English):= "Disposable"
endSteven.
-
Hi, Thank you for your suggestion. It still does nothing I am afriad. This is what I have in the sytem now.
let t := this;
let x := text('Main Category (English)'.'Product Type (English)');
if x = "Cups" or x = "Napkins - Christmas" or x = "Napkins - Party" or x = "Plates - Baby" or x = "Napkins - Wedding" or x = "Plates - Christmas" or x = "Plates - Party" then
t.Features.('Features (English)' := "Disposable")
end -
It reformats the equation for some reason?
t.Features.'Features (English)' := "Disposable" to
t.Features.('Features (English)' := "Disposable")
-
t.Products.Features.'Features(English)' := "Disposable"
Sorry i'm on my iphone(i can't test it)
Steven
-
In the "Products" table, is the reference to the "Features" table 1:N or N:1?
-
Hi,
Thank for the info. Unfortunaly the following line gave an error (field not found):
t.Products.Features.'Features(English)' := "Disposable"
The Products table can reference the Features table once but you can have as many Disposibale products (fropm Features) as you want...so I think it is N:1?
Thanks Matt
-
Hi Matt
You don't need to set t because Features is a reference from Products, so your code can become
let x := text('Main Category (English)'.'Product Type (English)');
if x = "Cups" or x = "Napkins - Christmas" or x = "Napkins - Party" or x = "Plates - Baby" or x = "Napkins - Wedding" or x = "Plates - Christmas" or x = "Plates - Party" then
Features.('Features (English)' := "Disposable")
endCheck that your if statement is working. All the text has to be exact in spaces, case, etc. I would be adding a reference field to your 'Main Category (English)' table and testing on that instead
if x = "CAT01" or x = "CAT02" ...
Regards John
-
On reflection
I would add a Yes / No field to your Main Category (English) table. Call it Disposable and set it to Yes where Product Type (English) s "Cups", "Napkins - Christmas", etc. I don't think you need the text function as we are testing a related table not a choice field, so your code would become
if 'Main Category (English)'.Disposable = 1 then
Features.('Features (English)' := "Disposable")
endRegards John
-
Hi John, Thanks for the feedback. I was overcomplicating it. It just needed 'Features := 1;' where 1 is the Disposible ID in the Features table. Thank you. Matt
Content aside
- 3 yrs agoLast active
- 10Replies
- 715Views