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

Calculated Column CSOM Get Option

$
0
0

I have Server Side Object Model code for getting the Calculated Column.

    SPFieldCalculated cf = (SPFieldCalculated)item.Fields["Down Time Duration"];
    req.DownTimeDuration = cf.GetFieldValueAsText(item["Down Time Duration"]);

What is the equivalent code in CSOM  for getting the value of Calculated Column ?


JQuery Data table with Date Range Filter

$
0
0

JQuery Data table with Date Range Filter (StartDate & EndDate)

Where all the data will come from SharePoint list :

Coloumn name are Start Date , EndDate (Date Range)

Other COloumn EmpNAme, EmpAddress, EmpNo

List Name-EMpDetails


Shiv Sharma

How to create a handler function that caters for a drop down.

$
0
0

I am creating an SPFX form and have managed to create a handler function that 'handles' multiple different text fields, but now I need a handler that can cater for multiple different drop down fields. I am using Microsoft Fabric UI.

The major issue is that for every textField a 'name' property can be called upon so the handler knows which textfield is which. A drop down doesn't have such a field. So how would I code a handler to cater for a drop down?

Here's my existing handler:

public onDropDownChange = (evt: any) => {
  const {value} = (evt.target as any);
  // const selectedItem = ((item && item.key) ? item.key.toString(): null );
  //What to put!!?
  this.setState({ 
  });
  console.log(value);
}

Any ideas on how to make a handler accept drop downs when they don't have a unique identifier like a textfield has?

Custom paging to retrive record accordingly not all at once

$
0
0

Greetings,

I have thousands of records in custom list , I want to retrieve 20/50,200,500 records per page using paging of bootstrap table ,

Currently working:

currently using CAML to fetch all records on load time and bind with bootstrap table where  bootstrap paging works to show records accordingly,

Problem:

facing performance issues while loading page (because it fetches all records as per query)

Solution Required:

showing paging options in drop down using bootstrap like (50,200,500,all ),

1) if user select 50 so first 50 records should be fetched,

2) if user choose 200 so 200 records should be retrived

3) on bottom of bootstrap table there is paging index like 1,2,3,4,5,next ,previous etc

if user choose page 2,so next 20/50 or 200 records should be retrived according to paging selection.

how can I do that kindly guide me.

thanks

How to get files from a folder in the library in one call

$
0
0

Hi Experts,

I have a requirement to list all files in the library folder, do you have any ideas how to do it with html client side ?

Power Shell Error: Exception calling “ExecuteQuery” with “0” argument(s): “File Not Found.”

$
0
0

I am building a script to essentially copy an entire directory to a SharePoint online library. I have gotten as far as building the folder directory on SharePoint but cannot seem to load any files onto the online directory. I believe I am really close to cracking this beast, I just need to solve one last error. The full error and my code are listed below:

I have bolded line #109

Exception calling "ExecuteQuery" with "0" argument(s): "File Not Found." At line:109 char:5 + $clientContext.ExecuteQuery() + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException+ FullyQualifiedErrorId : ServerException

...

