Orchard CMS - Query based on values from ContentPicker - orchardcms

EDIT: Rephrased issue
I think there is either a bug or I am doing something wrong.
I add a field to the type Blogpost. This field is of type
Contentpicker. I call it Related Page.
Then I create to regular pages (ContentType Page).
I create 4 blogposts. Two blogposts get PageOne as selected value in the RelatedPage field. The other two posts get PageTwo as selected value in the RelatedPage.
Now I create a query with filter ContentType is BlogPost. And a filter with Blog Post.Related Page equals {21} (that is the Id of PageOne).
I would expect to get results BlogPostOne and BlogPostTwo. Instead I don't get results. Actually I wanted the pageid to be retrieved from the page the widget is placed on but couldn't get it to work, so I reduced back to a predefined value instead of dynamic for the filter. But like I said no results.
So is the query wrong and how should I do it then. Or is there a bug with filters for ContentPicker fields.
P.S. I will also submit an issue in Codeplex.
UPDATE
In Tokenizer all the values that contain { } are being seen as tokens and therefore are replaced. The problem is that the Ids of content items in a contentpicker field are stored with accolades. So when having {21} as the value for the filter, 21 gets tokenized and since there is no value for this token the value becomes empty. When skipping the tokenizer it works (while debugging). But one cannot skip the tokenizer, because it is very legitimate that there is a token present.
So I believe there is a bug with either the tokenizer, or the way the ids are stored in the contentitem field for contentpicker. I think it can be solved by changing the contentpicker to store numbers separated with comma's but without the accolades.

have you tried using the alias of the page instead of content id as the identifier? e.g. "/about-us", like you do in the layer rules.

Related

Request data format for category field update

I am using the podio-js package in a project designed to handle our invoicing. I am currently facing a problem in my attempts to update an item's category type field.
Here is the code I am currently running with:
const url = `/item/${item_id}/value/${field_id}`;
// newOptionId is the id of the option I want to switch to
const requestData = JSON.stringify({[field_id]: newOptionId});
const responseData = await this.podio.request('PUT', url, requestData);
I tried several other formats as described here: https://developers.podio.com/doc/items/add-new-item-22362, but every time I get the same result, it unselects the current selected option and leaves my category type field with no selected option.
Please provide me with the correct requestData format as I think the problem is coming from there.
Thanks.
The request format {value: your_id} is not supported anymore, it worked for me using this.podio.request('PUT', url, [myId]) to update a category field.
#Podio team: it would be cool to update and complete your documentation.
There are 4 slightly different ways of setting value to a field.
1. One when creating new item Podio: create item
2. Another one when updating whole item Podio: update item. This includes for example reverting to specific revision or setting each and every field including meta-fields like files, reminders, recurrences, etc.
3. Yet another one is updating item value Podio: update item value, which is updating whole item but only fields. So, it only accepts content that is inside fields parameter for methods #1 and #2 above.
4. And one more is for updating item field values Podio: update item field values. This one expects values for single field and only content of fields['field_id'] from methods #1 and #2 should be passed here.
Each way requires different format for value and uses different url.
I've updated documentation to include 2 cURLs examples for last 2 methods to make it clear, but will be happy to include additional explanations if you provide them.

Content Item tokens always coming through empty in Projection Query

I'm trying to create a Projection Query that has a Title Part filter based on a property of the current content item - let's say the Display Text ({Content.DisplayText}) for example.
The query is not working and when I debug the solution and set a break point on the GetFilterPredicate method of the StringFilterForm class the token value is always coming through as an empty string. It's as if it's not being resolved. I am seeing the same behavior for all the tokens in the Content Items group.
Other tokens are working just fine, like the QueryString ({Request.QueryString:*}) token for example.
Why are the Content Item tokens always coming through empty in my query filter? I'm using Orchard v.1.7.1.0
This is not how it works. Tokens are not meant in this context to generate query constraints on the content item properties. Tokens can only be used there to provide values for parameters of the query. If you want to filter on the title of a content item, use a title part record filter.
2 years later, but in Orchard 1.9.2 you can query based on the current content item using the token:
{Request.Content.*}
I was missing the Request part of the token. Not sure if this worked at the time I originally asked the question.

Sharepoint: Get form fields' display names from list

