Query Datasource field data type and using it in scriban to fetch details of datasource item - sitecore

How to use 'Query Datasource' field data type so that I can point to another datasource item from my scriban item itself and able to retrive its (pointed datasource item) field values?
Any suggestion here?

Related

Get data based on sort index AWS dynamoDB

I have a DynamoDB table like this:
I want to list all posts irrespective of users, i-e by getting all data whose sort key is "post". How can I achieve this?
I have heard about Global Secondary Index, but couldn't figure out how to use them.
You create a global secondary index with a Key Schema like this:
Partition Key: SK attribute of the base table
Sort Key: PK attribute of the base table
It's called an inverted index. Then you can Query the Global Secondary Index by specifying the IndexName in the Query and search for all items that have "post" as the value for SK.

Oracle Apex Autocomplete Item to return ID value, not the lookup value

I have the table "SYMPTOMS" with two fields:
"ID" number and "SYMPTOM" varchar2(1000).
I want on my page the item "P2117_SYMPTOM_ID" to be autocomplete and search from the second field ("SYMPTOM") but to return the ID value of this record.
Check the docs. The page item type "Text field with autocomplete" only takes a single column as source (a return value), not 2 columns like a list of values. Reason is that this is an enhanced text field: you can freely enter data but it will suggest you possibilities from a list. A text field only has its actual value as return type too. You could have return ids from a table but then how would you handle values entered by the user that are not in the list ? If you want to map the data the user enters to an id then you can write your own function to do that. Ideally that function would:
Return the id of the value if it exists
Create a new value and return that newly created id if it doesn't exist.

How to create a field with a list of choices but store the index?

I'm making a Microsoft Access table where one of the fields is a list of pre-made options. When I make a SQL query on that table it returns the values of the list as strings containing the spelled out choice. I would like to assign numerical values to each element of the list so a SQL query returns a number instead. How do I do this? I know it's possible because I have an access file with such a list but I'm unable to recreate it.
An easy way to do this is to have your combo box use a query of the table as a Rowsource. This query would have the table unique ID in the first field and the field you wish to return as the second field. Then change the setting on the combo box for "Column Count" to 2. If you want to show both fields change the "Column Widths" value to 1"; 1". If you want to show only one field, change the value of one you do not want to see to 0. Now we you refer to this list in an SQL queries, it will use the ID field but show the user the string field.

fetch data in map from repository using JPA query

I want to get the data from table using this query:
select clientId, Count(countryID) from table groupBy countryID;
which gives me the count of country corresponding to clientId. Normally we fetch into the List<Object>.
How i can fecth these details into a Map<clientId, countryCount> with clientId as key and countryCount as value?

APEX dynamic tabular form field types

We are populating a subregion of a page with an Iframe (call to another page) with data for a questionnaire.
We have PAGE ITEM variables (:P37_... populated by query) that contain table values for P37_QUESTION_DESCRIPTION and P37_RESPONSE_TYPE.
The sub page used in the region (:P28_...) assigns report attributes for each column... where We populated the question text in the P28_QUESTION_DESC and a Y/N Select List defined list of values in the P28_RESPONSE_DESC_DISPLAY column. This works fine.
Now, the P37_RESPONSE_TYPE can more than just this Y/N Select List. It could be TEXTAREA, PICKLIST, DATE...
How can we define the :P28_RESPONSE_DESC_DISPLAY column dynamically to be any number of user input field types (based on the value in :P37_REPSONSE_TYPE?)
This was solved by using a non-tabular form report generated by query using apex.item functions. But is has left me with another problem. Here's the query:
select
apex_item.hidden(31,CASE_QUEST_DTL_ID) CASE_QUEST_DTL_ID,
apex_item.hidden(32,CASE_MGMT_BASE_ID) CASE_MGMT_BASE_ID,
apex_item.display_and_save(33,to_number(question_seq_no)) QUESTION_SEQ_NO,
apex_item.display_and_save(34,question_desc) QUESTION_DESC,
case when response_type = 'PICKLIST-YESNO' then apex_item.select_list_from_lov(35,response_desc,'YES_NO_SELECTLIST',NULL,'NO')
when response_type = 'TEXTFIELD' then apex_item.text(35,response_desc)
when response_type = 'TEXTAREA' then apex_item.textarea(35,response_desc,5,40)
when response_type = 'DATEPICKER' then APEX_ITEM.DATE_POPUP2(35,to_date(response_desc,'dd-mon-yyyy'),'dd-mon-yyyy')
end RESPONSE_DESC
from V_CASE_QUEST_LINK
where question_set_code like 'COB_Q%'
and case_mgmt_base_id = :P37_CASE_MGMT_BASE_ID
My problem is now grouping the questions by question_set_code. Because GROUP BY is evaluated after the select, it cannot simply be tacked on to the end of the query. I'm not sure that using a nested select will work here because of the apex.item calls. Anyone have a suggestion on how I can group these questions by the column?