Saturday, July 25, 2015

The password supplied with the username Domain\UserName was not correct. Verify that it was entered correctly and try again

When you create New web application in SP2013 & you got the following error:-

Sorry, something went wrong:- The password supplied with the username Domain\UserName was not correct. Verify that it was entered coorectly & try again.

You can login in central admin with same username & password but you will prompt for new web application or existing web application.

For that, existing application check IIS & set username & password again in Application Pool of web application--> Advance settings.

If still the problem persist try the following command in powershell:-

stsadm -o updatefarmcredentials -userlogin Domain\UserName -password YourPassword



The above problem occur when farm account password is expire and it's password is changed or simply farm account password is changed.


Hope, this will help.. :-)

Saturday, August 24, 2013

Hide Upload,Multiple, Add Document link from library view for DocSet

The requirement is that to avoid user to create, edit and delete docset, but they can add, upload, edit document inside the Doset. Also, avoid user to add document outside the Docset. 

So for the above requirement, i had created css file and uplaod it to style library and add the path of file path on library view page, where docset available. The css available in my file is as below:-

TD.ms-addnew
{
DISPLAY: none !important
}
#Ribbon\.Documents\.New\.AddDocument-Large
{
display:none;
}
#Ribbon\.ListItem\.New\.NewListItem-Large
{
    display:none;
}
#Ribbon\.Documents\.New\.NewDocument-Large
{
   display:none;
}
#Ribbon\.Documents\.Manage\.EditProperties-Large
{
  display:none;
}
#Ribbon\.Documents\.Manage\.Delete
{
  display:none;
}
#Ribbon\.Documents\.Manage
{
  display:none;
}


and add the below javascript inside the doset page to hide the "View All Properties" and  "Edit All Properties".

<script language="javascript">
_spBodyOnLoadFunctionNames.push("HideShow");
 function HideShow()
{

   var EditProperties = document.getElementById ('EditPropsLink');
if(EditProperties != null)
{
   EditProperties.style.display = "none";
}
var ViewProperties = document.getElementById('ViewPropsLink');
if(ViewProperties != null)
{
 ViewProperties.style.display = "none";
}


}
<script/>
Happy coding..... :-)

Expand only the first group and have the rest of the groups collapsed in Dataform webpart SP 2010

Now, it is possible in DVWP to expand only the first group and have the rest of the groups collapsed.
Example:-
- Group: Year 2013
- Item 1
- Item 2
- Item 3
+ Group: Year 2012
+ Group: Year 2011
+ Group: Year 2010

Use the following steps:-

1) Create dataform webpart using Sharepoint designer and bydefault group is collapsed in dataform webpart.
2) Save the page and search webpart id for dataform webpart in view source of page. E.g In my case it is  MSOZoneCell_WebPartWPQ4. Search the id for div available in webpart, <div id="WebPartWPQ4".
3) Use the following script on page and replaced the WebPartWPQ4   with your dataform webpart div id.
<script src="https://Server/SiteName/Style%20Library/Custom%20Javascript/jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
functioncollapseGroups() {
var someimage = document.getElementById('WebPartWPQ4');     //Webpart Id available in div tag
var myimg = someimage.getElementsByTagName('img')[0];     //  It will check first group image(+) available in div tag
var mysrc = myimg.src;
   //alert(mysrc);
    //$("img[src='/_layouts/images/plus.gif']:visible").parent().click();
    $(myimg).parent().click();
}
_spBodyOnLoadFunctionNames.push("collapseGroups");
</script>

The script will find 1st + sign image available next to group first and forcefully fired the click event.

Bingo!!!!, the script is work properly and our issue resolved.

Wednesday, July 17, 2013

Query string value in lookup field in NewForm of list/ libraries.

If you created custom action on list and want to pass query string value in lookup field  and removed the other option from lookup so user cant change the value of lookup field used the follwoing javascript.

e.g. You've built a nice custom page which lists your parent items and you have links to each parent items to add child items with respect to parent item. Also when user open the child item form user not allow to select other parent id from lookup column add the following script on child item form.

your links looks like:-

http://ServerName/Sites/SiteName/Lists/Listname/NewForm.aspx?ItemId ={ItemId}.

// Javascript for Querystring values selected in Lookup dropdown and removed others values on Form.
//Description:  If Lookup column value items less than 20, html tag of dropdown 'select'. If the items greater than 20 items, html tag automaticaaly converted into 'input' in sharepoint 2010. So this script work for both condition.


//looks for the control of the requested type with a title that matches our current field
function getField(typeOfField,fieldDisplayTitle)
{  
   var matchingDocs = document.getElementsByTagName(typeOfField);  
   for (var i=0; i < matchingDocs.length; i++)
   {  
     if (matchingDocs[i].title == fieldDisplayTitle)
     {  
       return matchingDocs[i];  
     }  
   }  
   return false;  
}   
   
