populating a dropdown with information from the screen

Use this Forum to post tips and techniques for using aXes. Please explain in detail. This Forum is managed by the aXes user community. LANSA cannot guarantee the accuracy of any information posted to this Forum.

Moderator: jeanmichel

Post Reply
User avatar
Dino
Posts: 88
Joined: 19 May 2017, 08:29

populating a dropdown with information from the screen

Post by Dino » 22 Dec 2022, 05:05

Hi

Been playing today with this, the only particular detail is to be aware that the array is of an object that contains values and text.

So, if you have a screen like this one:
axesdd00.jpg
axesdd00.jpg (52.77 KiB) Viewed 17510 times
and you want to have the input field code, to have a dropdown, using the values listed below, you could first identify the screen, also identify the field containing the 1=aaa 2=bbb etc for example as "options", then, bring a dropdown in the input field "code", leave the dropdown as Fixed Values, and select the script for fixedValues, click edit:
axesdd01.jpg
axesdd01.jpg (109.09 KiB) Viewed 17510 times
you can use this script there for example, which basically moves the string in the screen to an array, temporarly each entry is also split by the = character and the two halfs are used to populate value and text, adding entries to the returnValue array:

Code: Select all

/* move the string 1=aaa 2=bbb etc to an array format {"1=aaa", "2=bbb", etc. } */
let arraytxt = (FIELDS("options").getValue()).split(' ');

/* clear the array */
ENV.returnValue = [];  

for (let i = 0; i < arraytxt.length; i++) {
  /* convert the array entry in another temporary array for example tmp[0] = 1, tmp[1] = aaa */
  let tmp = arraytxt[i].split('=');
  /* put it together as an object  and add it to the array*/
  var  object = { value: tmp[0], text: tmp[1]};
  ENV.returnValue.push(object);
}
more info here:
https://axesdocs.lansa.com.au/index.php ... 50cmllcyJd

Post Reply