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

SharePoint item added event receiver firing only for few users

$
0
0

Hello Guys

I have got a problem with the one of the item added event receiver we deployed in production environment, It is firing only for few entries. After item added , event receiver need to move the list item to a folders inside the same list.

We have tested and its working fine from our side, but it is failing for few entries.

Please have a look at my code below, suggest me if i do any mistakes in my code.

  public override void ItemAdded(SPItemEventProperties properties)
        {
            try
            {
                var item = properties.ListItem;
                var _docRecType = item["Document_x0020_Received"].ToString();
                _docRecType = _docRecType.Split('#').Last();

                //Get the folder name by passing _docRecType to the returns folder method

                var folderName = getFolderName(_docRecType);

                var folderUrl = SPUtility.ConcatUrls(SPUtility.ConcatUrls(item.Web.Url, item.ParentList.RootFolder.Url), folderName);
                EnsureFolder(item.ParentList, folderName, folderUrl);
                MoveItemToFolder(item, folderUrl);
            }
            catch(Exception ex)
            {

                SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("Legal and Court Events", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);

            }

        }

        private static void EnsureFolder(SPList list, string folderName, string folderUrl)
        {
            if (!list.ParentWeb.GetFolder(folderUrl).Exists)
            {
                SPListItem newFolder = list.Items.Add(list.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, folderName);
                newFolder.Update();
            }
        }

        private static void MoveItemToFolder(SPListItem item, string folderUrl)
        {
            if (item.FileSystemObjectType == SPFileSystemObjectType.File)
            {
                var filePath = string.Format("{0}/{1}_.000", folderUrl, item.ID);
                var file = item.Web.GetFile(item.Url);
                file.MoveTo(filePath);
            }
        }

        private string getFolderName(string _docReccived)
        {
            string result = string.Empty;

            using (SPSite site = new SPSite("http://xyz"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["XL"];
                    SPQuery qry = new SPQuery();
                    qry.Query = "<Where><Eq><FieldRef Name='Document_x0020_received' /><Value Type='Text'>" + _docReccived + "</Value></Eq></Where>";
                    qry.ViewFields = "<FieldRef Name='Document_x0020_received' /><FieldRef Name='Folder' />";
                    qry.RowLimit = 1;
                    SPListItemCollection coll = list.GetItems(qry);
                    foreach (SPListItem item in coll)
                    {
                        result = item["Folder"].ToString();
                    }
                }

            }

            return result;
        }


Caml query returning same value all the time

$
0
0

Hi All,

I have a column name City which has different values Pune,Mumbai,Delhi etc and I have columns like population monthwise like JanCount, FebCount, MarCount etc

I have created a caml query to return data for each city value and where count not equals to zero.

The issue is that everytime the query returns me data for Pune city only.

The query is build usin caml query builder and returns me results when fired on caml query builder.

Till now I tried out 2 approaches :

1) Here with all city values in array and for each value of array calling function to get data with caml query value coming from array[i]

2) Here I created different functions with static query values .

In both cases returns me the data for Pune city only.

Please guide.

Same JavaScript two time

$
0
0

In SharePoint 2010, I used https://jqueryui.com/tabs/ with CEWP for tabs. It's work and fine. But When I use same thing in 2nd CEWP (another tab line) , It doesn't work. Seem like if you use same JavaScript two time with one page.. Both are not working.. Any Idea?

best Regards

Lasantha

Auto Populate a SharePoint New Form with the next sequential number. JQER20160401-001, JQER20160401-002, JQER20160401-003

