0

Populate text field based on selected option from a DCF

Hello 

I am trying to populate the email field based on the selected contact person option from the Dynamic Choice Field on the Sale Order form.

I am writing code in "Trigger After Update" of the DCF (code is as below), but the alert shows blank although contactPerson shows the correct value in the alert.

let contactPerson := text(this.'Contact Person');
let rec := (select 'Client Contacts' where upper(trim('Full Name')) = upper(trim(contactPerson)));
alert(rec)

 

How can I populate the email address and mobile fields based on the selected value in DCF ?

2 replies

null
    • Fred
    • 2 mths ago
    • Reported - view

    I suspect you are seeing a blank alert() is because when you do a select Ninox with no fieldname, Ninox always returns what appears to be blank but isn't. Ninox just doesn't know what to show you.

    If you change the code to:

    let contactPerson := text(this.'Contact Person');
    let rec := (select 'Client Contacts' where upper(trim('Full Name')) = upper(trim(contactPerson)));
    alert(debugValueInfo(rec))
    

    then you should see nid(some data).

    When working with dynamic fields the one function that comes in handy is record(), well and number() or numbers(). Since you have already selected the record you want in the dynamic field, no need to do a select just use record() and number() to get the record.

    let contactPersonRec := record('Client Contacts',number('Contact Person'));
    alert(contactPersonRec.email)
    

    If that all works you can modify it to set the fields you want to the data you want.

      • Database App Developer
      • vermau81
      • 2 mths ago
      • Reported - view

       Thank you Fred. It worked like a charm.

Content aside

  • Status Answered
  • 2 mths agoLast active
  • 2Replies
  • 41Views
  • 2 Following