AppGiniField('field').getValue() ... with version 2022.12.09

This sub-forum is for discussing all topics related to AppGini Helper JavaScript Library, provided by bizzworxx as a third-party AppGini plugin.
Post Reply
mberthiaume
Posts: 5
Joined: 2021-12-07 17:58

AppGiniField('field').getValue() ... with version 2022.12.09

Post by mberthiaume » 2023-03-06 03:25

Hi Team bizzworxx,

today, I upgraded to version 2022.12.09

After the update ... I have now an issue with getValue() ... everything worked ok with the previous version 2021.07.29

Example:
var dv = AppGiniHelper.DV;
var ACTION = AppGiniField('ActionR').getValue(); ... not work now :?:

Does the syntax changed in the new version ?

Thank's for your help

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: AppGiniField('field').getValue() ... with version 2022.12.09

Post by jsetzer » 2023-03-06 06:03

Can you please give me more details:
  • Datatype settings of that field "ActionR"
  • Does the problem occur in readonly- or in edit-mode?
  • What is the expected result and what is the actual return value?
  • Is it on load or later on? For lazy-loaded fields (like lookups) you will have to wait for them.
  • Are there any (red) error messages in console tab? Fix them first!
  • Are there any (yellow) warning messages in console tab, starting with "AppGiniHelper |"?
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: AppGiniField('field').getValue() ... with version 2022.12.09

Post by jsetzer » 2023-03-06 06:34

By the way:
If you send your order number to me by email, within your 1-year-free-updates period I can send the latest version to you. There have been some improvements to .getValue() function recently.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: AppGiniField('field').getValue() ... with version 2022.12.09

Post by jsetzer » 2023-03-06 08:32

Does the syntax changed in the new version ?
No, but I recommend using...

Code: Select all

var field = AppGiniHelper.DV.getField("FIELDNAME");
var field_value = f.getValue();
...instead, which should be a little more performant if you use the field more often in the same script.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: AppGiniField('field').getValue() ... with version 2022.12.09

Post by jsetzer » 2023-03-06 08:51

var ACTION = AppGiniField('ActionR').getValue();
If ActionR-field is a lookup (which I cannot see from your bugreport), remember that .getValue() returns an object, having id and text, not a simple type value.

Check return value in console:

Code: Select all

var field = AppGiniHelper.DV.getField("FIELDNAME");
var field_value = f.getValue();
console.log(field_value);
Examples

Here are two examples, directly from console.

chrome_44wrKVe0kX.png
chrome_44wrKVe0kX.png (5.6 KiB) Viewed 2733 times
  • First calls .getValue() on a field which is VarChar[100] field, converted to color-picker by using dv.getField("varchar").toColorPicker(); (just an example from a previous forum thread)
    chrome_gC5Dj0ch31.png
    chrome_gC5Dj0ch31.png (766 Bytes) Viewed 2733 times
    .getValue() evaluates as a (simple-type) string.
  • Second calls .getValue() on a field which is a Lookup field (unsigned int).
    chrome_TfUcU91zKQ.png
    chrome_TfUcU91zKQ.png (2.11 KiB) Viewed 2733 times
    getValue() evaluates as an object, having id and text properties.
Tip (1)

Use field_value.id and/or field_value.text for getting the id or the text of the selected entry of a lookup field, if set.

Tip (2)

If you only need the text-value of a lookup-field's selection, you can use .getValue(true):

chrome_Lxh9RfSC3p.png
chrome_Lxh9RfSC3p.png (2.33 KiB) Viewed 2733 times

Tip (3)

If there is no selection, yet, .getValue() returns null and getValue(true) returns an empty string:

chrome_ZV4NHbSwNy.png
chrome_ZV4NHbSwNy.png (1.5 KiB) Viewed 2733 times
chrome_YQQ6w4PEvT.png
chrome_YQQ6w4PEvT.png (3.92 KiB) Viewed 2733 times
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

mberthiaume
Posts: 5
Joined: 2021-12-07 17:58

Re: AppGiniField('field').getValue() ... with version 2022.12.09

Post by mberthiaume » 2023-03-06 22:39

Hi Jsetzer ,

Wow ... very fast answer !!!

I will try it this evening (I live in Canada ... not the same time zone)

P.S: I like the AppGINI Helper ... it save a lot of time ... very cool to use it :)

Best !!!

Michel Berthiaume

mberthiaume
Posts: 5
Joined: 2021-12-07 17:58

Re: AppGiniField('field').getValue() ... with version 2022.12.09

Post by mberthiaume » 2023-03-07 00:02

Great !!!

var ACTION = AppGiniField('ActionR').getValue(); ... not work before.

Now: var ACTIONR = AppGiniHelper.DV.getField("ActionR").getValue(); ... Work A1 :)

Thank's for your time !!!

Regards

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: AppGiniField('field').getValue() ... with version 2022.12.09

Post by jsetzer » 2023-03-07 14:29

var ACTION = AppGiniField('ActionR').getValue();
Arghhh, I have just seen why your original code did not work. I have missed that before :?
You can still use the "old" constructor, but this requires a "new" keyword:

Wrong

Code: Select all

var ACTION = AppGiniField('ActionR').getValue();
Right

Code: Select all

var ACTION = new AppGiniField('ActionR').getValue();
In other words

Code: Select all

// deprecated
var field = new AppGiniField('FIELDNAME');
var field_value = field.getValue();

Code: Select all

// recommended
var field = AppGiniHelper.DV.getField('FIELDNAME');
var field_value = field.getValue();
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: AppGiniField('field').getValue() ... with version 2022.12.09

Post by jsetzer » 2023-03-07 14:31

Pro-Tip

If you declare the (Javascript) DV-variable in hooks/header-extras.php already, you don't have to declare it in every DV.

Code: Select all

<!-- file: hooks/header-extras.php -->
<script>
var DV = AppGiniHelper.DV;
</script>
DV will be available automatically in each hooks/TABLENAME-dv.js:

Code: Select all

// file: hooks/TABLENAME-dv.js
var field = DV.getField("fieldname");
var field_value = field.getValue();
console.log(field_value);
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Post Reply