I am trying to update specific property of Sharepoint 2013 list item, ie. 'SharedWithUsersId'. Although I get the response code as 204 (indicating success), when I check the list item again, I am not seeing any change in the sharedWithUSersId. When I tried changing other properties, like title, it worked like a charm. So, I want to know if 'sharedWithUSersId' property cannot be edited via this particular api call?
Cheers, Z
It can be changed, but not directly. You can do it by REST API. For example:
function setNewPermissionsForGroup() {
var endpointUri = appweburl + "/_api/SP.AppContextSite(#target)/web/lists/getbytitle('";
endpointUri += listTitle + "')/roleassignments/addroleassignment(principalid=" + groupId;
endpointUri += ",roledefid=" + targetRoleDefinitionId + ")?#target='" + hostweburl + "'";
executor.executeAsync({
url: endpointUri,
method: 'POST',
headers: { 'X-RequestDigest':$('#__REQUESTDIGEST').val() },
success: successHandler,
error: errorHandler
});
}
You can find more details here
Related
I am trying to change style of sharepoint list using CSR. I want to apply bold to title column. I have added these code in JS file and reffered as JSLink(JavaScriptDisplayTemplate) to webpart. On document ready both renderTitleHandler & preRenderHandler are registered and also preRenderHandler are called successfully. But renderTitleHandler are not fired.
Please find my code snippet,
function renderTitleHandler(ctx) {
var fieldVal = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
var title = fieldVal.toString();
var html = '';
html += '<b>' + title + '</b>';
return html;
}
function preRenderHandler(ctx) {
ctx.ListTitle = '<b>' + ctx.ListTitle + '</b>';
}
(function() {
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.OnPreRender = preRenderHandler;
overrideCtx.Templates.Fields = {
"Title" : {"View" : renderTitleHandler}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
Thanks in advance.
Kannan.
Possibilities:
disable Minimal Download Strategy (mds). Sometimes this blocks your
javascripts caused by the async loading in the back of certain OOTB
scripts
remove the debugger;-line (is it possible that your code works when developer tools in your browser are open?)
Edit:
Found an example on my dev environment and i have the word View between quotes:
linkFilenameFiledContext.Templates.Fields = {
"Title": { "View": renderTitleHandler}
};
Hope it helps
I have a function in an Ember library that generates html.
getHTMLPreview: function(preview){
var article_div ="<div class='onebox'>"
+ "<a href='"+preview.url+"'</a>"
+ "<article class='onebox-body'><div class='remove-preview'></div>"
+ ( preview.img !== "" ? "<img src='"+preview.img+"' class='thumbnail'/>" : "")
+ "<h3><a href='"+preview.url+"'>"+preview.title+"</a>"
+ "</h3>"
+ "<p>"+preview.description+"</p>"
+ "</article>"
+ "<div style='clear:both'></div></div>"
;
return article_div;
}
I want to add a click handler on $(".remove-preview") and do something when that div is clicked.
getHTMLPreview is called on the success of an ajax function in the same library.
If you are building your html outside of ember, you might as well hook up your event handling outside of ember. There is no gain in hacking in the action control from ember to it. If you need to interact with ember at some point, you will need to access the private container to gain access to a controller/route you want access too.
var fooController = App.__container__.lookup('controller:foo');
I'm trying to fetch data from the facebook FQL api using google appscript. Unfortunately, I keep getting the following error:
Error encountered: Invalid argument: https://graph.facebook.com/fql?q=SELECT+post_id,share_info,comment_info,like_info,created_time+FROM+stream+WHERE+post_id+IN+(SELECT+post_id+FROM+stream+WHERE+source_id='SOME_SOURCE_ID'+AND+created_time+>+1369869370+AND+created_time+<+1377645370+ORDER+BY+created_time+DESC+LIMIT+0,100)&access_token=XXXXXXXXX
If I copy/paste the url into my browser, I get a valid JSON response which makes me think that the url is valid, however, if I look at the execution transcript, it points me to the var postfetch = UrlFetchApp.fetch(...) line.
Here's my code.
var posturl = "https://graph.facebook.com/fql?q=SELECT+post_id,share_info,comment_info,like_info,created_time+FROM+stream+WHERE+post_id+IN+" +
"(SELECT+post_id+FROM+stream+WHERE+source_id='" + source + "'+AND+created_time+>+" + istartEpoch.toString() +
"+AND+created_time+<+" + iendEpoch.toString() + "+ORDER+BY+created_time+DESC+LIMIT+0,100)&access_token=" + token;
var postfetch = UrlFetchApp.fetch(posturl);
var postjson = postfetch.getContentText();
var postdata = Utilities.jsonParse(postjson);
It turns out that < and > aren't valid characters to put into a url. Changing them to %3E and %3C and now all is right with the world.
I am working on a facebook mobile web app. There is the following function.
function getUserFriends() {
FB.api('/me/friends&fields=name,picture', function(response) {
console.log('Got friends: ', response);
if (!response.error) {
var markup = '';
var friends = response.data;
for (var i=0; i < friends.length && i < 25; i++) {
var friend = friends[i];
markup += '<img src="' + friend.picture + '"> ' + friend.name + '<br>' + friend.id + '<br>';
}
document.getElementById('user-friends').innerHTML = markup;
}
});
}
When it returns the pictures are missing.
The console log returns:
[06:02:12.503] GET http://m.mochirestaurant.com/fb/%5Bobject%20Object%5D [HTTP/1.1 404 Not Found 77ms]
While it should return something like:
http://profile.ak.fbcdn.net/hprofile-ak-ash2/276211_285403872_5043326_q.jpg
I think I misconfigured something in my facebook app but don't know what it is
[06:02:12.503] GET http;//m.mochirestaurant.com/fb/%5Bobject%20Object%5D [HTTP/1.1 404 Not Found 77ms]
Instead of a real value you can see that it says [object] in there (with the brackets URL-encoded) – which is what browsers return when you are trying to bring an object into a string context. (And because that is not a full URL beginning with http://…, your browser treats it as a relative address and tries to request it from your domain.)
So obviously friend.picture at this point in your code is not a string value, but an object.
(So far for the debugging and spotting-the-error-part.)
This stems from the October 3, 2012 Breaking change regarding the user/picure connection,
/picture connection will return a dictionary when a callback is specified
We will start returning a dictionary containing the fields url, height, width, and is_silhouette when accessing the /picture connection for an object and specifying a callback property. Currently we just return the picture URL as a string.
So you have to use friend.picture.url in your code to get the actual string property containing the user picture’s URL.
I'm new with Django + Ajax. My Problem is I can't get the value from my ajax POST request. I'm using the jquery post.
My task is to sort the draggable list item. The drag and drop is not the problem. Getting the values from POST request is the problem. It returns MultiValueDictKeyError
"Key 'ages' not found in <QueryDict: {u'action': [u'updateRecords'], u'ages[]': [u'80', u'81', u'79', u'82', u'83', u'84', u'85', u'86']}>"
here is my ajax:
$(function() {
var url = ""; /* won't place it*/
$("ul#ages").sortable({ opacity: 0.6, cursor: 'move', update: function() {
var order = $(this).sortable("serialize") + '&action=updateRecords';
$.post(url, order, function(theResponse){
alert('success');
});
}
});
});
here is the views:
if request.is_ajax():
if request.POST['action'] == "updateRecords":
update_record_array = request.POST['ages']
order_counter = 1;
for record_id in update_record_array:
Age.objects.filter(id=record_id).update(order_id=order_counter)
order_counter += 1
Can anyone help me out?
Thanks!
The error message shows what is wrong - you're looking up a key ages, but you're sending something called ages[] with some extra square brackets.
If you've put those brackets in the field name, you don't need them - that's a PHP-ism. (It might not be your fault: jQuery has been known to do add them itself.) In any case, you'll want to use request.POST.getlist(fieldname) to get the list of multiple values associated with that key.