Solved

make LOV of existing field in Aurena?

  • 3 November 2021
  • 1 reply
  • 601 views

Userlevel 5
Badge +8

Hi Community,

 

   Anyone assist us that how can make a LOV of existing field in Aurena upd13.

   Thank in advance

icon

Best answer by Minoshini Fonseka 3 November 2021, 18:13

View original

This topic has been closed for comments

1 reply

Userlevel 7
Badge +19

@Adarsh 

LOV is a dropdown list of references that display values of one or more database columns.

Example 1
 This is a simple example using a reference and a selector


Client file:

lov CalendarIdRef with CalendarIdRefSelector {
size = Small;
}

selector CalendarIdRefSelector for WorkTimeCalendar {
static CalendarId;
static Description;
static Objstate;
}


Projection file:

@Override
entity LaborClass {
reference CalendarIdRef(CalendarId) to WorkTimeCalendar(CalendarId) {
label = "Calendar ID";
}
}


Example 2
Using a query and a list for the advanced view

Client file:

lov LineProgramRef with LineProgramSelector using LineProgramLovs {
label = "Program";
required = [false];
description = LineProgramRef.Description;
format = uppercase;
maxlength = 10;
advancedview LineProgramLovList;
}
@DynamicComponentDependency PROJ
selector LineProgramSelector for LineProgramLov {
title = "Program";
field ProgramId;
field Description;
}
@DynamicComponentDependency PROJ
list LineProgramLovList for LineProgramLov {
label = "Program";
static Company;
static ProgramId;
static Description;
}


Projection file:

@DynamicComponentDependency PROJ
entityset LineProgramLovs for LineProgramLov;
@DynamicComponentDependency PROJ
reference LineProgramRef(Company, LineProgramId) to LineProgramLov(Company,
ProgramId);
@DynamicComponentDependency PROJ
query LineProgramLov {
from = "project_program_lov";
where = "objstate in ('Active')";
keys = Company, ProgramId;
attribute Company Text;
attribute ProgramId Text;
attribute Description Text;
}


Example 3
Dynamically change values in LOV dropdown

Scenario
Instead of always getting the same records loaded into LOV dropdown there might be scenarios where you need to show a filtered set of values based on the other attributed in the record. For example, consider a driver who has the license to drive Manual vehicles, he is allowed to select a vehicle with Manual or Automatic transmission from the List of Vehicles, but a driver who has Automatic only driving license should only be able to pick the vehicles with Automatic transmission. It is always good to hide the unavailable LOV options for the user. To implement this in UXx you can use a function which returns a collection of entities as the data source for the LOV instead of an entityset. At runtime you can pass the values from other attributes as parameters into the function. In the function you can apply the necessary logic and send back the filtered set of records to the LOV. In this case you have the flexibility of writing any logic to get the correct records out of the function

Implementation

  • Consider the following reference:
reference MainRepresentativeRef(MainRepresentativeId) to
BusinessRepresentative(RepresentativeId);

 

  • First create a function in the projection file which returns a list of Entities, if your requirement is to simply filter the values based on a parameter, you can add a where clause inside the function implementation of the projection.
function GetRepresentatives List<Entity(BusinessRepresentative)> {
parameter RepresentativeId Text;
where = "representative_id LIKE SUBSTR(:RepresentativeId,1,1)||'%'";
}

 

  • But if you need to apply more advance logic to filter the values you can write your own function implementation in the PLSQL file.
function GetRepresentatives List<Entity(BusinessRepresentative)> {
parameter RepresentativeId Text;
}
FUNCTION Get_Representatives___(
representative_id_ IN VARCHAR2 ) RETURN Objid_Arr
IS
base_collection_ Objid_Arr := Objid_Arr();CURSOR Get IS
2018-10-29
144
SELECT *
FROM BUSINESS_REPRESENTATIVE
WHERE representative_id LIKE SUBSTR(representative_id_,1,1)||'%';
BEGIN
FOR rec_ IN Get LOOP
base_collection_.extend;
base_collection_(base_collection_.last) := rec_.objid;
END LOOP;
RETURN base_collection_;
END Get_Representatives___;

 

  • Then in the client file you can connect the function (together with parameters) in the same way you connect an entityset with an LOV.
group MainRepresentativeGroup for Activity {
lov MainRepresentativeRef with RepresentativeSelector using
GetRepresentatives(MainRepresentativeId) {
label = "Main Representative Id";
}
}


You can use the same reference with different LOVs populated using different entitysets and functions. In this way you can make sure that the user will get only the available options in the LOV.