$
0
0
I'm trying to auto populate a SharePoint New Form field with the next sequential number for the same date.
I'm trying to auto populate a SharePoint New Form field with the next sequential number. I'm trying to do this every time a New Form is opened. I have a calculated field which gives me the TrackingNumberPrefix ---> =CONCATENATE(JQER-",TEXT(Created,"yyyy")&""&TEXT(Created,"mm")&""&TEXT(CREATED,"dd"))     Now I need to someway copy the calculated field and check if it has changed and increment it and place the combined sequential number into a New Form field. I'm thinking I'll have to use JavaScript. Any ideas would be appreciated!

JQER20160401-001, JQER-20160401-002, JQER20160401-003


Michael L. Williams

Convert script powershel to c#

$
0
0

Hello

 I have convert the script powershell to c# code:

$web = Get-SPWeb "https://intranet.oursite.com/"
$list =$web.GetList("/sites/test/Lists/Order")
$view = $list.Views["ScriptTest"]
$exportlist = $null
$exportlist = @()
$items = $list.GetItems($view) | Group-Object Title

$items | select @{name="Title"; expression={$_.name}}, @{name="Quantity"; expression={($_.Group | select @{name="q"; expression={$_['ItemQuantity']}}  | measure q -sum).sum }}

Thanks


Consume custom SharePoint wcf service from SharePoint hosted app

$
0
0

Hi All 

     I want to consume custom wcf service which is hosted in sharepoint from another site collection's app part.

That mean want to consume vti_bin /service of one site collection from  app part of another site collection

I have referred the below. But having doubt where to create IHttpModule.Also if any other way to acheive this pls share

http://blogs.logicstrong.com/sharepoint-2013-consuming-custom-wcf-services-sharepoint-hosted-apps-authentication/

regards

Jhanani


Janani.R

Import share point list to excel return data is null (excel result empty but SharePoint list has more than 50000rows

$
0
0

I have a share point list i want to export share point list to excel 

It cross to more than 5000 rows and  it has consist of multi test drop down ,choices and No custom code

How can i resolve  this issue? i tried  change views but no luck ,any other options are available 

Please share Limitation export share point list to excel   


Sridhar Mandipudi


Twitter Certificate Error

$
0
0

Hello

Our public SharePoint was extremely slow. After going through the event logs I see this error message realated to Twitter:

An operation failed because the following certificate has validation errors:

Errors:

An operation failed because the following certificate has validation errors:

Subject Name: CN=api.twitter.com, OU=Twitter Security, O="Twitter, Inc.", L=San Francisco, S=CA, C=US
Issuer Name: CN=DigiCert SHA2 High Assurance Server CA, OU=www.digicert.com, O=DigiCert Inc, C=US

 PartialChain: A certificate chain could not be built to a trusted root authority.
RevocationStatusUnknown: The revocation function was unable to check revocation for the certificate.
OfflineRevocation: The revocation function was unable to check revocation because the revocation server was offline.
.

I think this is causing the slowness. What does the error message me and what can i do to resolve it

Thanks


implement spellcheck functionality in multiline textbox

$
0
0

Hi all,

I have customized the sharepoint default new form.aspx  page in the i added multi  line text box field.Now when i enter anything wrong in that text box  i need a right clcik and correct the spelling.I need this functionality in sharepoint 2001 multi line text box.Please help me how to implement this.Thanks in advance.

Regards,

Praveen            

timerjob to export to excel and email to uses

$
0
0

Is there any way to get an excel export from a SharePoint list and email to users in SharePoint 2010?

We have a list which update weekly and I want to email all users in format of Excel


How to give greater than or equal to in Search API

$
0
0
/sites/my/_api/search/query?querytext=%27(ContentTypeId:0x01489534544341EDD* AND ListId:C694N7-C900-48BE-V1E3-5094087615F2 AND FYOWSNMBR>=2000) %27&rowlimit=30&TrimDuplicates=true&selectproperties=%27ListItemID,Title,FYOWSNMBR%27

The above url is the one i use for Search API.

If I use FYOWSNMBR=2000 ,I will get result

But If I use FYOWSNMBR>=2000,I get an error message:" We didn't understand your search terms. Make sure they're using proper syntax."

Please provide me a suitable solution

Thanks in Advance


How do i send a Twitter direct message with a media file?

$
0
0

I'am using tweetsharp Library to Send a twitter direct message but not found a parameter for media although we Can upload media when we send message form twitter to any one of our followers.
So Could any one Help?

//Using tweetSharp library 
  var result = service.SendDirectMessage(new SendDirectMessageOptions
                    {
                        ScreenName = "twitterName",
                        Text = Message //No parameter for media          
     
                    });


Enable Sharepoint Desktop Sites to Mobile Support

$
0
0

Team,

I need a great help on developing the SharePoint sites on mobile. We have SharePoint sites which is running in desktop browsers. Now, we have to enable the sites on mobile and tablets. 

We have decided to use the Bootstrap but without visual studio. As I dont have the development server like visual studio how to customize the masterpage and existing page layouts.

Could you please help me on this ?

Many thanks !!

-Dhana


Dhana-Chennai-India

Link two Infopath forms in one sharepoint list

$
0
0

I am currently striggled with this question for the last days, wondering how can I change Infopath form during submission of data. The final goal is to click "add new item" in a sharepoint list, an infopath form will open, with two buttons. Each button will redirect to a different infopath form which they will be able to submit data in tha same list.

I do not want to use different views because its view has its special needs ( fields that have default values and fields that can not be blank), if I have different views then submitting the one view will submit the default values of the other which is something that I do not want.

Is there any good tutorial or does anyone have a good recommendation of how to achieve this?

Microsoft.SharePoint.Client.ClientRequestException Error

$
0
0

I'm trying to upload a text file to a sharepoint 2010 site. I'm using the following code:

Using stream As New MemoryStream()
    Dim writer As New StreamWriter(stream)
    writer.Write(line)
    writer.Flush()
    stream.Position = 0
    Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContextLoad, filename, stream, True)
    stream.Close()
End Using

I'm getting the following error and do not know how to get around it.

Microsoft.SharePoint.Client.ClientRequestException was unhandled by user code
HResult=-2146233088
Message=Unexpected response from the server. The content type of the response is "text/html; charset=utf-8". The status code is "Redirect".
Source=Microsoft.SharePoint.Client
StackTrace:
     at Microsoft.SharePoint.Client.File.SaveBinary(ClientContext context, String serverRelativeUrl, Stream stream, String etag, Boolean overwriteIfExists, SaveBinaryCheckMode checkMode)
     at Microsoft.SharePoint.Client.File.SaveBinaryDirect(ClientContext context, String serverRelativeUrl, Stream stream, Boolean overwriteIfExists)
     at Text_Replacer.Form1.wrk_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e) in C:\Users\Me\Documents\Visual Studio 2010\Projects\SWSPTools\SWSPTools\Editor\Form1.vb:line 502
     InnerException:

