Page 1 of 1

Use dropdown value to populate a field

Posted: 26 Nov 2020, 00:01
by StuartB_75
Hi, I’ve searched the other posts but I can’t seem to find anything, so I’ll try and describe what I’m trying to do.

I have a dropdown field with several options. If a user selects a certain option I’d like another field in the same entity to populate with a defined value.

For example, if (field#149) is a dropdown with options: ‘No answer’, ‘dummy’ or ‘no access’ the I’d like the empty (field#600) to be populated with the value ‘N/A’.

I’ve tried to do it with an Ajax field, but that involves creating a new entity to hold basic values. It also doesn’t work with Display Rules to control the form.

Hope that makes sense. Any help would be much appreciated.
Stuart

Re: Use dropdown value to populate a field

Posted: 26 Nov 2020, 18:47
by enishemed
I think you can use MySQL formula field using CASE statement.

https://docs.rukovoditel.net/index.php?p=25

Re: Use dropdown value to populate a field

Posted: 26 Nov 2020, 20:46
by gpmio
Is the MySQL for numeric type field sonly? It is listed under 'Numeric'. I was trying to use MySQL to show the fefault email if there was not a billing email in the client table but i could not get it to return any data regardless of when the field was null or not

Re: Use dropdown value to populate a field

Posted: 30 Nov 2020, 15:49
by StuartB_75
Hi, and thanks to gpmio & enishemed for a little direction. I've tried to use the mySQL function of CASE but I don't get the result I'm expecting. I'm very new to SQL, so please bear with me, but I would really appreciate a little more direction if possible.
To recap, I have Entity #30 which contains Field #275 (a dropdown list). Within the several options in the list is #138 which I've given the value of '1'. Also within Entity #30 is Field #286 which is an input field set as text. The formula I've written is:

CASE
WHEN [275]=(138) THEN
([268]='TEST OF N/A')
ELSE 0
END

I was hoping that this would check field #275 and, if it was #138, then update the value of text field #268 with the phrase 'TEST OF N/A', but I get nothing happening at all. No errors created or anything, so I'm not sure what might be happening. If there's a SQL guru that might be able to assist it'd be much appreciated.
Thanks in advance
Stuart