Friday, April 20, 2012

Web Service permission issue for reader / viewer user in SharePoint

you may come across permission error while using list.asmx webservice in infopath. you may be able to use web service successfully for minimum contribute user but not for reader user. for this you need to grand permission for all authenticated users in default zone of that web application's user policy.

get current user details from user profile without writing code in InfoPath using webservice

refer this URL
http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx?from=ClayCobb

code to check logged in user exist in provided Active Directory (AD) group or not

using Microsoft.SharePoint.Utilities;

///
/// Method to check if logged in user exists in provided AD group or not.
///

/// AD group Name
///
public bool isMemberOfGroup(string strGroupName)
{
bool reachedMaxCount;
int limit = 100;
string strUserDispName = null;
bool returnValue = false;

if (SPContext.Current != null)
{
string strCurUserName = SPContext.Current.Web.CurrentUser.LoginName;
string URL = SPContext.Current.Site.Url;

SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite mySite = new SPSite(URL))
{
using (SPWeb sPCurrentWeb = mySite.OpenWeb())
{
SPPrincipalInfo[] users = SPUtility.GetPrincipalsInGroup(sPCurrentWeb, strGroupName, limit, out reachedMaxCount);

if (users != null)
{
foreach (SPPrincipalInfo user in users)
{
strUserDispName = user.LoginName;

if (string.Equals(strCurUserName, strUserDispName, StringComparison.OrdinalIgnoreCase))
{
returnValue = true;
break;
}

}
}
}
}
});
}

return returnValue;
}

Reset or Clear Multi select list box values for reloading with new values

Think suppose, if you come across of requirement ‘clear/reset values of multi select or repeating group’ you don’t have direct way in InfoPath as we do for Set Field Value. Because, InfoPath won’t allow us to select Group in Set Field Value action.
Hence what you do is, create a text field with the name that you like for Multi Select List box say “StatesList” and then Create a group say name as “Empty Group”
Now, in go to set field value action and select “StatesList” in Field and select “EmptyGroup” in Value and then click ok to finalize the rule.

Now, delete “StateList” text field and create Multi Select List box with same name “StatesList”.
If infopath is not allowing you to select Group field in Value, do same technique of creating text field with group name and use it in rule and then delete it and recreate Group field.
Every thing works as expected even though you deleted the “StatesList” text field. Rule will still alive and work properly on newly created multi select list box.


Cheers..!

Raj

How to Change New Icon time period in SharePoint

In this article I am describing about how to change the time period that a new Icon is displayed while you upload or add new item in SharePoint list.You may be also thought "How long an item does really stays new?". Usually many people ask these questions because they have uploaded/migrated a bunch of documents from their file share which are not really "new", but they get the !New tag assigned to them anyway.


This feature applies to not only Document Libraries, but also to other Lists such as Tasks, Issues, Contacts, and Links etc. In the default installation of SharePoint, the "New" tag gets appended to every new item in SharePoint lists and remains there for one calendar day. We have two options here, but make sure we have access to the SharePoint Server.
Increase the number of days that icon should appear
Eliminate the appearance of the icon altogether
We can use stsadm tool to accomplish this taskGo to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN


The "setproperty" command will be used for this task as
stsadm -o setproperty -pn days-to-show-new-icon -pv 2
-pn = Property name
-pv = Property value


enjoy blogging....:)

Tuesday, March 13, 2012

HOWTO: Add a button to the ribbon in SharePoint 2010

hi,
please go through this URL for the procedure of adding button to ribbon

http://koenvosters.wordpress.com/2009/11/05/howto-add-a-button-to-the-ribbon-in-sharepoint-2010/

enjoy coding....

Raj

Sunday, January 22, 2012

Hi All

Recently i got to do a project using InfoPath 2010. As per the requirements of the client, i had to use object model in InfoPath. I found many new things and learned frm mistakes and experience. I would like to share those with you.

1. If you want to connect to SQL Server using infopath programing, your form should be configured with fully trusted. For this, you have to go to Form Options-->Security-->Full trust.

2. Your validation will be ignored if you are using custom buttton for handling any business requirements. Then you should do small setting for the button. ie., goto button properties, select submit options, select form submit instead rules and programing. Also, click on Advanced button and you will see other advanced options when a button is clicked like close the form, stay on the form etc.,.
3. We cannot use global members directly in infopath 2010. You should use FormState property. while using this you may get doubt of how to use that for your required data type like string, int, etc., There is nothing tricky, give your required retur type for your member property and cast value to your required type while returning in get {} block. No need to do any thing in set {}.

4. There is no provision in code to assign value directly to integer, double, date, time & date & time. for this you need to delete an attribute. See below code which explains this.
---
public void DeleteNil(XPathNavigator node)
{
if (node.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance")) node.DeleteSelf();
}
----
once after doing this for the node, you can assign required value.


hmm, just taking a pause here. will continue rest of the things next, when i get free time.

thanks for reading..

thank you
raj