One other piece of info. We are using fedauth so I have to use the following to authenticate and generate the PUT method.

public void ClientContext_ExecutingWebRequestLoad(object sender, Microsoft.SharePoint.Client.WebRequestEventArgs e)
        {
            CookieContainer cc = new CookieContainer();

            foreach (var c in SharepointTrustCookies)
                cc.Add(c);
            e.WebRequestExecutor.WebRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)";
            e.WebRequestExecutor.WebRequest.CookieContainer = cc;
            e.WebRequestExecutor.WebRequest.Method = "PUT";
            e.WebRequestExecutor.WebRequest.Accept = "*/*";
            e.WebRequestExecutor.WebRequest.ContentType = "multipart/form-data; charset=utf-8";
            e.WebRequestExecutor.WebRequest.AllowAutoRedirect = false;
            e.WebRequestExecutor.WebRequest.Headers.Add("Accept-Language", "en-us");
            e.WebRequestExecutor.WebRequest.Headers.Add("Translate", "F");
            e.WebRequestExecutor.WebRequest.Headers.Add("Cache-Control", "no-cache");
           // e.WebRequestExecutor.WebRequest.ContentLength = line.Length;

        }


Here is how I create the clientContextLoad:

Dim clientContextLoad As ClientContext = New ClientContext(MY_SITE)
        Dim spAuth As SharepointClaimsAuthentication = New SharepointClaimsAuthentication(MY_USER_NAME, MY_PWD, INTERNAL_AUTH_SITE, EXTERNAL_AUTH_SITE, MY_SITE)
        spAuth.Authenticate()
        AddHandler clientContextLoad.ExecutingWebRequest, AddressOf spAuth.ClientContext_ExecutingWebRequestLoad
        clientContextLoad.Credentials = CredentialCache.DefaultCredentials

And here is the filename I am passing: /sites/my_Site/Team_Documents/Output.txt

I can successfully authenticate and iterate the sharepoint site because prior to writing the file I read the file and make a regex change. The issue is when I try to save the file.



viewing multiple lists in one big list

$
0
0

following problem.

I've got different lists created out of the same template list, so they all got equal columns.

Every list displays a business case. Now the idea is to create an overall list out of all those single lists to get an overview. Is there an opportunity to combine all rows of the different single lists to one big list?

thank you very much in advance

Programmatically move a document in a library to another site collection

$
0
0

I need to create an ItemUpdated event reciever on a documnt library that will detect when particular metadata value is updated on a document and move the document to a library in another site collection.

How can I programmatically move a document to a library in a different site collection? All of the other questions I can find on this site deal with moving the document to another library in the same site collection, and i know that SPFile.MoveTo() can be used for that but i need to move it to another site collection. It must be possible because it can be done through the SendTo link on the front-end.

Any ideas? TIA


Workflow Question

$
0
0
Am I able to use sharepoint designer 2010 to create a workflow that will refresh the data connection in an excel workbook saved to my site as new entries are made on a sharepoint list? I have a sharepoint list linked to an excel sheet in my site's library so I can visualize the data in an excel web part on a page. However, currently in order for the web part to refresh and show all of the list entries I have to open the actual workbook and refresh the connection. I am trying to identify a way to avoid this to prove more convenient for end users.

Insert column in multiple lists

$
0
0

Following Problem.

I've got multiple lists, that are created through the same list template, so they all got equal columns but different entries.

Now I need the opportunity to insert a additional column afterwards into all those lists with just one command, cause there are a lot of those lists. Is that possible and if it is how can I realize it?

Thank you very much in advance.

Adding NewItem using SP Services in sharepoint 2010 for lookup,Choice field and People Picker Field.

$
0
0

Hi all,

I have scenario where in i have to add the data to the list using js and spservices for lookup field,Dropdown field and People Picker Field.

The scenario is as below.

I have two List say A and B

A and B list has some compulsory fields.

I have page where i have a radio button say A and B

When I click in A the form of A should be displayed and when B is clicked the form of B is to be displayed and the data is to be saved in the list.

Currently i am able to acheive this by hiding the webparts but the problem which is occuring is because of the compulsory fields in A form i am not able to submit the data of form B.

As these forms are on the same page.

Can anyone guide me on the same line.I want the compulsory fields to be present and data should get added to the List.

Regards and thanks.


Shraddha

Viewing all 11571 articles
Browse latest View live


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