Drupal 8 paragraph in rest export view - drupal-8

I have a view with a rest export display used to retrieve a custom content type made by some fields and a paragraph.
I'm not getting how to output the paragraph in the view, I don't see the filed or any reference to the paragraph field.
What I'm missing?

You should be able to add a relationship to your paragraph reference field, and then all of the paragraph fields will be available under fields.

Related

Save the dynamically populated value on dropdown

I'm using wagtail CMS for Django, I want to add a dynamically populated value for a dropdown and save it on the Page model, this is my code:
class MyPage(Page):
domain = CharField(max_length=10, choices=MY_CHOICES)
subdomain = CharField(max_length=10, choices=[('', '------')]
I've got some frontend logic to populate dynamically the options for subdomain, but after I hit save I got: The page could not be created due to validation errors And in the subdomain field: Select a valid choice. [my value] is not one of the available choices.
I can't use ForeignKey to populate subdomain because it depends from an external API service that we're using.
I tried to use a custom field that inherits from CharField with no success, it looks it executes validate method only for the domain field.
If you use the choices argument, you have to predefine the list of possible values. Read the relevant part of the docs (last two paragraphs of that section).
You could omit the choices argument from the model field definition and only render a HTML select tag in the frontend (which is then filled with options dynamically, like you explained).
You could also look into changing the default widget of the CharField to a select tag, like this answer and this part of the docs show.

Read values from Dynamics CRM Lookup Entity form

I have an entity Property which contains a field that is a lookup to the contact entity
On the Property form, I have displayed the Contact Entity using a custom form defined on the Contact entity. In my javascript code I want to read some field values from the Custom Contact form.
I have tried
Xrm.Page.getAttribute("fieldname")
Xrm.Page.getControl('contactformname').getAttribute('fieldname')
Neither of these work. Can someone help.
Thanks
I am assuming you have created a Quick View Form for Contact that is shown on the Property form.
You can get the value of fields in a Quick View Form using getControl().getAttribute().getValue(). In your case you would access the value of the field as follows, where you substitute the name of the Quick View Form and the name of the field for their real values:
Xrm.Page.getControl("contactQuickFormName_contactQuickFormName_contact_fieldname")
.getAttribute()
.getValue();

How do I get the value of a WFFM field as a tag and output it in a Sitecore DMS report?

If I create a Web Forms For Marketers form with Analytics enabled I can choose to add each field as a tag to a Visitor. I can't see how to configure which tag they should be added to, or even what the tag is called by default (I'm assuming a tag with the field name is created).
I'd also like to know how to retrieve the tag data in a visit report (i.e. the one you'd get if you double clicked on a form submission in the Form Reports dialogue). I can see how to access plenty of inbuilt tags, but I can't find out how to fill these specifically from the form, and I cant see any fields in the report designer representing the field names I have.
Question 1: How to set the name of the tag
If you set the "Tag" checkbox on the form field, the Item Name (=field name) of the form field is used as tag name.
If you have database access, you can check the "VisitorTags" table on the analytics database to see which tags are written and how they are called.
Question 2: Retrieve Tag data in visit reports
In the VisitDetail report, the following inbuilt tags will be displayed if set:
Email
First Name
Second Name
Company
Organization
Full Name
StateProvince
Name your form fields accordingly and the values will be used in the report out of the box.
If you want to use custom tags in reports, have a look at the .mrt files in /sitecore/shell/Applications/Reports/. You will have to extend the report to use your own tags.
Example: Adding a custom tag to the VisitDetail report.
Extend the SQL Query to fetch tags in the /sitecore/system/Settings/Analytics/Reports SQL Queries/Visits Visitor Tags item. Add the line
, MAX(CASE WHEN [TagName] = 'SomeCustomTag' THEN [TagValue] ELSE NULL END) [SomeCustomTag]
Extend the VisitDetail.mrt, add a column with value SomeCustomTag to the VisitorTags section just like the predefined tags.
Use the value of your custom tag inside the report text by using {Visit.VisitorTagsRelation.SomeCustomTag}
I use a text editor to edit the .mrt files, but you can probably also do it in Reports Designer.

In Django, how to validate a (multiple) cholice field when the choices are added by Javascript?

I have a ChoiceField where the choices are not known at the time the HTML is rendered; they are defined dynamically by the user and added to the form through Javascript, but the validation naturally fails since the selected option is not in the choices attribute (which is just an empty list). I have tried setting the field to a CharField, but then the validator just gets a string value that needs to be converted into a list before it van be used. Ah, and I'd like to avoid subclassing the field class as it's just for one occasion.
I hope this is clear. Any ideas?
Don't subclass the field class but override the clean_<yourfield> method in your Form class. See the docs here.

Sitecore: How to access same field name in different sections

I have data template dt1 in sitecore that has the field "header" in section "data".
I also have data template dt2 that has the field "header" in section "portal"
Finally I have data template dt3 that uses both dt1 and dt2 as base templates.
How can I, in xslt, find the content of portal/header?
In my code, when I write <sc:text field="header" />, I get the content of data/header (since this node comes first).
I know how to do this in .net, but I need to use xslt.
/callprat
I found a way around this in .Net on a project I was working on. One of the templates that the client had set up had "Buckets" which had different field sections, but the fields within were the same between buckets. I used LINQ to group the fields by Section name, then dealt with each grouping of fields.
var sections = currentItem.Fields.GroupBy(field => field.Section);
foreach (var section in sections)
{
if (section.Key.StartsWith("Bucket"))
{
buckets.Add(new Bucket(section)); //I made a bucket item,
//and passed each IGrouping<Field> to it
}
}
item.Fields.Where(field => field.Section.ToUpper() == "META DATA" &&
field.DisplayName.ToUpper() == "TITLE").First().Value;
You can't.
And frankly I don't know of any supported way to do it from .NET either.
This, straight out of the Data Definition Reference, section 2.1.1
2.1.1 Data Template Fields
A data template field defines the user
interface control and other properties
that influence how the field behaves
in the Content Editor and Page Editor.
For more information about fields, see
Chapter 4, The Template Field.
Note When defining field names, ensure
that they are unique even between
field sections. Both XSLT and .NET
code use field names alone, without
reference to sections, to extract
content from fields.
You can reference fields by their IDs:
C#:
string value = item["{00000000-0000-0000-000000000000}"]
or
Field field = item.Fields["{00000000-0000-0000-000000000000}"]
I haven't tried this, but I think it'll work in XSLT as well:
<sc:text field="{00000000-0000-0000-000000000000}" />