###################### copy files 
cls
$t1  = get-date
$i=1
$count = ((Get-ChildItem -File  -Recurse -Path $source_folder) | Measure-Object -Property FullName ).Count
foreach ($file in (Get-ChildItem -File  -Recurse -Path $source_folder))
{
    $t01  = get-date
    #$url_dest = $url_sharepoint+$Url_site+$file.FullName.Substring($file.FullName.IndexOf($MainFolder)-1).ToLower().Replace('\','/')
    #$url_dest = $url_sharepoint+$Url_site+'/'+$library+(($file.FullName.ToLower()).Replace($source_folder.ToLower(),'')).Replace('\','/')
    $url_dest = $url_sharepoint+$Url_site+$library+$file.FullName.Substring($file.FullName.IndexOf($MainFolder)-1).ToLower().Replace('\','/')
    $FileStream = New-Object IO.FileStream($File.FullName,[System.IO.FileMode]::Open)
    $FileCreationInfo = New-Object Microsoft.SharePoint.Client.FileCreationInformation
    $FileCreationInfo.Overwrite = $true
    $FileCreationInfo.ContentStream = $FileStream
    #$FileCreationInfo.Content = System.IO.File.ReadAllBytes(filePath)
    $FileCreationInfo.URL = $url_dest
    $Upload = $mylist.RootFolder.Files.Add($FileCreationInfo)
    $listItem = $upload.ListItemAllFields
    $listItem['Title']=($file.Name).split('.')[0]
    Write-Host " Uploading file $i/$count $url_dest"
    $listItem.update()
    $clientContext.Load($Upload)$clientContext.ExecuteQuery()
    $t02  = get-date
    $speed ="{0:n2}" -f ($file.Length/($t02-$t01).TotalSeconds/1mb)
    Write-Host "...................upload speed was " $speed " MB/sec"
    $i++
    $FileStream.Close()
}
$mylist.Title

$t2=get-date
$size = "{0:n2}" -f (gci -path $source_folder -recurse | measure-object -property length -sum).sum



cls
$speed ="{0:n2}" -f ($size/($t2-$t1).TotalSeconds/1mb)
Write-Host "Medium upload speed was " $speed " MB/sec"

Displaying item in Context Editor web part from link (tab setup) in another Context Editor web part on same .aspx page

$
0
0

I have a tabbed setup in a context editor web part where I display four tabs with buttons in each tab that I want to link to text in another context editor web part on the same landing/base info .aspx page. This will allow me to structure all of my information in a browseable context without forcing the user out of the contained environment. The user basically gets to explore on the same page by just clicking on a tab and then any item in that tab to show the result in the other web part.

I am using jquery and css and show/hide on the tab view to make the tabs work. What I am not sure how to do is to drive content in the content editor web part (info section) to the right of the tabbed web part (tabbed section) when something in the tabbed section is clicked. I have heard that it is possible to use the same show/hide setup on the info section, but can't find any example code to make it work. Maybe someone could point me in the right direction?

I am concerned however that this show/hide approach might load everything at once and create an excessive load time, so if there is a better approach or I am wrong about this assumption, I am all for it.

Anything to get me started would be wonderful. I am sorry, but I cannot point anyone to my site to see what I mean or to examine my code as this is in a classified environment.

Thanks in advance...

Bill Meisheid
REDD Communication Consulting Company, LLC

"Access to the resource is forbidden" while connecting Sharepoint to Power BI

$
0
0

Hello Friends

I am using two month trial version for Power BI. I want to use Sharepoint List in Power BI to create charts. But, when I try to connect website or List, I got following error:

""Access to the resource is forbidden"

Is it because I am using trial version or some authorization issue from my organisation?

Arun


CORS REST Requests: SP.RequestExecutor Returning Error

$
0
0

I created a primitive form to test CORS requests. The HTML file contains the script element to load the SP.RequestExecutor.js file (this form works inside an aspx SP chrome file or outside of it).

I am doing a simple GET on a PDF at the remote site (which happens to be a sharepoint.com site), and following the script action in Chrome. The Chrome console shows the following output below. I reformatted it to show a line number to the left with the file and line # executing, then inserting an indented line below that shows the message. Identifying URLs were also changed to not show real URLs, although the "sharepoint.com" domain is correct.

01	CORSTestRESTRequests.html:198 
				appweb url = https://vendorsharepoint.sharepoint.com
02	SP.RequestExecutor.js:2  
				:The frame element does not exist. Put request in queue
03	SP.RequestExecutor.js:2  
				:Created IFrame https://vendorsharepoint.sharepoint.com/_layouts/15/AppWebProxy.aspx?SP.AppPageUrl=https://divisiongroup/SiteAssets/CORSTestRESTRequests.html
04	SP.RequestExecutor.js:2  
				:Create IFrameLoadTimeout 2
05	CORSTestRESTRequests.html:322 
				[Violation] 'click' handler took 3187ms
06	CORSTestRESTRequests.html:1 
				A cookie associated with a cross-site resource at http://vendorsharepoint.sharepoint.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
07	SP.RequestExecutor.js:2  
				:Processing IFRAME onload event
08	SP.RequestExecutor.js:2  
				:Clear IFrameLoadTimeout 2
09	SP.RequestExecutor.js:2  
				:Start to ping the IFRAME https://vendorsharepoint.sharepoint.com/_layouts/15/AppWebProxy.aspx
10	SP.RequestExecutor.js:2  
				:Create IFramePingTimeout 3
11	SP.RequestExecutor.js:2  
				:RequestExecutor.PostMessage.Message: {"command":"Ping","postMessageId":"SP.RequestExecutor2"}
12	SP.RequestExecutor.js:2  
				:RequestExecutor.PostMessage.Target: https://vendorsharepoint.sharepoint.com/_layouts/15/AppWebProxy.aspx
13	AppWebProxy.aspx?SP.AppPageUrl=https://divisiongroup/SiteAssets/CORSTestRESTRequests.html:201 
				ErrorPage.OnMessage: Origin=https://divisiongroup, Data={"command":"Ping","postMessageId":"SP.RequestExecutor2"}
14	AppWebProxy.aspx?SP.AppPageUrl=https://divisiongroup/SiteAssets/CORSTestRESTRequests.html:231 
				ErrorPage.PostMessage: Origin=https://divisiongroup, Data={"command":"Ping","postMessageId":"SP.RequestExecutor2","responseAvailable":false,"errorCode":-1007,"errorMessage":"Correlation ID: 6f842b9f-b0ca-a000-ef66-88b16d4445ad"}
15	SP.RequestExecutor.js:2  
				:RequestExecutor.OnMessage
16	SP.RequestExecutor.js:2  
				:RequestExecutor.OnMessage: Message.data={"command":"Ping","postMessageId":"SP.RequestExecutor2","responseAvailable":false,"errorCode":-1007,"errorMessage":"Correlation ID: 6f842b9f-b0ca-a000-ef66-88b16d4445ad"}
17	SP.RequestExecutor.js:2  
				:RequestExecutor.OnMessage: Message.origin=https://vendorsharepoint.sharepoint.com
18	SP.RequestExecutor.js:2  
				:Successfully load frame for https://vendorsharepoint.sharepoint.com/_layouts/15/AppWebProxy.aspx
19	SP.RequestExecutor.js:2  
				:RequestExecutor.PostMessage.Message: {"command":"Query","url":"https://vendorsharepoint.sharepoint.com/:b:/r/Corres/Submitted%20Letters/DF16-19-03040b-FA%20ASO%20Ack%20Ltr.pdf","method":"GET","postMessageId":"SP.RequestExecutor1","timeout":90000}
20	SP.RequestExecutor.js:2  
				:RequestExecutor.PostMessage.Target: https://vendorsharepoint.sharepoint.com/_layouts/15/AppWebProxy.aspx
21	AppWebProxy.aspx?SP.AppPageUrl=https://divisiongroup/SiteAssets/CORSTestRESTRequests.html:201 
				ErrorPage.OnMessage: Origin=https://divisiongroup, Data={"command":"Query","url":"https://vendorsharepoint.sharepoint.com/:b:/r/Corres/Submitted%20Letters/DF16-19-03040b-FA%20ASO%20Ack%20Ltr.pdf","method":"GET","postMessageId":"SP.RequestExecutor1","timeout":90000}
22	AppWebProxy.aspx?SP.AppPageUrl=https://divisiongroup/SiteAssets/CORSTestRESTRequests.html:231 
				ErrorPage.PostMessage: Origin=https://divisiongroup, Data={"command":"Query","postMessageId":"SP.RequestExecutor1","responseAvailable":false,"errorCode":-1007,"errorMessage":"Correlation ID: 6f842b9f-b0ca-a000-ef66-88b16d4445ad"}
23	SP.RequestExecutor.js:2  
				:RequestExecutor.OnMessage
24	SP.RequestExecutor.js:2  
				:RequestExecutor.OnMessage: Message.data={"command":"Query","postMessageId":"SP.RequestExecutor1","responseAvailable":false,"errorCode":-1007,"errorMessage":"Correlation ID: 6f842b9f-b0ca-a000-ef66-88b16d4445ad"}
25	SP.RequestExecutor.js:2  
				:RequestExecutor.OnMessage: Message.origin=https://vendorsharepoint.sharepoint.com

It seems that the transaction involves a "ping" command on line 11, followed by a response (?) on line 13 that is an error and more error info on line 14.  Then there is a "query" command on line 19 followed by more error info on lines 21 and 22.

The script calls the AJAX error function after all this messaging/transaction occurs.

Can anyone figure out what is happening in this activity? Thanks



Wrong Label return from managed metadata using Rest

$
0
0

I'm trying to load all the items from a list that contains some managed metadata fields using the REST api.

The API returns back an Id in place of the Label value,

Is there a way we can get real label value, can any one help on this ?

REST API to get current value in a multi-line text field with "Append changes to existing text" option on returns null

$
0
0

Hi,

as to the title,  I'm trying to read the current value in a multi-line text field. and "Append changes to existing text" option is turned on for this field. I am using REST API like this: http://url/_api/web/lists/getbytitle('RESectionFeedback')/Items but it gives me null values for this particular field. 

This is how the item with some values look like if I check it in SharePoint site, as you can see there are some records in feedbackContent field. 

But this is the result returned from the rest api, as you can see the feedbackContent field shows null,

I have searched around and found that I can use SPServices lib to get full list of versions for such field, but I don't really need the full version history but just need to current value, so it might be an overkill and cause some overheads. So I'd like to know if it's possible to get the current value using rest api and I just did not use it correctly, or it's just not possible.

Thanks,

Michael

Change document name via SharePoint workflow

$
0
0

I have a document library that will hold documents that need to be signed. The documents are PDFs. They are automatically generated and I have control over how they are named. I have named them with the email addresses of the people that will need to sign these documents. then created a workflow which starts when a new document is added to the document library that performs the following:

  • Sets Variable UserEmailAddr to Current Item: Name
  • Set Current Item: Name to Test.pdf
  • Send Email addressed to UserEmailAddr with link to document (https://site/doclib/[Name])

The workflow works fine with a link in the email to the newly renamed document.

My problem is that I am going to be dropping hundreds of documents into this document library and I want the documents renamed something like FirstName LastName FormName.pdf.

All email addresses are formatted FirstName.LastName with various endings like FirstName.LastName.10.abc@domain.com or FirstName.LastName.2@domain.com or FirstName.LastName@domain.com.

I am trying to figure out how to extract the FirstName and LastName from the email address and then rename the file.

Since I have full control of the process that generates these PDFs, I can name them anything I want if that helps.

Thank in advance for any assistance.


MCSE + I

SPO autocomplete filter results display value from List's 'Title' field BUT filters based on another field in that same list?

$
0
0

I want my autocomplete filter to display the search results based on the Companies list item's Title field while filtering the page's WPs based on another field in the Companies list. I am working with the following lists (see image below). I cannot get this working -- any help or guidance would be appreciated!

 - List view WP "Companies" [cols: ID, Title, CiqId]
 - Document Library view WP "SourcesLibrary" [cols: CompanyId, CiqId](!)

(!)CompanyId is a text field populated by Companies list,'Title' field  
(!) CiqId is a text field populated by Companies list, 'CiqId' field*

The Filter
I have an HTML WP filter whose autosuggest results are populated by the "Companies" list 'Title' field. This is working properly. What I can't figure out is how to use this filter to filter the page web parts based on the 'CiqId' field while still displaying the 'Title' field values as search results. I've included the script for this filter at the bottom of the post.

Use-Case
When the term "3M" is entered into the HTML Form WP filter, the value "3M" is displayed in the filter's dropdown results while the list view and library WPs are filtered by the value "D", as that is the value in the item's 'CiqId' field. This results in the list view and library WPs showing all items and documents matching the 'CiqId' value "D", which would include "3M" and "Post-it". See the link to view the sample data: https://i.stack.imgur.com/Y2Ik1.jpg

Right now, my filter displays the Title field as search results and filters the page's WPs based on that value as well.

    <html>
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- css -->
    <link href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.css" rel="stylesheet" >
    <link href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css" rel="stylesheet" >
    <link href="//stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" >
    <link href=//stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" >
    <!-- js -->
    <script src="//code.jquery.com/jquery-3.3.1.slim.min.js"></script>
      <script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
    <script src="//stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
    <script src="//code.jquery.com/jquery-3.2.1.slim.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="//code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
    <div id="preloader" class="spinner"></div>
    </head>
    <body>
    <script type="text/javascript">
    $(document).ready(function()
    { 
    var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body> <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'><listName>Companies</listName><viewFields><ViewFields><FieldRef Name='Title'/> </ViewFields></viewFields> </GetListItems> </soapenv:Body> </soapenv:Envelope>";
//Make a call to the List WebService using the SOAP envelope described above.
//The URL is fixed to a Specific Site Root.  Feel free to change this
//to your own fixed root or do some jscript voodoo to figure out where
//Of course in 2010 you can do this with the Client Object Model, or hit
//the list rest Service and return json, so enabling jsonp cross site calls.
$.ajax({
url: "https://birchbox.sharepoint.com/_vti_bin/lists.asmx",
    type: "POST",
    dataType: "xml",
    data: soapEnv, 
    contentType: "text/xml; charset=\"utf-8\"",
    success:  function( xmlResponse )         { 
    var domElementArray=$( "z\\:row", xmlResponse ); 
       var dataMap = domElementArray.map(function() 
       {     
       return { 
       value: $(this).attr('ows_Title') , 
       id: $(this).attr('ows_Title') 
       }; 
       });  
                var data = dataMap.get(); 

                //Find the Sharepoint Portal Search Box (this is a poor selector, but it is not properly named by sharepoint, well it is but INamingContainer gets in the way)    
               $( "#tags2" ).autocomplete(    
                {                 source: data  
                });
                }     

                });//.ajax   

                 });//docReady 

          </script>
    <div id="gobuttons2">
    <div class="ui-widget"></div>
    <div class="input-group mb-3" onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_">
    <input id="tags2" name="tags2" input type="text" class="form-control" placeholder="Type a company name and click 🔍" aria-label="Type a company name and click 🔍" onchange="javascript:_SFSUBMIT_"/>
        <div class="input-group-append">
    <button type="submit" class="btn btn-outline-danger btn-sm" onclick="javascript:_SFSUBMIT_"><i class="fa fa-search"></i></button>
    <button type="button" class="btn btn-outline-dark btn-sm" onclick="javascript:_SFRESET_"><i class="fa fa-refresh"></i></button>
    <button type="button" href="#" class="btn btn-outline-dark btn-sm" onclick="tags2.value=''"><i class="fa fa-eraser"></i></button>
    </div></div></div>
    </body>
    </html>

                                                  

List does not exist

$
0
0

After migrating the SharePoint 2013 Custom form of a list (Request) to SharePoint Online, it shows the below error. 

It seems to be  the GUID of the List is changed. How can I update this ?

How to workaround list threshold limit

$
0
0

Hey SharePoint Fam,

I have a environment where list threshold limit is 10k and list is almost over that limit.  The user needs to be able to query the data daily to find specific entries that may go back years ago.  Is there a way to not show any records and just show a search box where they can search the data and it returns that specific entry?  Really don't necessarily need to show all 10k items on default view at all but need to somehow query that data.

Thanks For Any Help


How do I delete a specific folder from SharePoint using Power Shell script?

$
0
0

I have multiple main folders on SharePoint online each with their own sets of sub-folders and files. I need to delete a specific folder (and its full contents including any sub-folders and files) from each of those main folders. The folder has the same name across all main folders, but obviously it does not share the same file path/url. This is what I have come up with so far from the research I have done.  The code for deleting the folder is not even running as far as I can tell.  Any and all help is greatly appreciated.

$url_sharepoint = "https://company.sharepoint.com"
$library = "Sharepoint Library"
$deleteFolders = "Folder Name"
$source_folder = "Network Share:\filepath"

$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $SecurePassword)
$clientContext.Credentials = $cred

$mylist = $clientContext.web.Lists.GetByTitle($library)
$clientContext.Load($mylist)
$clientContext.ExecuteQuery()

#Get name of folder
$MainFolder = Split-Path $source_folder -Leaf

#upload folder to sharepoint
$UploadMainFolder = $mylist.RootFolder.Folders.Add($MainFolder)
$clientContext.Load($UploadMainFolder)
$clientContext.ExecuteQuery()

$folders = $UploadMainFolder.Folders[$library].SubFolders

Foreach($folder in $folders)
{
    if ($folder.Name -match $deleteFolders)
    {
        $UploadMainFolder.Folders[$library].SubFolders.Delete($folder)
        Write-Host "Folder has been deleted!"
    }
    else
    {
        Write-Host "Folder has not been deleted!"
    }
}

Powershell example on how to upload large files using Graph

$
0
0

Hi, 

Does somebody have an example on how to use Graph to upload large files to a sharepoint library using an uploadsession as prescribed by Microsoft in the Graph API reference : Graph API reference Upload Session ?

I am able to get access to Graph using a token by making an Azure AD application. I am able to get the necessary drive ID's of the libraries. Where i'm lost is the part where you have to chunk up the file you want to upload and how to send the binary parts within the invoke-restmethode instructions. Does sombody have an example or can somebody point me in the right direction ?

thx


robtor

Search and replace email user profile database

$
0
0

Hi, we have a need to search all user email in SharepPoint 2013 user profile database and replace them with null value

For example

If user email address contain "@ace.com" value

replace email address with empty value

I need PowerShell script sample to do this.

Thanks

Tee

SharePoint Url filter with JavaScript

$
0
0

I want a custom form to do filter with SharePoint column value . I know we can use Url filter, but I want to have a inputbox to pass the filter value.

Can anyone provide an example ?

CSOM unauthorized error with windows authentication

$
0
0

Hi,

I am  trying to authenticate my custom web app with CSOM (Project Context) with windows authentication but for some reasons it is giving error as unauthorized. I have tried all methods credentialcahce.defaultcredentials or network credentials everything even event handlers mentioned in some forums but the error is still there. below is hsort snippet of my code

 ProjectContext projcontext = new ProjectContext(SiteURL);
 // projcontext.ExecutingWebRequest += new EventHandler<WebRequestEventArgs>(clientContext_ExecutingWebRequest);
 projcontext.Credentials= CredentialCache.DefaultCredentials;
projcontext.ExecuteQuery();

Viewing all 25064 articles
Browse latest View live


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