How to set Property value from resources.resx file to Xamdatagrid Field name property - infragistics

I want to set Name value of the xamdatagrid field from properties Resources file
xamdatagrid field name property

As answered here, you can use the x:Static markup extension:
<igDP:Field Name="{x:Static res:ResourceFileName.FieldName}"
You will need to declare the res namespace:
xmlns:res="clr-namespace:TheNamespaceOfYourResxFile"
And change the Access Modifier of the resx file to Public

Related

SharePoint - Programmatically set 'add to all content types' to false

While adding an existing site column to a SharePoint list, we get an option to set if the column need to be added to all content types or not.
I tried to un-check this property and the site column gets added to the library locally (i.e. without being used in any content type).
Add Columns from Site Columns
List of columns
How can I achieve it programmatically? Currently I am using below code which always adds the column to the default content type.
I do not want the column to be added to any content type.
if (!list.Fields.ContainsField(reportField.ToString()))
{
list.Fields.Add(reportField);
list.Update();
}
An option would be to use the [AddFieldAsXml][1] method and set the AddFieldOptions parameter to AddToNoContentType. See example below:
list.Fields.AddFieldAsXml(fieldSchemaXml, false, (AddFieldOptions.AddToNoContentType));
list.Update();
If building the field Schema XML is not an option, then you could set the content types to read only whilst you add additional fields then set them back after. This will stop all fields being added to the content types by the AddField method that you are currently using.
Method AddFieldAsXml makes it possible to set 'add to all content types' to false. Option 'AddToNoContentType' should be added to the method AddFieldAsXml as the 3rd parameter.
PowerShell script example:
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$ctx.Credentials = New-Object System.Management.Automation.PSCredential($Username, $(convertto-securestring $Password -asplaintext -force))
$fieldSchemaXml="<Field Type='Text' DisplayName='Name' Required='False' MaxLength='255' StaticName='Name' Name='Name' />"
#Add Column to the List
$List.Fields.AddFieldAsXml($fieldSchemaXml, $False, [Microsoft.SharePoint.Client.AddFieldOptions]::AddToNoContentType)
$List.Update()
$ctx.ExecuteQuery()
More detailed information about method AddFieldAsXml can be found in the documentation at the link: https://learn.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.spfieldcollection.addfieldasxml?redirectedfrom=MSDN&view=sharepoint-server.
More detailed information about all AddFieldOptions can be found in the documentation at the link: https://learn.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.spaddfieldoptions?redirectedfrom=MSDN&view=sharepoint-server.

How to create new tab that has style as Description tab for Stock Items?

I want to create new tab (Software Solution) and add new field (Solution) that is the same as Description tab to allow users put some description.
This is what I have done.
You need to use the PXRichTextEdit control to achieve that. The customization design will not allow you to pick this control type, so you will likely need to manually edit the ASPX file directly to add a PXRichTextEdit. From the layout editor, select Actions->Edit Aspx, and manually modify the ASPX to add your new control. You can then click the Generate Customization Script button to update the customization project.
This is how the Description tab looks like in the ASPX:
<px:PXTabItem Text="Description" LoadOnDemand="true" >
<Template>
<px:PXRichTextEdit ID="edMyField" runat="server" DataField="UsrMyField">
<AutoSize Enabled="True" MinHeight="216" />
</px:PXRichTextEdit>
</Template>
</px:PXTabItem>
The underlying database field needs to a nvarchar(max) field and the DAC property needs to be decorated with the PXDBText(IsUnicode=true) attribute. If you use PXDBString, the content will not save.
Unfortunately, the database schema tool included with Customization Projects does not allow you to add nvarchar(max) fields (the maximum length supported is 4000) and this is not enough. You can use the following T-SQL script instead and add it to the customization project:
IF NOT EXISTS (
SELECT *
FROM sys.columns
WHERE object_id = OBJECT_ID(N'[dbo].[Contact]')
AND name = 'UsrMyField'
)
BEGIN
ALTER TABLE [dbo].[Contact] ADD [UsrMyField] nvarchar(max)
END

Added a Field to WeBlog Entry template, trying to get the field in Category.ascx.cs

I have followed the steps in the following link Template Settings and created custom templates for Entry, Comment and Category. To the Custom Entry Template, I have added an additional field. I have a requirement to display it in the Categories.ascx. I am able to override the Categories.ascx but I am unable to get the value of the added field using WeBlog's API. Here's the code that I am using. But the issue is that the Class EntryItem doesn't have the additional field that I have added. Is there a way to read this field using WeBlog API?
EntryItem[] blogEntries = ManagerFactory.EntryManagerInstance.GetBlogEntries();
EntryItem inherits from CustomItem I believe, so you can use the InnerItem Property to get access to the actual Item. Your field should then be available like this:
entryItem.InnerITem["YouField"];
You can use a field renderer in the Categories.ascx file to display the value of you field and use data binding to get the item assigned to the field renderer.
<sc:FieldRenderer ID="FieldRenderer1" runat="server" FieldName="YourField" item='<%# entryItem.innerItem %>'/>
In Categories.ascx you can add this code to render the new field on the front-end:
<sc:FieldRenderer FieldName="Your New Field Name" ID="frNewField" runat="server" />
Then in the C# code-behind, add this code to data bind the front-end field renderer to the entry item's underlying Sitecore item:
frNewField.Item = entryItem.InnerItem;

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.

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}" />