I am trying to extract the field names from a list, but only those that are normally displayed in the edit/view-form. However, it is turning out to be more difficult than first assumed.
Filtering fields by simply not taking those with SPField.Hidden == true still yields a lot of fields that are not relevant in this context. A standard document library yields this result as example:
FileLeafRef, Title, CaseID, DocID, Finalized, Related, RegistrationDate, ItemSelectField,
ExtendedDocIcon, CaseRecordNumber, Local_x0020_Attachment, ID, ContentType, Created,
Author, Modified, Editor, _CopySource, CheckoutUser, _CheckinComment, LinkFilenameNoMenu,
LinkFilename, FileSizeDisplay, Edit, _UIVersionString, ParentVersionString, ParentLeafName
I have taken the internal names because I have a danish localized version of Sharepoint, but you get the idea. In the above Title, CaseID, DocID and LinkFilename and perhaps some more fields will be relevant - one thing is for sure, less than half of these fields are displayed when you view the item or insert a new one.
I tried the SPField.ShowIn* (DisplayForm, EditForm, etc.) but they're all set to null or false for all the fields.
Try this:
Custom Fields Only From Sharepoint List
In addition to Hidden, try taking out Fields where:
ReadOnly is true.
Type is Computed
Group is _Hidden

Storing index values in FAST-ESP without modifications

first of all I'm totally new to FAST but I already have a couple of issues I need to solve, so I'm sorry if my questions are very basic =)
Well, the problem is that I have a field in the FAST index which in the source document is something like "ABC 12345" (please note the intentional whitespaces) but when stored in the index is in the form "ABC 123456" (please note that now there is a single space).
If I retrieve all the document values then this specific value is OK (with all the whitespaces), my only problem is with the way the value is stored in the index since I need to retrieve and display it to my user just like it appears in the original document, and I don't want to go to the full document just for this value, I want the value that I already have in the index. I think I need to update one of the FAST XML configuration files but I don't have enough documentation at hand in order to decide where to perform the change, index_profile.xml? in the XMLMapper file?
I've found the answer by myself. I'm using a XMLMapper for my collection, all I had to do was to add the ignore-whitespace attribute to the Mapping element and then set this attribute value to "false". This solved the problem and the raw data now when retrieved from the index contains the expected inner whitespaces.
Thanks.

How to create a lookup column that targets a Doc Lib and uses the 'Name' of the document?

How do you create a lookup column to a Document Library that uses the 'Name' of the document as the lookup value?
I found a blog post that recommends adding another custom field like "FileName" and then using a item reciever to populate the custom field with the value from the Name field but that seems cheesy.
Link to the blog in case people are interested:
http://blogs.msdn.com/pranab/archive/2008/01/08/sharepoint-2007-moss-wss-issue-with-lookup-column-to-doc-lib-name-field.aspx
I've got a bunch of custom document content types that I dont want to clutter with a work around that should really work anyway.
I created a one step workflow to set the title from the name, fired on modify and created. Seems to work and took seconds to create.
One way you can do this (although not the easiest way) is by creating a custom field type that extends the SPFieldLookup class. SharePoint's field editor for Lookup fields purposefully hides any columns types that aren't supported by Lookup fields, but you can create a field editor for your custom field type that shows them.
However, I have created a Lookup column that points to a Name column in a Document Library before, and it probably doesn't work like you'd expect. While the value stored in the lookup column is valid, it doesn't show up right in List view or on the View Properties form.
The solution you posted may actually be the best way to handle this. Lookup fields require some kludges if you want to handle more complex scenarios, but that's because they're not meant to provide the same functionality as a foreign key relationship in a database.
Coding in any form always scares me. So Here's what I did: I simply renamed the Stupid "Title" Field to something else, say "Keywords", since you cant do anything with that field: cant even make it mandatory.
Then I created another Single line field called "Title" and used this field for the Lookups
Well there is a simple solution to that and in might work in some case.
In the nutshell if you make the Title field Mandatory, this will force the user to enter a title. In that manner we can use title field as a lookup field.
Now How to do that?
One you are done create a document library go to the library setting. Select Advance Setting and Select Yes for the option "Allow management of content types?".
Then go back to the Library setting and Under content types select the "Document" Content type. THen Select Title Column and then Select "Required (Must contain information)" and say OK.
Now try uploading a document to this document library. You will see Title field in the form.
Hope this helps
Cheers
Vaqar
You have to add the field as XML with the ShowField as 'FileLeafRef'
var XmlFieldDefinition = "<Field DisplayName='myLookupColumn' Type='LookupMulti' StaticName='myLookupColumn' Name='myLookupColumn' Required='FALSE' List='THE LOOKUP ID HERE' WebId='THE WEB ID HERE' UnlimitedLengthInDocumentLibrary='TRUE' Mult='TRUE' Sortable='FALSE' ShowField='FileLeafRef' />"
Field fld = fieldCollection.AddFieldAsXml(XmlFieldDefinition, true, AddFieldOptions.DefaultValue);
ClientContext.Load(fld);
ClientContext.ExecuteQuery();

Resources