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

Get ID of last item in sharepoint list using JSOM or CSOM

$
0
0

Hi

the problem is i need the value last ID which was created in the list, whether the item is deleted or not

whichever is the last id i need value if that as i am creating a sequential number using the ID

Below is my code

<html><head><script type="text/javascript"> 
    ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js"); 
    // Get the current Site
    var  webAbsoluteUrl;
    function retrieveListItems() {
        webAbsoluteUrl=  _spPageContextInfo.webAbsoluteUrl;
        if (_spPageContextInfo.serverRequestPath.endsWith("NewForm.aspx"))
{       
        var clientContext = new SP.ClientContext(webAbsoluteUrl);
        // Get the liste instance
        var oList = clientContext.get_web().get_lists().getByTitle('ABC');
        var camlQuery = new SP.CamlQuery();

        // Get only the last element
        camlQuery.set_viewXml('<Query><OrderBy><FieldRef Name=\'Title\'  Ascending=\'False\' /></OrderBy></Query><RowLimit>1</RowLimit>');
        collListItem = oList.getItems(camlQuery);

        clientContext.load(collListItem);

        clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);        
}
    
}
    function onQuerySucceeded(sender, args) {
        $("input[id*='fa564e0f-0c70-4ab9-b863-0177e6ddd247']").attr("readonly", "true").css('background-color', '#fff', 'color', '#444');
        $("input[id*='fa564e0f-0c70-4ab9-b863-0177e6ddd247']").attr("disabled", "disabled");
        var isdata=false;
        var listItemInfo='';
        var listItemEnumerator = collListItem.getEnumerator();
        while (listItemEnumerator.moveNext()) {
			isdata=true;
            var oListItem = listItemEnumerator.get_current();
			 listItemInfo = oListItem.get_item("ID");
            // Split the first
            var res = listItemInfo;

			var newID1 = res+1;
			var newID = "ABC-00" + newID1
            // create the new id
			if(isdata==true){
			    $("input[id*='fa564e0f-0c70-4ab9-b863-0177e6ddd247']").val(newID);
			}
        }
		if(isdata==false){
		    $("input[id*='fa564e0f-0c70-4ab9-b863-0177e6ddd247']").val("ABC-00" + 1);
	   }
      listItemInfo.toString();
    }
    function onQueryFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); 
    }   

_spBodyOnLoadFunctionNames.push("SetReadOnly()");</script></head></html>


Paru


Dynamic calculation of Sharepoint list columns in sharepoint list 2010

$
0
0

Hi,

How to add two sharepoint 2010 list columns dynamically and showing the sum in the third column, without using infopath.

How to Upload File to Document Library using JavaScript Client Object Model?

$
0
0

I want to Upload File to a Document Library using JavaScript in SharePoint 2010. I found that you can copy file from One Document Library to Another but you can't upload File using JavaScript on this Forum. I want to know from TechNet that is it really Impossible or not. Please help me with that? Its Urgent..

Thank You.


Ritesh Goswami

Issue Approval and Notification, SP 2010

$
0
0

Very new to this...  I have searched widely for solutions, but found nothing definitive.  Hoping someone can help... 

Presently using SP 2010 on Windows 7. I do have SP Designer 2010.  I am a novice, please don't assume I understand much! 

I am running an Issue Tracking list for users to log, well, issues.  

I am requiring two names - 'Assigned To' and 'Sponsor'.  

I need the Sponsor to approve the Issue BEFORE going live, AND BEFORE the Assigned To person is notified, that is: 

