Tuesday, December 20, 2016

Set JSLink in List View using JavaScript Object Model (ECMA) Programming In SharePoint 2016 And Office 365




Steps:

  • Add Content Editor Web part (CEWP) to the SharePoint page.
  • Save the below script as a text file and upload it to Site Assets page.
  • Refer the script file from the CEWP.

Script:

<script language="javascript" type="text/javascript"
src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
 <script language="javascript" type="text/javascript">
 $(document).ready(function() {
 SP.SOD.executeFunc('sp.js', 'SP.ClientContext', setJSLink);
 });
var oView;
function setJSLink() {
 //Get the client context,web and list object
 var clientContext = new SP.ClientContext();
 var oWebsite = clientContext.get_web();
 var oList = oWebsite.get_lists().getByTitle('Products');
 //Get the view object and set the jsLink property
 oView = oList.get_views().getByTitle('CustomProductView');
 oView.set_jsLink("~site/siteassets/ListViewModification.js");
oView.update();
 //Load the client context and execute the batch
 clientContext.load(oView);
 clientContext.executeQueryAsync(QuerySuccess, QueryFailure);
}
function QuerySuccess() {
 console.log("JSLink has been set to the view.");
}
function QueryFailure(sender,args) {
 console.log('Request failed'+ args.get_message());
}
</script>

Get All Folders using JavaScript Object Model (ECMA) Programming In SharePoint 2016 And Office 365

Steps:

  • Add Content Editor Web part (CEWP) to the SharePoint page.
  • Save the below script as a text file and upload it to Site Assets page.
  • Refer the script file from the CEWP.

Script:

<script language="javascript" type="text/javascript"
src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
 SP.SOD.executeFunc('sp.js', 'SP.ClientContext', getAllFolders);
});
var oListItem,collListItem,clientContext;
function getAllFolders() {
 //Get client context,web and list object
 clientContext = new SP.ClientContext();
 var oWeb= clientContext.get_web();
 var oList = oWeb.get_lists().getByTitle('Demo Library');
 //use caml query to get the folder collection
 var camlQuery = new SP.CamlQuery();
 camlQuery.set_viewXml("<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef
Name='FSObjType'/><Value Type='Text'>1</Value></Eq></Where></Query></View>");
 camlQuery.set_folderServerRelativeUrl('/Sites/Playground/Demo
Library/NewFolder');
 collListItem = oList.getItems(camlQuery)
 //Load the client context and execute the batch
 clientContext.load(collListItem);
 clientContext.executeQueryAsync(Success, Failure);
}
function Success() {
 //get the folder collection and loop through it
 var listItemEnumerator = collListItem.getEnumerator();
 var oListItem;
 while (listItemEnumerator.moveNext()) {
 oListItem = listItemEnumerator.get_current();
 console.log(oListItem.get_item('FileLeafRef'));
 }
}
function Failure(sender,args) {
 console.log('Request failed with error message - '+ args.get_message()+' .
Stack Trace - '+ args.get_stackTrace());
}
</script>

Set User as Owner of Group using JavaScript Object Model (ECMA) Programming In SharePoint 2016 And Office 365



Steps:

  •  Add Content Editor Web part (CEWP) to the SharePoint page.
  •  Save the below script as a text file and upload it to Site Assets page.
  •  Refer the script file from the CEWP.
Script:

<script language="javascript" type="text/javascript"
src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
 SP.SOD.executeFunc('sp.js', 'SP.ClientContext', setAsOwner);
});
var oGroupUsers;
function setAsOwner() {
 //Get client context and web object
 var clientContext = new SP.ClientContext();
 var oWeb = clientContext.get_web();
 //Get group collection and specific group
 var groupCollection = oWeb.get_siteGroups();
 oGroup = groupCollection.getByName("HR Group");
//Set as owner
 var oUser =
clientContext.get_web().ensureUser('i:0#.f|membership|User@abc.on
microsoft.com');
 oGroup.set_owner(oUser);
 oGroup.update();
 //Load the client context and execute the batch
 clientContext.load(oGroup);
 clientContext.executeQueryAsync(QuerySuccess, QueryFailure);
}
function QuerySuccess() {
 console.log("Group Owner set.");
}
function QueryFailure(sender,args) {
 console.log('Request failed'+ args.get_message());
}

</script>


#SharePoint2016 And #Office365

Monday, December 19, 2016

Why is PHP so complex?

1. This is Hello World in Assembly Language:
  1. .model small
  2. .stack 100h
  3.  
  4. .data
  5. msg db 'Hello world!$'
  6.  
  7. .code
  8. start:
  9. mov ah, 09h
  10. lea dx, msg
  11. int 21h
  12. mov ax, 4C00h ;
  13. int 21h
  14. end start
2. This is Hello World in C++:
  1. #include <iostream>
  2.  
  3. int main() {
  4. std::cout << "Hello world!\n";
  5. }
3. This is Hello World in PHP:
  1. <?php
  2. print "Hello world!";
  3. ?>
4. This is Hello World in the Big Bang Theory:
From #1 to #3Complexity should not be defined by how many lines of codes an application contains. On the contrary, each language, from #1 to #3, is least complex and makes better applications if used in the right context. For example:
#1. Assembly writes better CPU/GPU processes,
#2. C++ writes better operating systems and video games,
#3. PHP … let’s just say … is versatile and practised by a huge community.
In the wrong context, any languages could become complex. For example, it is difficult and impractical to make a corporate website with Assembly and a video game with PHP. Programming is easiest when the right languages and tool sets are used (see also JavaJavaScriptPythonC language family and Haskell).
Between #3 and #4. Human language is still the most beautiful language ever. Our mind can interpret Hello World in both pictures and letters - more accurately than any computers or computer languages. How is that even possible is another topic all by itself. Yet, that is not to say that human language is not complex. It is.
I look forward to a day when we have the ability to program in human gestures and native languages. Meanwhile, between #3 and #4, that’s the next best thing we have.

Tuesday, December 13, 2016

What's the difference between RHEL and CentOS?


  1. Fedora is the main project, and it’s a communitity-based, free distro focused on quick releases of new features and functionality.
  2. Redhat is the corporate version based on the progress of that project, and it has slower releases, comes with support, and isn’t free.
  3. CentOS is basically the community version of Redhat. So it’s pretty much identical, but it is free and support comes from the community as opposed to Redhat itself.
There's no functional difference. 
 CentOS is RHEL relabeled to remove the Red Hat identity. 
Red Hat isn't going to support it, but you do get the benefit of all the work they put in on integration of the distribution,

fedora-redhat-centos