function getParameterByName(name)
{
   name = name.replace(/[\[]/, "
\\\[").replace(/[\]]/, "\\\]");  
   var regexS =  name + "=([^&#]*)";  
   var regex = new RegExp(regexS);  
   var results = regex.exec(window.location.href);
   if(results == null)    
   return "";  
   else    
   return decodeURIComponent(results[1].replace(/\+/g, " "));
}
  
//Set query string value to lookup field when lookup items less than 20 and removed other values from dropdown.
function setSelectValue(lookupControl, valueToSet)
{
   for(var i = 0; i < lookupControl.length; i++)
   {
     if(lookupControl[i].value == valueToSet)
     {
       lookupControl[i].selected = true;
        //lookupControl.disabled=true;
     }
   }
   //to remove other option from the field
   var options = lookupControl.options;
   var iCount = 0;
   while (lookupControl.length > 1 )
   {
     if(options[iCount].selected != true)
     {
       options[iCount] = null;
     }
     else
     {
      iCount = iCount + 1
     }
   }
                   
}
  
//function to be registered on SP Body On Load to attempt to select the corresponding lookup field information
function attemptToSetField()
{
  var fieldNameToBeAutoSet = "File ID";  //This is the display name of the field you want to auto-set
  var queryStringParameterName = "ItemId";  //This is the query string key name you will be retrieving the ID from
  var idToBeSet = getParameterByName(queryStringParameterName);
  if(idToBeSet)//only run the auto-set if it's been passed to us via query string
  {
    var lookupControl = getField('select',fieldNameToBeAutoSet);
    if(lookupControl)
    {
      setSelectValue(lookupControl, idToBeSet);
    }
    else
    {
       lookupControl = getField('input', fieldNameToBeAutoSet);
       if(false === lookupControl)
       {
          alert('Unable to get dropdown named ' + fieldNameToBeAutoSet);

       }
       else
       {
          //Set query string value to lookup filed when lookup items more than 20 and removed other values from dropdown.
          lookupControl.setAttribute('choices',idToBeSet + '|' + idToBeSet);
          lookupControl.value = idToBeSet;
          lookupControl.selected = true;

       }
     
                    
    }
  }
}
  _spBodyOnLoadFunctionNames.push('attemptToSetField');

“Failed to get value of the “Attachments” column from the “Attachments” field type control. See details in log. Exception message: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)”

The attachment issue comes after customization of NewForm.aspx/EditForm.aspx page. After Customizing page even you have not attached any attachement the following error message showing on click of save button:-
“Failed to get value of the “Attachments” column from the “Attachments” field type control. See details in log. Exception message: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)”

Resolution:-
Disabled attachment option from list
Go to list --> settings --> advance settings ---> disable attachments.

OR

If you want the attachment column to be present, open page in sharepoint designer and findout the below tag and replace it....

<TemplateName xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm">ListForm</TemplateName>

To

<TemplateName xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm">ListForm2</TemplateName>

Friday, July 5, 2013

SharePoint Lookup field: - Behaves differently when items greater than 20

SharePoint Lookup field: - Behaves differently when items greater than 20
Lookup column having less than 20 items:
If your lookup column having 20 or less items, the lookup column rendered like a normal dropdown filed (i.e. if you checked the source code of the page, you will get HTML tag <Select title=”File ID”…..) as shown in below images.
1.       The below image showing no. of items less than 20
2.       The below image showing source code for the page

Lookup column having more than 20 items:
If your lookup column is having more than 20 items, the source code automatically changed and complicated in IE browser. In FireFox and other browsers the lookup column with more than 20 items still gets same HTML source i.e. <Select tag .  The images are shown in below:
1.       The below image showing no. of items greater than 20
2.       The below image showing source code for the page
When lookup column has more than 20 items in IE it gets generated INPUT text box with an image. The input field on the other hand having lots of event handler like onfocusout, onkeypress, onkeydown. One of the attributes of input tag is also “Choices” which contains all the ids and values of lookup separated by “|” character. The image next to Input field has an “Onclick” event that triggers the select and selected value pass to the attribute “Value”.

Tuesday, April 30, 2013

Remove hyperlink from lookup column in Dataview webpart in Sharepoint 2010

When you used lookup column in the list and implemented it in custom dataview webpart, the hyperlink appears on the lookup field value.

To remove the link from lookup field used the following tag:-

Just you have to replace with

<xsl:value-of disable-output-escaping="yes" select="@Teams"/>

By:

<xsl:value-of disable-output-escaping="yes"
select="substring-after(substring-before(substring-after(@Teams, 'ID='), '&lt;'), '&gt;')"/>


If you have added multiple selection lookup value in your list, and you want to remove hyperlink from field, the above trick will not work. For that we required to more customise the XSLT and used the following code:-

In multiple selection lookup value shows in data view web part:-

Team1; Team2; Team3; Team4

We will format it to:-

Team1
Team2
Team3
Team4

Using the following code:-

Add the below template to your data view web part:-

<!—Semicolon delimit start -- >
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)" />                
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!—Semicolon delimit End -- >

<!—Remove Hyperlink start-- >

<xsl:template name="deleteAnchorTags">
<xsl:param name="Anchor"/>
<xsl:choose>
<xsl:when test="contains($Anchor, '&lt;')">                                    
<xsl:value-of select="substring-before($Anchor, '&lt;')"/>
<xsl:call-template name="deleteAnchorTags">
<xsl:with-param name="Anchor" select="substring-after($Anchor, '&gt;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Anchor"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!—Remove Hyperlink End-- >


And replace your tag with:-

<xsl:value-of disable-output-escaping="yes" select="@Teams"/>

By:-

<xsl:variable name="onlyText">
<xsl:call-template name="deleteAnchorTags">
<xsl:with-param name="Anchor" select="@Teams" />
</xsl:call-template>
</xsl:variable>
 <xsl:variable name="thisRow">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="$onlyText" />
<xsl:with-param name="replace" select="';'" />
<xsl:with-param name="by" select="'&lt;br/&gt;'" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$thisRow" disable-output-escaping="yes"/>


Happy coding..... :-) :-) :-)