• When the Issue is saved, the Issue is to go into draft or pending (?) and SPONSOR requested to approve via email; 
• If approved, then the Issue goes live and THEN the assignee is notified (and treated as normal issue).  The Issue doesn't need re-approval when completed (at this stage); 
• If rejected, the assignee is notified and... (not sure - possibly moved to a 'rejected' list if that's possible?) 

I figure I need to use SP Designer as I need to pick up the SPONSOR of that record.  It will NOT be the same person all the time.  

I did get something close using SP Designer for the approval request, however the Assigned To person receives notice that they're assigned before the Issue is approved.  The Sponsor did also receive an approval request, but Assigned To shouldn't receive any notification until after approval.  

Whatever solution, do I apply this at issue or folder level? 

Cheers 

Lookup column values are sometimes disappears.

$
0
0

Respected All,

I am facing problem regarding lookup column in sharepoint 2016. 

we have two librarys one is Source library & another is Destination Library.

Whenever i am adding (content name) lookup value in destination library the lookup value of source library lost means disappears.

This issue not coming all the time,it comes sometimes.

Please help me solve this problem.

Thanks in advance.

Thanks ,

Navnath Namde     

Deploying SharePoint 2010 based web-site on to Windows Server 2016

$
0
0

Hi,

We have SharePOint 2010 based web portal which is presently deployed on Windows Server 2008. Now we want to deploy this web portal on Windows Server 2016 and change the database to SQL Server 2016.

This web portal gets maintained by us and has not been developed by us. Since its very old application so not even we received a single work on doing any maintenance work. The only request that we have now is to upgrade the Windows server and database.

Since we dont have much expertise in SharePoint side hence we would like to get help here.

Please let us know if we have to look for any constraints w.r.t. deployment on Windows Server 2016 and upgrading database to SQL Server 2016.

Thanks in advance. 


Sanjay Nipane

CAML query-office 365

$
0
0

Hi ,

Can we have multiple queries on single list in one power shell function?

I had a query on document library which has returned all items from library.

Now if I get first item with filename as 'Test.pdf' then I need to have a query again to check if the same filename has occurred again. If so then I have to fetch another query in it which will have different result.

Howto do this?

Thanks




Shubha

Unable to get domain DNS or forest DNS for domain X

$
0
0

I have install a new SharePoint farm, and when I try to add new managed account I get an error:

Specified value is not supported for the {0} parameter

 

ULS Log:

72e1 High     Unable to get domain DNS or forest DNS for domain hq.vlmrk.corp. ErrorCode=1355 3d5075e2-ad28-4049-ba65-7357c9acfb34
05/31/2011 14:16:57.66  w3wp.exe (0x0508)                        0x0E84 SharePoint Foundation         Runtime                        tkau Unexpected System.ArgumentException: Specified value is not supported for the {0} parameter.    in Microsoft.SharePoint.Utilities.SPUserUtility.GetDomainControllerToSearch(SPWebApplication webApp, String domainName)     in Microsoft.SharePoint.Utilities.SPUtility.GetDomainAndPropColl(SPWebApplication webApplicaiton, String loginName, String[]& resolveUserAdProperties, SPActiveDirectoryDomain& gcPath, ResultPropertyCollection& propcol)     in Microsoft.SharePoint.Utilities.SPUtility.GetUserPropertiesFromAD(SPWebApplication webApplicaiton, String loginName, String[]& origUserAdProperties)     in Microsoft.SharePoint.Utilities.SPUtility.GetUserPropertyFromAD(SPWebApplication webApplicaiton, String loginName, String propertyName)     in Microsoft.SharePoint.Administration.SPManagedAccount.GetUserAccountContro... 3d5075e2-ad28-4049-ba65-7357c9acfb34
05/31/2011 14:16:57.66* w3wp.exe (0x0508)                        0x0E84 SharePoint Foundation         Runtime                        tkau Unexpected ...l(String username)     in Microsoft.SharePoint.ApplicationPages.AdminConfigServices.ValidateUserLogon(Object sender, ServerValidateEventArgs e)     in System.Web.UI.WebControls.CustomValidator.OnServerValidate(String value)     in System.Web.UI.WebControls.BaseValidator.Validate()     in System.Web.UI.Page.Validate()     in System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)     in System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)     in System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 3d5075e2-ad28-4049-ba65-7357c9acfb34

Any ideas?

How to get tenant id using sharepoint framework

$
0
0

Hello All,

I want to get Tenant Id of my sharepoint online site using SPFX.

Is there any way to get it?

Thanks

Event Receiver is not working if upload a file via Windows explorer mode.

$
0
0

Hi All,

I have written a event receiver for Document Repository in Item Added event. It is not triggering if I would upload a file via Windows explorer mode.

Regards

Poomani Sankaran

CAML query-office 365

$
0
0

CAML query to check if list items which has same Created  Date .

I have retrieved some documents list items from document library using one CAML query.

Now in this query I have retrieved specific 3 document items .

Now I have to check if this three document have same modified date or not.

How can I check this?


Shubha

Sharepoint 2010- Copy a value from another column not working (within IF Function)

$
0
0

I'm using the following formula:

=IF(ISBLANK([Date Sent]),"<img src='/_layouts/images/blank.gif' onload=""{"&"    var SPday=new Date();"&"    SPday.setFullYear("&YEAR([Date Of Request])&","&MONTH([Date Of Request])-1&","&DAY([Date Of  Request])&");"&"    var Days=Math.round((SPday.getTime()-new Date().getTime())/86400000);"&"    this.parentNode.innerHTML=Math.abs(Days)+' days '+((Days<0)?'past':'left');"&"}"">","=[Days taken]")

