0

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

null
    • Luck and Luck
    • Matthew_Luck
    • 2 yrs ago
    • Reported - view

    I should have mention it is all doen from within the Products form.

    • Ninox partner
    • RoSoft_Steven.1
    • 2 yrs ago
    • Reported - view

    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"
    end

    Steven.

    • Luck and Luck
    • Matthew_Luck
    • 2 yrs ago
    • Reported - view

    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

    • Luck and Luck
    • Matthew_Luck
    • 2 yrs ago
    • Reported - view

    It reformats the equation for some reason?

    t.Features.'Features (English)' := "Disposable" to 

    t.Features.('Features (English)' := "Disposable") 

    • Ninox partner
    • RoSoft_Steven.1
    • 2 yrs ago
    • Reported - view

    t.Products.Features.'Features(English)' := "Disposable"

    Sorry i'm on my iphone(i can't test it)

    Steven

    • Alain_Fontaine
    • 2 yrs ago
    • Reported - view

    In the "Products" table, is the reference to the "Features" table 1:N or N:1?

    • Luck and Luck
    • Matthew_Luck
    • 2 yrs ago
    • Reported - view

    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

    Capture

    • John_Halls
    • 2 yrs ago
    • Reported - view

    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")
    end

     

    Check 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

    • John_Halls
    • 2 yrs ago
    • Reported - view

    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")
    end

     

    Regards John

    • Luck and Luck
    • Matthew_Luck
    • 2 yrs ago
    • Reported - view

    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

  • 2 yrs agoLast active
  • 10Replies
  • 712Views