on 07-25-2019 4:00 AM
Hi Experts,
I defined a code list data type using a business configuration object with the fields below:
and the field values are 139 items/cities:
Now what I am trying to do in ABSL script is to get the "Type code for City"(the 3 digit number) given the "Name of City"(the Description), however the only way I can think of is to have 139 if-else statements or 139 switch-case condition like the code below, is there other way I can implement this, I saw one using querybyelements but I dont know how to code/implement it, hope you can show me how to code/implement this using query by elements.
var code;<br>if (Name of City == "Angeles") {<br> code = "001";
} else if (Name of City == "Antipolo") {
code = "002";
} else if (Name of City == "Bacolod") {
code = "003";
} else if .....
Hi Lenorsi,
As you mentioned you can use the QueryByElements to Query the BCO
For example:
var QueryBCO=CitiesBCO.QueryByElements;
var SelParams=QueryBCO.CreateSelectionParams();
SelParams.Add(QueryBCO.CitiesBCOCode.content,"I","EQ",001);
var ResultsSelection=QueryBCO.Execute(SelParams); //Here you can filter by the selection parameters
var Results=QueryBCO.Execute(); //Here you retrieve all the Cities (Values) from the BC Set.
Thanks,
Piotr.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Piotr,
Thank you for answering.
What I need is to have the "Code" (001, 002, 003, 004.....) given the Value/Description ("Angeles", "Antipolo", "Bacolod", ... ), what you gave is the other way around. As an example, lets say I have
var value = "Angeles";
how do I get its corresponding "Code" which is 001
Hi Lenorsi,
To do that you just apply the reverse logic i.e
SelParams.Add(QueryBCO.CONTENT.content,"I","EQ","Angeles"); //Here we are using CONTENT instead of CODE.
var ResultsSelection=QueryBCO.Execute(SelParams);
var CityCode=ResultsSelection.GetFirst().NAME.Content;//Here we are accessing the Query results and assigning the corresponding code(001) to the CityCode variable.
If this answers your question please mark the Question as Answered,
Thanks,
Piotr.
User | Count |
---|---|
75 | |
10 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.