20
votes
Accepted
How to check whether the current user has edit permission for a particular list using JSOM in SharePoint 2013
You can try using below code. Since its OnPrem, we first need to get the login name of user and pass it to the get_effectiveBasePermissions method.
To ensure that user has edit permission, we will ...
13
votes
Accepted
Get Parent web of a subsite using JSOM in SharePoint 2013
Using your SP.Web object, you can get the parent information (SP.WebInformation). Using its ID, you can then, via the site collection, get the parent web object.
var context = new SP.ClientContext....
13
votes
Accepted
How to get List name by its GUID using Javascript
You can use the below rest call as well.:
Replace guid with your list guid.
$.ajax({
url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists(guid 'b778bbec-dd69-4a6c-9437-c73972c36292')",
...
12
votes
Using jQuery $(document).ready() in JavaScript Object Model
Document ready event gets fired when the DOM get loaded. This doesn't necessarily guarantee that the JS files required for SharePoint JSOM is already loaded.
The best way is
SP.SOD.executeFunc('sp....
12
votes
Accepted
Which one is faster CSOM or JSOM
Check out this excellent article where the performance of both is tested: Deep Dive – REST and CSOM Comparison
I tested a series of pretty common operations in both REST and CSOM:
Creating ...
11
votes
Accepted
How to get the current list/library name using JSOM?
Use ctx to get current list/library info. For Name or Title, It is
ctx.ListTitle
PS: No callback needed
Following information can be retrieved from ctx about current list/library in SharePoint 2010....
11
votes
Accepted
'ctx' variable in SharePoint
ctx is a global variable. It belongs in the list view pages.
var ctx = SP.ClientContext.get_current();
So if you use above line in any list view pages, it will cause an issue. The value of ctx will ...
11
votes
How to get List name by its GUID using Javascript
Using Client Object Model will help in this case:
var oList;
function getListTitleById() {
var clientContext = SP.ClientContext.get_current();
oList = clientContext.get_web().get_lists()....
10
votes
Accepted
Get current user id in JSOM on sharepoint online
Can you not use _spPageContextInfo? It has the current user ID built in:
_spPageContextInfo.userId
https://social.technet.microsoft.com/wiki/contents/articles/29766.sharepoint-understanding-the-...
9
votes
create custom permission level in SharePoint Site programatically in JSOM or CSOM
CSOM For O365
This creates a permission level inherited from the Full Control level, and can be changed to your desirable permission level.
namespace Console.Office365
{
using Microsoft....
9
votes
How to check whether the current user has edit permission for a particular list using JSOM in SharePoint 2013
Here is the code you are looking for:
var ctx = new SP.ClientContext.get_current();
var web = context.get_web();
var ob = new SP.BasePermissions();
ob.set(SP.PermissionKind.manageWeb)
ob.set(SP....
7
votes
Accepted
Programmatically create workflow with JavaScript, JSOM and SP.WorkflowServices.WorkflowServicesManager
You need to load Id of the definition before creating subscription.
Also subscriptionService.publishSubscriptionForList needs guid object instead of just GUID string.
When we create List workflow ...
7
votes
Accepted
how to get a list's add new item URL with JSOM?
Load DefaultNewFormUrl property of the list. Example:
clientContext.load(list, 'DefaultNewFormUrl');
Then retrieve it in the success method:
var newUrl = list.get_defaultNewFormUrl();
7
votes
Accepted
How to get and set custom 'Web' properties in SharePoint online using javascript
You can read/write to web property bag using JavaScript object model. Example of reading the custom property:
//wait until client object model dependencies are loaded before executing our code
...
7
votes
Display SharePoint list Hyperlink column Value Using JSOM
Hyperlink is a object. You can get its property by following
For description
listItem.get_item("{column internal name}").get_description()
For Url
listItem.get_item("{column internal name}")....
7
votes
Accepted
how to change the default gear icon look in SharePoint 2013?
You can change the icon using the following small jQuery code
$( document).ready(function() {
$('.ms-siteactions-imgspan > img').attr('src','url_Of_your_image');
});
7
votes
Accepted
SharePoint hosted-add in save date object in list
The problem is that you are using the method getDay(). That method will give you the day of the week in this case 3. You should be using the method getDate().
var dt = new Date(dtTest.getFullYear(), ...
7
votes
Accepted
How to pull data from root level site and display in subsite using JSOM?
Get the root site url as shown below:
var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
Get client context using that url as shown below:
var context = new SP.ClientContext(siteUrl);
list = context....
7
votes
How to resolve "The property or field 'ListItemCollectionPosition' has not been initialized.." error?
You can include it like below.
clientContext.Load(listItems,items => items.Include(item => item.Id), items => items.ListItemCollectionPosition);
7
votes
How can I get count of similar items records from list in SharePoint hosted app?
If I am not wrong, you want to group the list item with the column ids as displayed in the below image:
In order to achieve this, please follow the following link:
https://piyushksingh.com/2016/11/21/...
6
votes
How to move list item into folder in Sharepoint online
Example: how to move list item into a folder via SharePoint JSOM API
/**
* Move ListItem
* @param {SP.ListItem} list item
* @param {string} targetFolderUrl - server relative url of folder where ...
6
votes
Get Parent web of a subsite using JSOM in SharePoint 2013
An alternative to using the get_parentWeb is using the _spPageContextInfo object for urls and only needs one execute:
if(_spPageContextInfo.siteServerRelativeUrl != _spPageContextInfo....
6
votes
Zip document library using JSzip
You could consider the following solution:
retrieve files collection via SharePoint JSOM API
utilize getBinaryContent(path, callback) from JSZipUtils to load
file content by file url
generate zip ...
6
votes
Accepted
JSOM : run work flow using Javascript
You seem to pass 3 parameters to you method, that only expects 2, and seem to have mixed up the order of them.
function startWorkflow(itemID, subID)
So you should first pass the itemID, the integet ...
6
votes
How to pull data from root level site and display in subsite using JSOM?
This could help
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var parentInfo = web.get_parentWeb();
var parentWeb = context....
6
votes
Accepted
How to retrieve dropdown options list
In SharePoint, I assumed that Column type is "Choice field".
Below is the code for get all choices from that choice field:
$.ajax({
url: "Site URL"+"/_api/web/lists/GetByTitle('List Name')/...
6
votes
Accepted
Can I use elevated permissions using JSOM, CSOM, or REST?
Sorry, but there is no way to run at elevated privileges from the client-side, and if there was a way, it would be roughly 0% secure.
Depending on what you're trying to achieve, there are some ways ...
5
votes
how to get a list's add new item URL with JSOM?
I guess your are looking for SP.List.defaultNewFormUrl property (sp.js).
var value = SP.List.get_defaultNewFormUrl();
Try following
var list = clientContext.get_web().get_lists().getByTitle("...
5
votes
Accepted
JSOM peoplepicker 500 error
Using JSOM in the past I have experienced this trouble when I have a lack of system resources, specifically when my systems RAM has less than 5% available.
The fact that you are getting a Service ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
jsom × 872sharepoint-online × 314
javascript × 301
csom × 126
2013 × 94
sharepoint-enterprise × 87
sharepoint-server × 72
sharepoint-addin × 66
rest × 62
office-365 × 58
sharepoint-rest-api × 54
jquery × 53
list × 49
2010 × 39
client-object-model × 32
caml-query × 31
sharepoint-hosted-app × 28
web-part × 24
2016 × 22
sharepoint-designer × 20
caml × 16
workflow × 15
development × 15
sharepoint-foundation × 15
document-library × 14