Change Field Value based upon another value....

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
jonathan.ayres
Posts: 6
Joined: 2024-02-17 00:40

Change Field Value based upon another value....

Post by jonathan.ayres » 2024-12-18 02:52

Good evening all, have an issue that is making me pull my hair out (because I've forgotten how to make it work correctly!).

Have a field called "Oppstatus" that is a drop box with several values. (Open, Quoted, Approved, etc)
Have another field called "Probability" that is a drop box with percentages (0%, 10%, 20%, etc)

Whenever someone selects the value "Quoted", would like the percentage change to 30%, or if changed to "Approved", change to 90% - however, would still like the ability for the operator entering the data to manually override the percentage.

I think jquery is the way to go; but my brain is just not firing on all cylinders...

User avatar
Marcelo Vitoria
Veteran Member
Posts: 102
Joined: 2016-10-11 12:08

Re: Change Field Value based upon another value....

Post by Marcelo Vitoria » 2024-12-18 16:42

In the table where the "Oppstatus" field is, also insert the percentage field that you need to display.

When the user selects the value Open, Cited, Approved, etc., in the Probability field you configure it as a lookup field with autofill checked to pull the percentage value from the "Oppstatus" table, but this lookup field cannot be edited separately.

I hope this helps.
Marcelo Vitoria
Coding since 1982 ! :geek:
Basic Sinclar - Clipper - Visual Foxpro - VB6 - PHP
AppGini 24.18 - AdminLTE - SPM
https://www.workspaceservices.com.br/eng

jonathan.ayres
Posts: 6
Joined: 2024-02-17 00:40

Re: Change Field Value based upon another value....

Post by jonathan.ayres » 2024-12-19 18:39

Marcelo, thanks... That unfortunately doesn't allow the user to "override" the percentage. I built something like this a while back for product additions to quotes; where it would plug in "default" prices based upon the lookup, but would allow the user to override if we had special pricing for a particular reason...

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1709
Joined: 2018-04-01 10:12

Re: Change Field Value based upon another value....

Post by pbottcher » 2024-12-19 22:13

Hi,

it would be good to know what kind of dropdown you have. Is it a lookup, or an option list.
Logically you can register for the on change of the Oppstatus and based on the new fieldvalue you can trigger a change to the Probaility.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

jonathan.ayres
Posts: 6
Joined: 2024-02-17 00:40

Re: Change Field Value based upon another value....

Post by jonathan.ayres » 2024-12-20 00:59

The source dropdown is an option list; not a lookup.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1709
Joined: 2018-04-01 10:12

Re: Change Field Value based upon another value....

Post by pbottcher » 2025-01-03 15:00

Hi,

you may try this code in the hooks/TABLENAME-dv.js

Code: Select all

function switch_probability(prob) {
	$j('#Probabilit').select2().val(prob).trigger('change');
}

$j(function() {
	$j('#Oppstatus').on('change',function(e) {
		val=e.added.id;
		switch (val) {
			case 'Open':
				switch_probability('10%');
			break;
			case 'Approved':
				switch_probability('90%');
			break;
		}
	})
})
Like this the dropdown will adjust to 10% for open and 90% for approved, but remains editable.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply