Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all 11571 articles
Browse latest View live

Get latest workflow instance programatically?

$
0
0

hi,

i am building sate machine workflow and when i upgrade the solution another workflow instance is created  when workflow starts again.

now i want to get latest workflow instance problematically.

thanks,

gaurav.


Powershell scripts not writing it to output file

$
0
0

Hi,

Below is my script which loops through all sites and web in a site collection and if the particular web part is added in a page, it will give the page URL and it should be written to a output file.

function enumerateWebParts($Url)
 {
 $webApp = Get-SPWebApplication $Url  #Get WebApplication URL
foreach($web in $webApp | Get-SPSite -Limit All | Get-SPWeb -Limit All) #foreach loop to iterate through all sites and webs of WebApplication
 {
 if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) #Check if site is a publishing site
 {
 $pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
 $pages = $pWeb.PagesList
 foreach ($item in $pages.Items)
 {
 $fileUrl = $webUrl + "/" + $item.File.Url

 $manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
  
 $wps = $manager.webparts
 foreach ($type in $wps) #loop through each type found $wps
 {
#Write-Host " type searching";
Write-Host $type.GetType().Name;
 if ($type.GetType().Name -eq "RightMenu") #if webpart $type -like KWizCom select webpart object
 {
Write-Host "found";
 $wps | select-object @{Expression={$pWeb.Url};Label="Web URL"},@{Expression={$fileUrl};Label="Page URL"},DisplayTitle, IsVisible, @{Expression={$type};Label="Type"}
Write-Host $fileUrl;
$page=$pweb.Url+$fileUrl;
Write-Output $page;
 }
 }
 }
 }

 else #if web is not a publishing site
 {
 $pages = $null
 $pages = $web.Lists["Site Pages"]
 if ($pages)
 {
 foreach ($item in $pages.Items)
 {
 $fileUrl = $webUrl + "/" + $item.File.Url

 $manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
 $wps = $manager.webparts
 foreach ($type in $wps)
 {
 if ($type.GetType().Name -eq "RightMenu")
 {
 $wps | select-object @{Expression={$Web.Url};Label="Web URL"},@{Expression={$fileUrl};Label="Page URL"},DisplayTitle, IsVisible, @{Expression={$type};Label="Type"}
Write-Host $fileUrl;
$page=$pweb.Url+$fileUrl;
Write-Output $page;
 }
 }
 }
 }
 else
 {
 }
 }
 # Write-Host “… completed processing” $web
 }
 }

$row = enumerateWebParts(‘http://sptest.danfoss.net’) #call the enumerateWebParts function pass it the URL for the web application



 
 

I run the command through D:\RightMenu.ps1 | Out-File D:\RightMenu.txt

Aruna

retrieving data from managed metadata field of list with cmal query using javascript

$
0
0

hi friends

i am trying to retrieve data from managed metadat field of list using javascrtipt

function retrieveListItems() {

    var clientContext = new SP.ClientContext.get_current();	
    var oList = clientContext.get_web().get_lists().getByTitle('termlist');
	var camlQuery = new SP.CamlQuery();
	camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'ID\'/><Value Type=\'Counter\'>'+pageId+'</Value></Eq></Where></Query></View>');
    this.collListItem = oList.getItems(camlQuery);
    clientContext.load(collListItem);
    alert("load");
	clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));  	  
}

function onQuerySucceeded(sender, args) {
var PO;
var ID1;
var TA;
var UT;
    var listItemEnumerator = collListItem.getEnumerator();    
    while (listItemEnumerator.moveNext()) {
       var oListItem = listItemEnumerator.get_current();        
	      //listtId1=oListItem.get_item('_dlc_DocId');  
	   ID1=oListItem.get_item('ID');     
	   PO=oListItem.get_item('Author');  
	   TA=oListItem.get_item('Audience');
	   UT=oListItem.get_item('Utilities0').get_label();
	}

alert(TA);	
alert(UT);
alert("end");
}

function onQueryFailed(sender, args) {
	    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

Utilities0 is managed metadata field it is not working am unable to retrieve any data. 

is there any wrong in this code

i have tried 

UT=oListItem.get_item('Utilities0').get_label();

and

UT=oListItem.get_item('Utilities0');

if am not using get_label() it is show [object object ] in alert

 

Excel Content Type Auto Recognize on Upload

$
0
0

I have created custom Content Types for our document libraries - Word, Excel, Powerpoint, so that users can create new documents within Sharepoint.

However, when users are uploading documents, I don't want them to have to choose the Content Type.  I want Sharepoint to autorecognize that the file being uploaded is an Excel File and file it to the appropriate Content Type. 

For example, when users upload documents, they receive the document upload window which prompts them to enter metadata about documents (ie, attributes such as Content Type, Document Type, Category, etc...).

When users upload an Excel spreadsheet, I don't want them to have to choose the Content Type.  By default, the Content Type drop-down list they see in the input window shows Word at the top, so if users don't click into the Content Type field and change it to Excel or Powerpoint, then all documents get filed under Word Content Type.

I'm trying to eliminate extra steps for users, so that they will want to use Sharepoint.

Is there a way to write some code that would make Sharepoint auto-recognize what the file type is of documents being uploaded, and file them to the correct Content Type automatically without users having to choose this field?

thanks!

ISO: help with powershell script to examine each site collection's "simple user list"

$
0
0

So, for quite a number of years, I have been dealing with an odd problem.

I am in a situation where users are assigned windows logins which include their initials and department numbers.

For a new user, the data flows from Active Directory through the timer jobs that import AD into SharePoint.

Then, as they use a site collection, a copy of some of their data goes into the SharePoint site collection user list.

This is, of course, a vastly simplied explanation of the standard way things work.

Now, on a regular basis a user moves from one department to another, or in some cases, a user changes some portion of their name.

This results in them having a new login.

In most cases, this information makes its way through the process and the user list is mostly updated...

Right now, 8 fields in the user information record are populated. 7 of the fields are updated ... but not the Account field.

This leaves the user entry half pointing to the user's new login and half pointing to a login that no longer exists.

This results in problems in various ways - sometimes the user can check items out but not back into a library. Sometimes an ASPX page can determine the user's name, but not their login, and so forth.

Is there a way, via PowerShell, that I could run through every web application, every site collection in a farm, checking the users in the user list and generate a report on the user entries which have the account value different from the user name ?

I am not looking to automatically fix anything right now - just wanting to generate a report on users which have the issue.

Thank you so much.

Restore SharePoint list backup with custom name

$
0
0

Hi All,

I have taken SharePoint list back up. Is there any way to restore it in the same site collection with the different list name?



srinivas

Feature setting Masterpage & CSS doesn't work when included in SiteTemplate - but does work when activated manually

$
0
0

Hi,

I'm experiencing a strange behaviour recently. I wrote a feature with an EventReceiver that sets the masterpage and alternate css file for the current spweb it is activated for. When I activate that feature manually it works like expected. But if I include the same feature in a SiteTemplate and it is called during site-creation, it doesn't work. I debugged it and stepped through it. As far as I can tell everything looks right. It sets the masterpage and css file like it should and throws no error. But when the site loads in the end, it suddenly still uses the v4.master and no alternateCSS. How can that be?

If I deactivate the feature then manually and activate it again, it works...

Here's the feature:

		const string masterPage = MyOfficeProcess.master";
        const string searchMasterPage = "MyMinimal.master";
        const string alternateCss = "MyOfficeAlternateProcess.css";

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb web = (SPWeb)properties.Feature.Parent;

            using (SPWeb topLevelSite = web.Site.RootWeb)
            {
                string relativePath = topLevelSite.ServerRelativeUrl;
                if (!relativePath.EndsWith("/"))
                {
                    relativePath += "/";
                }

                if (web.WebTemplate == "SRCHCENTERLITE" || web.WebTemplate == "SRCHCEN" || web.WebTemplate == "SRCHCENTERFAST")
                {
                    web.CustomMasterUrl = relativePath + "_catalogs/masterpage/" + searchMasterPage;
                }
                else
                {
                    web.MasterUrl = relativePath + "_catalogs/masterpage/" + masterPage;
                    web.CustomMasterUrl = relativePath + "_catalogs/masterpage/" + masterPage;
                }

                web.AlternateCssUrl = relativePath + "Style Library/My/" + alternateCss;
                web.UIVersion = 4;
                web.Update();
            }
        }

XSl formula for pulling values based on parameters or query strings

$
0
0

Hello,

I have a custom list in SharePoint

List Column/Fields (any time a new item is created these are the fields that need values)

Machine = ID2

SpecLabel = text string value

SpecValue = text string value

Using DataFormWebPart

I Filter values by Machine by creating a parameter with a query string as its source.

And pull the values

<xsl:value-of select="@SpecLabel" />

<xsl:value-of select="@SpecValue" />


On the browser I add the parameter to the URL sting to filter each machine ID.

?=Machine=1

Back in the XSL i use the same parameter to pull the value of the string as my header title.

<xsl:value-of select="$paramMachine"/>

Problem

I need a formula that will pull just the the SpecValue data for a specific item.

Example: I have thee items below and I need to just pull the “SpecValue” for the Built Year which is 2014.

Machine = 1
SpecLabel = Speed
SpecValue = 10

Machine = 1
SpecLabel = Color
SpecValue = Red

Machine = 1
SpecLabel = Built YearSpecValue = 2014

Any Suggestion? 


how to get highest salary from salary column in sharepoint list

$
0
0

Hello,

I have one custom list in which there is one salary column so I want to get the highest salary.Can we do this OOTB or by using custom code by adding webpart(using CAML query).

Thanks,

Content editor webpart not working properly in chrome

$
0
0

I have create custom master page and set as default one. It will working fine for all browser except chrome.

screen shot is here:

help me to solve this issue.

Creating a Status column (IF statement/calculated column)

$
0
0

I'm developing list for managing a project with 11 columns each representing a project milestone.

We'll call them A,B,C...K.

"A" representing a status of "Project Started" and K representing "Project Complete" with various statuses in between.

When a milestone has been reached, the date is input into the appropriate column. So when the project is complete, there will be dates in all columns A-K

I wish to incorporate a new column that indicates the current status depending on if columns A-K have been filled in.

So if all columns are blank, a status of "Awaiting start" is indicated.

If column A is filled in with a date, a status of "A" is indicated.

If columns A and column B are filled in then a status of "B" is indicated.

If columns A, B and C are filled in then a status of "C" is indicated. * * If all the columns are filled in with dates, a status of "K" is indicated.

Any ideas? Some form of If statement in a calculated Status column?

SPAlert get email address of recipient?

$
0
0

The SPAlert class has a User and UserID property -

UserGets or sets a user object representing the user who created the alert.

UserIdGets or sets the ID of the user who created the alert

my question is - the property description says that both properties are for the User who created the alert. Is this accurate? Or is it the user who is the recipient of the alert? If not, how do I get the recipient user rather than the created by user?

Thanks in advance,

Jake.

SharePoint 2010 - Hide CEWP if survey has been answered

$
0
0

I have created a link to a survey on a web part page using a CEWP. I would like to hide the CEWP if the logged in user has already answered the survey.

I found the following to be of some help: http://social.msdn.microsoft.com/Forums/sharepoint/en-US/16ece738-0012-4772-88c2-11239fe61370/show-or-hide-web-part-javascript but am currently a bit of a stranger to javascript so am not sure how to amend itto say if the completed column from the survey list equals yes for the currently logged in user then hide the web part.

Any help would be appreciated.

Event Receiver debug not attaching to process

$
0
0

I built an ItemAdding Event Receiver which works on my SharePoint 2010 development server.  Now I'm trying to create the exact same thing on my Live SharePoint server.  And its not working.  Its supposed to populate one column in the document library. 

I'm trying to debug it in VS, but it won't attach to the process.   I was able to debut it yesterday.  I have no idea why it won't fire the event receiver.

Any ideas?

how to determine current page is published or not using javascript

$
0
0

hi friends

i am using publishing workflow. if page not published i need to hide buttons on page.

how can i determine the current page is published or not using JavaScript 


Custom EditForm for Document Library using visual Studio

$
0
0

Hi all, I know building custom new, edit, display forms for lists and its bit different for document libraries.

I have a content type added to a document library. Using code, I have changed the EditFormUrl property for the content type. I need lot more fields (Not from the content type) to be shown on the edit form. Is there a good article out there to show some thing similar?

How can I change the edit form.aspx page to show the custom page I built through visual studio and not through SharePoint designer.

Thank you. Any help appreciated.

Saved List template is not visible under create page

$
0
0

Hi All,

I created a list template and it got successfully saved to list template gallery. I am trying to create a new list with the above created list template in the same site . but unfortunately the list template is not visible under create page.

Mine is SharePoint 2010 environment and it is nothing to do with migration.

I tried activating team collaborating lists feature under web features and tried below code from various articles.

Write-Host "**********operation Started************"
$webURL = "http://servername/sites/test/"
$web = Get-SPWeb $webURL
$web.parserenabled = $true
$web.update()
$web.dispose()
Write-Host "**********operation completed************"

But nothing helped....

Can anyone suggest....



srinivas

Like operator for sharepoint ssrs

$
0
0

Hi,

i ve got a multiiple instructor coulmn like

i ve written experssion like = Join(Parameters!Instructor.Label,",") Like "*" & Fields!InstructorName.Value  & "*"

boolean

value=true

but Please see the below image

it is displaying wrong instructor results

Any Suggestions?


Thanks Manohara R

Add multiple people using Javascript Client Object Model

$
0
0

I am trying to add multiple people to a SP column of type Person/Group i.e. people picker. I am able to add one successfully using their userId, but HAVE no clue how to do that for multiple people. Here is the code for one user:

function UserDrop(e, toElement, listGuid, columnName) {

    
//EcmaScript Client Object Model
    var ctx = new SP.ClientContext.get_current();
    var list = ctx.get_web().get_lists().getById(listGuid);
    var item = list.getItemById(elementId);
//columnName is of type person/group and I am adding user //whose userId is 7
    item.set_item(columnName, 7);
    item.update();

    // asynchronous call
    ctx.executeQueryAsync(
        function () { toElement.innerHTML = userLinkHtml; },
	    function () {alert ("Error")}
        );

    return false;
}

This works great and I can add user whose userId is 7, however I want to add multiple people like let's say users of user Ids 7 and 8. 

Any ideas or help will be greatly appreciated. 

There is a thread on this one but that's from .net COM which could accessed here: http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/5183e87c-ee1d-4594-9492-0dfdf6616cce


7929

ECMAScript --> get current User fails!!

$
0
0

i want to get the current logged in user:

    var ctx = SP.ClientContext.get_current();
    this.web = ctx.get_web();

    this.currentUser = web.get_currentUser();

    ctx.load(this.currentUser);

    alert(this.currenUser.get_loginName());

 

but the current user is always null ---> what im doing wrong?

Viewing all 11571 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>