Posts

Showing posts from February, 2015

How to update TaxonomyField sharepoint 2013

the most simple solution, and occasionally the only working one, is to find the Term itself and send it and let SP to handle everything else, and the code is much shorter

this is the code for updating the field

Term ItemTypeTerm = GetTermByName();

if (ItemTypeTerm != null)
{
    TaxonomyField ItemTypeField = 
(TaxonomyField)f.Fields.GetFieldByInternalName("CbsMMDItemType");

ItemTypeField.SetFieldValue(field, ItemTypeTerm);
}

Sharepoint 2013 SPView does not bring all items and/or fields

i created a handler to bring me a view, so say i had this url for the view
"http://server/sub1/sub2/Lists/myList/myItems.aspx"

to i sent my view the server relative url
"/sub1/sub2/Lists/myList/myItems.aspx"

and used it to open a new SPSite and SPWeb and get the items, yet i just couldn't get all my items.
yet when i tried by using the SPContext.Site it worked.

i dont know why, but the context of how the SPSite was opened affects the view.

my final code looks like this
using (SPSite tempSite = newSPSite(serverUrl + serverRelativeViewUrl))
{
    using (SPWeb getUrlWeb = tempSite.OpenWeb())
{
spwebUrl = getUrlWeb.ServerRelativeUrl;
}
}


using (SPWeb tempWeb = spContext.Site.OpenWeb(spwebUrl))
{
string viewUrl = item.MethodValue;
if (viewUrl.StartsWith("/") == false)
{
viewUrl = "/" + viewUrl;
}
SPView oView;
try
{oView = tempWeb.GetViewFromUrl(viewUrl);
}
catch (Exception viewEX)
{

Search Application Topology errors (sharepoint 2013)

Image
you may have encountered this problem like this
"SharePoint 2013 Search Topology Activation Error: "Unable to retrieve topology component health states. This may be because of the admin component is not up and running".

or like this, having index partition or any other of the 5 components with a warn or error (image is edited to fit).

a more common case we had was having noderunner limited to 300MB.

so the solution was to bring it up to 500.
C:\Program Files\Microsoft Office Servers\15.0\Search\Runtime\1.0\noderunner.exe.config

the conclusion is that noderunner without enough memory eventually throw an error.


angular ngrepeat startWith filter

today i had some fun trying to make a "startWith" filter for ng-repeat.

simple start with

the most simple solution is to modify the default angular filter, just this line inside the filter function, deep inside the angular.js file there is our function "function filterFilter()", find this line

return ('' + obj).toLowerCase().indexOf(text) > -1;

and you only need to change it to

return ('' + obj).toLowerCase().indexOf(text) === 0;
example : http://plnkr.co/edit/iRzIj77N9rAoiCSMbRyk?p=preview


any word start with

but then they asked that if we have "In God I Really Do Trust" that 't' will bring it, i.e. make a filter that will find if any word start with, so I made a little nice filter, it even supports object to 1 level depth

http://plnkr.co/edit/xFhy7CdHnAZcEvgDA59L?p=preview


maybe there is an OOTB way to do it

while working on all that I noticed that the default filter comes with a comparator, so we can just use that.
the only downside…

Server Control with Child Control, dynamic created, retain control

Image
publicclassRelatedPublicationFilesSave : Control
{
protectedHiddenField _test;

    protectedoverridevoid OnInit(EventArgs e)
    {
base.OnInit(e);
        _test= newHiddenField();
        _test.ID = "_test";
this.Controls.Add(_test);
    }
    protectedoverridevoid OnLoad(EventArgs e)
    {
        _RelatedPublicationFilesSave =
this.FindControlById("_test") asHiddenField

make sharepoint (and asp.net) faster by bypassing internet certificate checks

Image
NOTE that all that means less security.

Part 1: tell you machine that you are MS certificate domain

Run -> drivers -> etc -> edit the "hosts" file.
add "127.0.0.1 crl.microsoft.com"
sometimes the machine will not let you to edit the file directly so just make a copy, edit it and paste it back.

Part 2: tell .Net to to check certificates

run this powershell script that will put something in the registry that tells .Net to to try and check the certificates, this is the PS:
get-ChildItem REGISTRY::HKEY_USERS | foreach-object {set-ItemProperty -path ("REGISTRY::\" + $_.Name + "\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing") -name State -value 146944}
NOTE that you will get multiple errors running this script, since it does not test which item in the final sub folder is valid. 
in order to test if the script worked you will need to go deep in to that sub folder and look for a value named "State&quo…