Store per user data in sharepoint webpart - sharepoint

I got to store some user specific data (string) in my Sharepoint webpart.I guess hidden webpart properties should do the trick. Tried with the following attributes on webpart property:
[WebBrowsable(false)]
[Bindable(true)]
[WebPartStorage(Storage.Personal)]
[Personalizable(PersonalizationScope.User)]
But I observe in the webpart that data stored is not user specific. Any help?

How are you reading your data ? You can use the WebPart.PartCacheRead method to retrieve per use values.
web.config can be modified to signal how you want your WebPartCache to be stored. To support caching in database then you must include the [Serializable()] attribute to you custom classes
The WebPart.EffectiveStorage property can also help in determining how the data is stored:
if (EffectiveStorage == Storage.Shared)
{
output.Write("<b>You are now in shared mode.</b>");
}
Just wondering why you have WebBrowsable attribute set as false. Are the users not able to configure the web part ? When and how is the property value set ?

Related

Find all resources (users) that has a schema extension property set to null

We have a scenario were we need to extend the existing schema in AAD for users to support our use case. As soon as a new user has been created (we do not control this process) we want to attach some additional information to the object. We also want to attach information to all the already existing user objects. We though the schema extension in the Graph API would solve this issue for us.
I've added a schema definition based on the tutorial here. Our extension got the name ext7sumrsqd_policies and have the following properties:
IsHandled (boolean)
SuggestedOwner (string)
After the extension was created I wanted to find all users that does not have the new "property" set (imagine a sync that is running on an intervall and want to check for new users that has not yet been handled).
Tried the following query first: https://graph.microsoft.com/v1.0/users?$filter=ext7sumrsqd_policies eq null
However the Graph API does not support filter with null.
Therefore tried to filter on any of the properties on the new extension:
https://graph.microsoft.com/v1.0/users?$filter=ext7sumrsqd_policies/IsHandled eq false
https://graph.microsoft.com/v1.0/users?$filter=ext7sumrsqd_policies/IsHandled eq true
However this filter never returns any user that has ext7sumrsqd_policies=null.
Are there any way you can filter the Graph API for resources that is currently missing a schema extension property or where the property is null?
As stated filtering by null is not supported. You might try creating a second schema extension such as ext7sumrsqd_hasPolicies that specifies if ext7sumrsqd_policies is null or not.

Is it possible to add Extra Fields Under Create User in Liferay

I am using Liferay 6 for portal Development .
During Creating Users under Liferay , i need to add some extra Fields also ??
Please let me know if this is ppossible or not ??
Please see the screen shot attached here , and also please let me know in which table this will be stored in Database ??
Yes, you can use Custom Attributes functionality for liferay entities (in your case, User) and can add as many extra fields as necessary for each liferay entity.
Custom field for the user-entity can be created through:
Control Panel -> Portal -> Custom Fields -> User.
And programmatically can be created as follows:
user.getExpandoBridge().addAttribute("yourCustomFieldKey");
Then set the value as:
user.getExpandoBridge().setAttribute("yourCustomFieldKey", "valueForCustomField");
If your custom field is already present you can check like this:
if (user.getExpandoBridge().hasAttribute("yourCustomFieldKey")) { ... };
The data is stored in tables prefixed with "EXPANDO":
EXPANDOCOLUMN: stores the custom field key and other settings
(contains the tableId refrences)
EXPANDODATA: stores the custom field value for the key (contains the
columnId and tableId refrences)
EXPANDOTABLE: stores for which liferay entity (user) are you adding
the custom field
EXPANDOROW: stores linking information between a user and its values
(contains tableId and userId refrences)
Hope this helps.
yes, you can add custom fields to user-entity and add them the field-values to user:
user.getExpandoBridge().addAttribute(...);
Custim field for the user-entity you can create by Control Panel Portal->Custom Fields or programmaticaly at liferay start.
The data will be stored in ExpandoValue tables.
Just in case somebody try to retrieve the values from the custom fields and is having problems with null values returned by the method user.getExpandoBridge().getAttribute("yourCustomFieldKey") (even when you followed the threads about permissions), I found other way to retrieve the Custom Fields values:
ExpandoTable table = ExpandoTableLocalServiceUtil.getDefaultTable(user.getCompanyId(), User.class.getName() );
ExpandoColumn column = ExpandoColumnLocalServiceUtil.getColumn(table.getTableId(), "yourCustomFieldKey");
ExpandoValue expandoValue = ExpandoValueLocalServiceUtil.getValue(table.getTableId(), column.getColumnId(), user.getUserId());
Then you can do a simple (if the field is text) expandoValue.getString();
Not so pretty, but do the work.
User creation page in liferay can be customized. You can infact decide which fields to be present in the user creation page. More about this in here.
Use the following commands if you get the permission problem in adding or setting attribute.
user.getExpandoBridge().addAttribute("yourCustomFieldKey",false);
user.getExpandoBridge().setAttribute("yourCustomFieldKey", "valueForCustomField",false);

