January 21, 2011

Add to My Links - Content Editor Webpart


<script language=”javascript”>

function addlink()

{

t=document.title;

u=escape(location.href);

var q='http://server:port/_vti_bin/portalapi.aspx?cmd=PinToMyPage&ListViewURL='+u+'&ListTitle='+t+'&ReturnUrl='+u;

location.href=q;

};

</script>

<a href=’#’  onclick=’addlink’>Add to My Links</a>

Unable to add selected webpart(s)

Our Favourite error:

Resolutions:
1. Code which needs higher access for ex, if we are dealing with AudienceManager etc etc. Keep the code in SPSecurity.RunWithEleveatedPrivileges.
2. As Usual, web.config, safe controls.
3. Sometimes, in the first step, you can add the webpart, but we get the error "HRESULT..DISP_E_Exception", same thing, RumWithElevated Privilelegs. Needs this when you are updating properties of the webpart etc.



January 04, 2011

DataView - Attachments - In Subsite

<WebPartPages:DataFormWebPart runat="server" ShowWithSampleData="False" AllowRemove="True" AllowHide="True" SuppressWebPartChrome="False" PartImageLarge="" ViewContentTypeId="" ExportMode="All" Dir="Default" MissingAssembly="Cannot import this Web Part." ID="g_c7ec8e24_ff10_46f1_936c_0daf5cc44068" DataSourceID="" IsIncludedFilter="" DetailLink="" AllowEdit="True" UseSQLDataSourcePaging="True" HelpMode="Modeless" IsIncluded="True" Description="" NoDefaultStyle="TRUE" FrameState="Normal" AllowConnect="True" ViewFlag="0" AllowZoneChange="True" AllowMinimize="True" Title="Advertisements" PartOrder="1" PageSize="-1" FrameType="None" HelpLink="" PartImageSmall="" ConnectionID="00000000-0000-0000-0000-000000000000" ExportControlledProperties="True" ChromeType="None" IsVisible="True" __MarkupType="vsattributemarkup" __WebPartId="{C7EC8E24-FF10-46F1-936C-0DAF5CC44068}" __AllowXSLTEditing="true" WebPart="true" Height="" Width=""><ParameterBindings>
<ParameterBinding Name="ListName" Location="None" DefaultValue="Advertisements"/>
<ParameterBinding Name="WebURL" Location="None" DefaultValue="/Subsite/"/>
<ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
<ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
</ParameterBindings>
<DataFields>

@Title,Title;@Brochure_x0020_Text,Brochure Text;@Brochure_x0020_Image,Brochure Image;@ID,ID;@ContentType,Content Type;@Modified,Modified;@Created,Created;@Author,Created By;@Editor,Modified By;@_UIVersionString,Version;@Attachments,Attachments;@File_x0020_Type,File Type;@FileLeafRef,Name (for use in forms);@FileDirRef,Path;@FSObjType,Item Type;@_HasCopyDestinations,Has Copy Destinations;@_CopySource,Copy Source;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;</DataFields>
<DataSources>
<SharePointWebControls:SPDataSource runat="server" DataSourceMode="List" SelectCommand="<View></View>" UseInternalName="True" ID="dataformwebpart2"><SelectParameters><WebPartPages:DataFormParameter ParameterKey="ListName" PropertyName="ParameterValues" DefaultValue="Advertisements" Name="ListName"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="WebURL" PropertyName="ParameterValues" DefaultValue="/Subsite/" Name="WebURL"></WebPartPages:DataFormParameter>
</SelectParameters><UpdateParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="EBBDF8F7-7651-419E-8139-E6E02821AB2D" Name="ListID"></WebPartPages:DataFormParameter>
</UpdateParameters><InsertParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="EBBDF8F7-7651-419E-8139-E6E02821AB2D" Name="ListID"></WebPartPages:DataFormParameter>
</InsertParameters><DeleteParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="EBBDF8F7-7651-419E-8139-E6E02821AB2D" Name="ListID"></WebPartPages:DataFormParameter>
</DeleteParameters>
</SharePointWebControls:SPDataSource>
</DataSources>
<Xsl>

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/">
<xsl:call-template name="dvt_1"/>
</xsl:template>
<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
<table border="0" width="100%" cellpadding="2" cellspacing="0">
<tr valign="top" style="visibility:hidden">
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
<th width="1%" nowrap="nowrap"></th>
</xsl:if>
<th class="ms-vh" style="visibility:hidden; width: 146px;" nowrap="">Advertisements Image</th>
<th class="ms-vh" style="visibility:hidden" nowrap="">Title</th>
<th class="ms-vh" style="visibility:hidden" nowrap="">Advertisements Text</th>
</tr>
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows"/>
</xsl:call-template>
</table>
</xsl:template>
<xsl:template name="dvt_1.body">
<xsl:param name="Rows"/>
<xsl:for-each select="$Rows">
<xsl:call-template name="dvt_1.rowview"/>
</xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">
<tr style="border-bottom:1px;border-bottom-color:grey;">
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">ms-alternating12345</xsl:attribute>
</xsl:if>
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
<td width="1%" nowrap="nowrap">
<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>
</td>
</xsl:if>
<td style="width: 146px;padding-bottom:8px;" >
<img border="0" src="{substring-before(@Advertisements_x0020_Image, ', ')}" alt="{substring-after(@Advertisements_x0020_Image, ', ')}"/>
</td>
<td colspan="2" valign="top">
<table>
<tr><td colspan="2"><strong><xsl:value-of select="@Title" /></strong></td></tr>
<tr><td colspan="2"><xsl:value-of select="@Advertisements_x0020_Text" disable-output-escaping="yes"/>
<xsl:element name="SharePoint:AttachmentsField">
<xsl:attribute name="runat">server</xsl:attribute>
<xsl:attribute name="FieldName">Attachments</xsl:attribute>
<xsl:attribute name="Visible">true</xsl:attribute>
<xsl:attribute name="ItemId">
<xsl:value-of select="@ID"/>
</xsl:attribute>
</xsl:element>
</td></tr>
</table>

</td>


</tr>
</xsl:template>
</xsl:stylesheet></Xsl>
</WebPartPages:DataFormWebPart>

Note: Instead of ListID use ListName
Note: WebURL : Instead of {sitecollectionroot} use / or /Subsite/
Note: Create the Lists in Subsite if we want to work with Attachements

Instead of:
<SharePoint:AttachmentButton ControlMode="Edit" Enabled="true" ItemId="{@ID}" runat="server" Visible="false"/>
<SharePoint:AttachmentsField ControlMode="Display" ItemId="{@ID}" EnableViewState="true" FieldName="Attachments" runat="server"/>

Use:
<xsl:element name="SharePoint:AttachmentsField">
<xsl:attribute name="runat">server</xsl:attribute>
<xsl:attribute name="FieldName">Attachments</xsl:attribute>
<xsl:attribute name="Visible">true</xsl:attribute>
<xsl:attribute name="ItemId">
<xsl:value-of select="@ID"/>
</xsl:attribute>
</xsl:element>

Note: Both are Same when rendered but first one works nicely when we have lists is Root. When We have Lists in Subsite go with the second option along with changing the ListName and WebURL attributes.

STSADM to Increase List Template Size to 500 MB

stsadm -o setproperty -propertyname max-template-document-size -propertyvalue 50000000

SonarQube with Jenkins Setup using Docker Images

https://funnelgarden.com/sonarqube-jenkins-docker/  https://medium.com/@hakdogan/an-end-to-end-tutorial-to-continuous-integration-and-con...