Note: [Days taken] is a column which I calculate: [Date Sent] - [Date Of Request]

If above formula is true, it will calculate Today()- Date of Request,

If above formula is false, it should copy the value from the column [Days taken] but it is shows the text "=[Days taken]".

I want it to show the number instead of the text. Please help! thanks!


link in subsite not working

$
0
0

This site can’t be reached

The webpage at http://www.futuregroupintranet.com/CIC/Lists/Links/AllItems.aspxmight be temporarily down or it may have moved permanently to a new web address.

ERR_INVALID_RESPONSE

Getting the message above when I am creating a link in a subsite. How to solve it

Is there any possibility to read that UniqueId from sharepoint 2010 server?

$
0
0
I would like to read some folder- and file-properties from sharepoint 2010 server. The most important property is the UniqueId. Is there any possibility to read that property?

I tried with csom (Microsoft.SharePoint.Client.dll). This works fine with the code below for sharepoint 2013 and above. It works for sharepoint online and sharepoint server. The problem is for sharepoint 2010 server where I need to read. An exception occurs like "The Field or Property UniqueId is not available". The "ListItemAllFields" is not available either. I read many posts but I could not found a solution. 

I could figure out that there would be normaly 3 solutions for it:

1. csom (Would be the best solution and works perfect for 2013 and above -> no solution found for 2010 server)
2. ssom (Works only when everything is on the same server -> is no solution for me because the application where I need to read is not on the same server like sharepoint)
3. webservices (I could not found a matching solution with webservices)

I read about Caml query and found something like 
<FieldRef Name='UniqueId'/>
but I don't know how to use it and I don't know if reading UniqueId even is possible with it.

