Macro to list all documents field value only select list - kentico

I am trying to list all items in a section of Kentico as a drop-down list but want only one field value to be returned for each document.
What I have tried
Lists Nothing:
Documents.WithAllData["/Foo/Bar/Bar"].AllChildren.WithAllData.All.GetValue("FooBar")
Lists all document information:
Documents.WithAllData["/Foo/Bar/Bar"].AllChildren

You'd use a macro similar to this:
<select id="ddlItems">
{% Documents["/Foo/Bar/Bar"].Children.WithAllData.ApplyTransformation("cms.event.transformationname") %}
</select>
To list out all your items. The transformation will then have your column information:
<option>{% FooBar %}</option>
**** UPDATE ****
Based on your comment, you can simply use a sql query (which a macro will run anyway). If you know what page type you want to query you can go directly to that page type's table:
SELECT Col1, Col2, FROM Content_YourTable
If you need the data from your page type based on a particular path in the tree, then you can use something like this:
SELECT Col1, Col2
FROM View_CMS_Tree_Joined
INNER JOIN CONTENT_MenuItem on DocumentForeignKeyValue = MenuItemID
WHERE NodeAliasPath like '/Foo/Bar/Bar/%'
AND Classname = 'cms.menuitem'

Related

How to show last two rows only in tableview from sqlite using with QSqlQueryModel?

Below is my example code:
db = QSqlDatabase.addDatabase('QSQLITE')
db.setDatabaseName('book.db')
db.open()
model = QSqlQueryModel()
model.setQuery("SELECT * FROM card")
self.tableView.setModel(model)
I am using QSqlQueryModel, Qtablevie, Sqlite3, and able to view all rows in my table. But i want to view only last two rows of my table which are newly inserted rows in to the table. The table has no "id" field and it has numaric and text fields. How is it possible?
Below is the table image:
If you want to get the last 2 elements ordered by any field that indicates the insertion order, in your case "rowid", then you have to use a filter in the SQL command like this:
model.setQuery("SELECT * FROM card ORDER BY rowid DESC LIMIT 2")
Another possible option is to filter the table using QSortFilterProxyModel but it is more inefficient.

SQLite returns int instead of real

I'm working on a website in node js and use SQLite as a database for the first time.
I want to be able to use real for some form data and I noticed that every real in my database are converted to integer once the query is made.
To vizualize the database i am using DB Browser and i checked if the columns are defined as REAL which they are.
If i try to query a data set as 0.1 in my DB I get this :
sqlite> select step_variable
from variables
where id=38;
0.0
After trying as suggested the command TYPEOF(step_variable) it returned :
0.0|real
In the SQLite CREATE TABLE command, one defines a data type affinity, not a data type. SQLite supports the following five column affinities: TEXT, NUMERIC, INTEGER, REAL, NONE.
Thus the data type you specify when creating a table does not enforce a certain data type. You can supply any data type you want or even omit the data type.
CREATE TABLE table1(
column1 ABC,
column2 Others,
column3 WHATEVER);
CREATE TABLE table2(column1, column2, column3);
Populate tables:
INSERT INTO table1 VALUES( 1, 'my text', 123.45);
INSERT INTO table2 VALUES( 1, 'my text', 123.45);
Now let us check what SQLite made out of it:
SELECT column1, TYPEOF(column1) from table1
SELECT column2, TYPEOF(column1) from table1
SELECT column3, TYPEOF(column1) from table1
With:
column TYPEOF(column)
------------------------
1 INTEGER
my text TEXT
123.45 REAL
When you go through a query result e.g. by using sqlite2_step you can use the sqlite3_column_type statement to confirm the column type - unless you know the result anyway and simply cast the result to the data type expected.
Martin
I found the solution it was simply that i didn't save my file after modifying it.

How to collect data from a form and inset it in another sharepoint list

Good afternoon,
I am creating an app using sharepoint and powerapps, on powerapps I have a form that feeds from a sharepoint list. Now my problem is the following, when I create a new form I would like to submit from another sharepoint because it is going to be easier for me to create reports.
If I understood you correctly, you have a Form tied to a Sharepoint List and you want to copy its contents to another Sharepoint List with the same column structure. Is that correct?
If that is so, this is how you do it:
1) Add both SharePoint Lists (List1 and List2) as DataSources to your app
2) Set your form's Data source to List1
3) Select the fields you want to edit
4) Add a button to your form. Set the OnSelect value of the button to this:
Patch( 'List2', Defaults( 'List2' ), { Column1: val1, Column2: val2, etc.. } )
where val1, val2 etc.. are values you entered into your controls
Ex: = txtFirstName.Text, ddlStartDate.SelectedDate etc..
NOTE: Your column names have to match the exact spelling of the column names on List 2. If you have any multi word column names, put them in single quotes. Ex: 'First Name'
See: https://learn.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch
and https://learn.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-defaults

Sharepoint update Lookup Column

I am trying to update a Lookupvalue field "Items" via the SharePoint object model.
"Products" is a column in one list which is used as a lookup column to another list in field "Items".
In my webpart i have dropdown of Items now
string strItems = ddlItems.SelectedValue.ToString();
item["Items"] = new SPFieldLookupValue("strItems");
item.Update();
However, this is causing an error
Internally, SharePoint stores these references like this:
NumericID;#DisplayValue i.e.
145;#Soup
12;#Cake
874;#Steak
That is the kind of thing that should be in the constructor to SPFieldLookupValue. Or if it is more helpful, use the variant of the constructor that takes an int id and string display value.
More info is laid out here:
http://blogs.msdn.com/b/sridhara/archive/2007/08/25/update-quot-lookup-quot-fields-in-sharepoint-2007.aspx
You need to set the Items column to the ID of the SPItem represented by the product. You could do this by setting the DataTextValue of your dropdown to ID and then using the SelectedValue. You could also do a CAML query when a new item is selected in the dropdown.
You can find more information at the bottom of this blog post:
http://weblogs.asp.net/bsimser/archive/2005/05/13/406734.aspx

Complicated condition

I have predefined item combination (for example brand1|brand2|brand3 etc) in the table.
i like to collect brands and check against with predefined table data.
For example i collected brand1|brand2|brand3 then i can do get some value form that predefined table(it meets the condition).
How can i check?
brands would be unlimited. also brand1|brand2|brand3 of brand1|brand2| exist then returns true.
Okay, taking a wild guess at what you're asking, you have a delimited field with brands in them separated by a | character. You want to return any row that has the right combination of the brands in there, but don't want to return rows with, for example, brand "testify" in them when you search for "test".
You have four search conditions (looking for brand3):
the brand exists by itself: "brand3"
the brand starts the delimited field: "brand3|brand4|brand6"
the brand is in the middle of the field: "brand1|brand3|brand6"
the brand is at the end of the field: "brand1|brand2|brand3"
so, in SQL:
SELECT *
FROM MyTable
WHERE BrandField = 'brand3'
OR BrandField LIKE 'brand3|%'
OR BrandField LIKE '%|brand3|%'
OR BrandField LIKE '%|brand3'
Repeat as required for multiple brands.

Resources