URL for Key Filter on document list view in SharePoint 2010

I'm trying to dynamically construct URLs in an ASP.NET MVC website that point back to a SharePoint list view with a Key Filter enabled for a managed metadata field (which uses a TermSet).
If I configure a navigation hierarchy for the managed metadata field, I see the following in the URL:
TreeField=MyCategory&TreeValue=0C37852B-34D0-418E-91C6-2AC25AF4BE5B
However, if configure the managed metdata field as a KeyFilter, I see the following in the URL:
#ServerFilter=FilterField1=MyCategory-FilterValue1=247-FilterLookupId1=1-FilterOp1=In
Where does the FilterValue1 value of 247 come from? It is not the database id of the MyCategory term. It is also not present anywhere on the Term object when loading the taxonomy through the SharePoint API. Is there a way to construct the query string to use the guid for the term (or better yet, the label, which I know will be unique).
The value comes from the taxonomy hidden list. Use the following method GetWssIdSoftTerm to get the int value the above urls are using to filter the data.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.taxonomyfield.getwssidsofterm.aspx

SharePoint Managed Properties (Mappings) - Multiple Site Collections

Have mapped properties for custom fields used in multiple site collections.
The property is also used to display additional information on the search results page if it contains information.
The search results work fine as content from each site collection is returned, but the managed property only contains data for content found on one particular site collection.
When configuring the managed property, there is only one option available to select the custom field I wish to map.
A full crawl has completed since configuring the managed property. The content from each site collection is being indexed, but the managed properties are only populated with data for content on one site collection.
Are the fields available to select when configuring a managed property from all site collections, or do I need to change a setting somewhere to tell it to look for custom fields in an alternate site collection?
Thanks in advance.
I've done this before and it is possible and indeed straightforward, you do not need to set any special settings. Just make sure that the internal names of the fields are the same (or all names are mapped to the managed property) and all lists/sites are set to be included in search results

Not sure how to programmatically filter by taxonomy metadata in my custom search webpart

I have pages in a pages library on a publishing site which have a managed metadata (taxonomy) field in their content type. I want my custom search webpart to read the taxonomy set on its parent page (I can do this fine) and then query against a specific scope using only the selected tags of the parent page as the filter (no keyword necessary).
I have tried to set FixedQuery = “owstaxIdMetadataAllTagsInfo=#0[TERM GUID]” of my CoreResultWebPart with no success... I actually gave up after I was getting 0 results and am now trying to just perform a FullTextSqlQuery.
Unfortunately it seems that even though pages with the managed metadata field are successfully being indexed, the managed property owstaxIdMetadataAllTagsInfo has no data in the results! I went ahead and made the property searchable/queryable and the property value is null.
Can you anyone confirm that I should be getting values from that managed property when there is indeed a managed metadata field on the page that is populated with data?
Note: I have tried to make my own managed property based on the managed metadata field in my site's content type -- same results.
I don't think - owstaxIdMetadataAllTagsInfo returns anything. I tried adding it to my result web part's Diaplay properties > fetched properties and got a property not recognized...related error.
So I created a separate metadata property for 'enterprise keywords' i.e. 'TaxKeyword. You need to ensure that you check the checkbox - 'Reduce storage requirements for text properties by using a hash for comparison' otherwise no results will be returned for that peroperty is you use LIKE predicate with fulltextsql.

Resources