Here the code which works fine for sharepoint 2013 and above but did not work for sharepoint 2010 server:

   
public string GetChilds(ClientContext clientContext, string relativeUrl)    
{
  SpFolder folder=clientContext.Web.GetFolderByServerRelativeUrl(relativeUrl);      
clientContext.Load(folder,                   
  item => item.Name,                   
  item => item.UniqueId,                   
  item => item.ServerRelativeUrl                   );          

  clientContext.Load(folder.Folders,        items => items.Include(                        
    item => item.Name,                       
    item => item.UniqueId,                       
    item => item.ServerRelativeUrl,      item => item.TimeLastModified,    item => item.TimeCreated,                        
    item => item.ListItemAllFields["Author"],              
    item => item.ListItemAllFields["Editor"]));      clientContext.Load(folder.Files,      items => items.Include(        item => item.Name,          item => item.UniqueId,        item => item.ServerRelativeUrl,      item => item.TimeLastModified,      item => item.TimeCreated,      item => item.ListItemAllFields["Author"],          item => item.ListItemAllFields["Editor"],    item => item.ListItemAllFields["File_x0020_Size"]));           
 clientContext.ExecuteQueryWithIncrementalRetry(EXECUTEQUERY_RETRYCOUNT, EXECUTEQUERY_DELAY);   

  string result = "";    result += "Parent Name:" + folder.Name + ",";  result += "Parent UniqeId:" + folder.UniqueId.ToString() + ",";    result += "Parent ServerRelativeUrl:" + folder.ServerRelativeUrl + ",";  if (folder.Folders != null)      {        foreach (SpFolder subFolder in folder.Folders)        {            result += "Name:" + subFolder.Name + ",";        result += "UniqueId:" + subFolder.UniqueId.ToString() + ",";      //...       
    }      }        
  if (folder.Files != null)    {        foreach (SpFile file in folder.Files)       {
      result += "Name:" + file.Name + ",";        result += "UniqueId:" + file.UniqueId.ToString() + ",";        //...      }    }        return result;  
}

The expected result would be retrieving the UniqueId and ListItemAllFields from sharepoint 2010 server. 
The actual result is: "The Field or Property UniqueId is not available".

SharePoint 2010 Event Receiver is not firing while upload document in document library

$
0
0

Hi All,

I have created a Event Receiver in SharePoint 2010 which is not working while upload document in Document Library . Please suggest me below,

1) I have used below code to create a simple event receiver in my development environment. I did not do the development  where actually SharePoint installed by using SharePoint in build templates. I have developed it by using class Library in my development environment and manually deployed in SharePoint by using Power shell commands.

public class TestEventHandler : SPItemEventReceiver
    {
        public override void ItemAdded(SPItemEventProperties properties)
        {
            base.ItemAdded(properties);
            try
            {
           
                      if (properties.ListTitle == "Code Update")
                {
                    SPItem item = properties.ListItem;
                    item["B_x0020_ID"] = "B001";

                    item["T_x0020_ID"] = "T001";

                    item["T_x0020_Name"] = "T Name";

                    item["DB_x0020_Name"] = "DB Name";

                    item.Update();

                }
            }
            catch (Exception Err)
            {
                properties.ErrorMessage = Err.Message.ToString();

            }

        }

2. Copied following files to server. DDF file, Features folder which contains 2 xml file, DLL file, manifest.xml

3. Create wsp file by using the following command. makecab /F TestEventHandler.DDF

4. executed below commands one by one.

Add-SPSolution -LiteralPath E:\SharePoint\Eventhandler\Deployment\Package\TestEventHandler.wsp

Install-SPSolution -Identity "TestEventHandler.wsp" –WebApplication "http://docportal" -GACDeployment

Install-SPFeature "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\TestEventHandler"

Enable-SPFeature -Identity "8c9616a0-fcea-40be-adcc-f78a7a49b098" -Url "http://docportal"

Please let me know if I have done any mistakes. Still my event receiver is not firing in document portal while upload document. Please suggest me anyone asap. I have spent lot of time to drill down the issue but I could not rectify it.

Thanks in advance

Poomani Sankaran




How to re-initiate the items which failed in Event Receiver in SharePoint 2010?

$
0
0

Hi All,

I have a written a Event Receiver Item Added in SharePoint 2010. It has been bounded in Document Library. Event receiver was filed for some documents while uploaded. How to find and re initiate them. 

Please guide me on it.

Thanks & Regards

Poomani Sankaran

vb.net sharepoint web service reference

$
0
0

hello all,

recently i upgrade sharepoint 2007 into sharepoint 2010 and it is working fine

i have another old external outlook add in project, this project refers sharepoint 2007 web service http://MyServer/_vti_bin/lists.asmx so, i have deleted the existing sp2007 web service and added new sp2010 web service reference by the same name as like existing

now., the issue is old vb.net project code convertion, below is my below old code

Dim myservice As New sharepoint.Lists()

myservice.Url = "http://MyServer/_vti_bin/lists.asmx"

myservice.PreAuthenticate = True
myservice.UseDefaultCredentials = False
myservice.Credentials = New Net.NetworkCredential("serviceAccount", "password", "domain")

when i compile the project im receiving error as "ErrorBC30002Type 'sharepoint.Lists' is not defined.OutlookAddin"

experts please help me to resolve this issue!!

thanks

jey


Thanks In Advance, Jeyaseelan

How to create Event Receiver in SharePoint Online Office 365

$
0
0

Hi All,

We have configured web application in SharePoint Office 365. How to create Event Receiver and deploy them in to Document Library of SharePoint Office 365. 

Regards

Poomani Sankaran

Issue with selecting dynamically added values from dropdown in editform,aspx (custom)

$
0
0

hi,

i have custom editform.aspx page,in which i have dropdown data bind using spdatasource everything working fine.

now in js file on ExecuteOrDelayUntilScriptLoaded(Initializecontrols, 'sp.js');

function Initializecontrols(){
$('select[title$="spinsurancecity"]').prepend('<option value="test6" selected="selected">test6</option>');
		$('select[title$="spinsurancecity"]').val("test6");
}

so in editform the value selected in dropdown is test6, on click on save i am getting below error

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Note:in newform.aspx i m not able to enable event validation.

No server site code ,only js file with client side code

Same in NewForm.aspx(custom) it is working.

Please Let me know any way to achieve this.

Where is Microsoft.SharePoint dll?

$
0
0

I've browsed the MSDN posts that show how to add a reference to Microsoft.SharePoint.

I'm running Visual Studio 2010 Professional.  When I check Help/About, it lists Microsoft Visual C# 2010 (0108-532-2002181-70703), and Microsoft Visual Studio 2010 SharePoint Developer Tools (10.0.30319).

I'm trying to integrate this with an ASP.NET Web Application (Visual C# Web, .NET Framework 4), but I can't seem to find Microsoft.SharePoint.dll in the .NET list when I try to add a reference; when I browse to C:\Program Files\Common Files\Microsoft Shared\, I don't see the rest of the file structure I expect to see (Web Server Extensions\14\SAPI\Microsoft.SharePoint.dll).

Finally, searching the hard drive for Microsoft.Share*.* yields no results.

Do I need to create an Empty SharePoint project and import everything I've done so far into that?  Where do I get the proper DLL?

Thanks in advance for any help you can provide.  I would just like my SPSite, SPWeb, and SPFolder objects to be recognized.


MSVC++ Newbie

Viewing all 11571 articles
Browse latest View live


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