If somebody like the post and its helpful in your work then, add comments.

Monday, October 21, 2013

Create SharePoint(2013) Publishing pages using ECMASCRIPT

Well, to create paged from page layouts in the Publishing site in SP2013, I have tried the below code

First get the context for web,

             context = new SP.ClientContext(webUrl);  web = context .get_web();

Then get the publishing web for the site

                               pubweb = SP.Publishing.PublishingWeb.getPublishingWeb(context1, web );

                                context .load(web );

                                context .load(pubweb);                               

                                 context .executeQueryAsync(onquerysucced,onqueryfailed);

In onquerysucced get all the pages in the master page library

            

var pageLibrary = web.get_lists().getByTitle("Master Page Gallery");  

var camlQuery = new SP.CamlQuery;

items = pageLibrary.getItems('');

context .load(items,'Include(Id,Title,File)');

context .executeQueryAsync(onPagelayoutsuccess,onqueryfailed);

 

In onPagelayoutsuccess method

             var listItemEnumerator = items.getEnumerator();

             var listItemInfo = '';

             while (listItemEnumerator .moveNext()) {

            var oListItem = listItemEnumerator.get_current();

                pageItems.push({

                "Id":oListItem.get_id(),

                "Title":oListItem.get_item('Title'),

                "obj" :oListItem //Add Object in the list            

                });

             pageItems.push(oListItem);

             }

             //knockout js work for finding the required page layout item from the list

             var newPage = ko.utils.arrayFirst(pageItems(), function(item) {

                                return item.Title == "CT_PageLayout.aspx";

                                }); 

            

          pageInfo = new SP.Publishing.PublishingPageInformation();

          pageInfo.set_name("CT_PageLayout.aspx");

          pageInfo.set_pageLayoutListItem(newPage.obj);

          newPage = pubweb.addPublishingPage(pageInfo);

          context.load(newPage);

          context.executeQueryAsync(onPageCreationSuccess,onqueryfailed);

         };

         function onPageCreationSuccess(){                                

                                                                listItem = newPage.get_listItem();

                context.load(listItem);

                 context.executeQueryAsync(onPageSuccess,onqueryfailed);

          };

Tuesday, October 8, 2013

SharePoint 2013 : Get SharePoint items in Knockout js observableArray

To get the list tem in the observableArray, just declare a array in the js and get as below code

list = ko.observableArray(),


 getCourses = function () {
var
clientContext = TRANAPP.context;
var oList = clientContext.get_web().get_lists().getByTitle('Courses'
);
var myQueryString = '<View><RowLimit>1000</RowLimit></View>'
;
var newQuery = new
SP.CamlQuery();
newQuery.set_viewXml(myQueryString);
courseItems = oList.getItems(newQuery);
clientContext.load(courseItems,
'Include(Id, Title, CourseDescription, Author)'
);
clientContext.executeQueryAsync(onGettingCourses, onQueryFailed);
},
onGettingCourses =
function
(sender, args) {
var
allCourse = courseItems.getEnumerator();
while
(allCourse.moveNext()) {
var
currentCourse = allCourse.get_current();
list.push({
"Title": currentCourse.get_item('Title'
),
"Id"
: currentCourse.get_id(),
"CourseDescription": currentCourse.get_item('CourseDescription'
)
});
}
},
onQueryFailed = function (sender, args) {
alert(
'Request failed. ' + args.get_message() + '\n'
+ args.get_stackTrace());
},

SharePoint : Open the list item directly to edit mode.

To open the list item directly to edit form instead of the display form.

image

Then we have to edit the view on which the list item is showing. Just open the view in the designer in advanced mode and click on the “Title” column=>SQL server basics.

image

And see the properties which are associated,

image

Change the HREF property to below property just change the “$FORM_DISPLAY” to “$FORM_EDIT”

{$FORM_EDIT}&ID={$ID}&ContentTypeID={$thisNode/@ContentTypeId}

SharePoint 2013 : Add lookup column from in a list from VS2012

To add the lookup column in the SharePoint list in visual studio 2012 wizard we have to create first list from we have to add lookup column in anther list.

image

Then add anther list, like below in this list Course is lookup column

image

Just edit the properties other lookup column ‘Course’, and add the List to =Lists/Courses and  ShowField to Title

image

SharePoint 2013 : Add date and time field on your custom page

Add the date and time SharePoint control in the SharePoint 2013 hosted app.

image

Just drag and drop the controls on the page from toolbox of the VS2012

 

image

The code block will look like as follows :

<SharePoint:DateTimeControl ID="srtDate" ClientIDMode="Static" AutoPostBack="false"
                       runat="server" ToolTip="Start date for training beginning" />

But when you render this control from your app it does not load on the page, and give below screen error.(500 INTERNAL SERVER ERROR)

image
Then add the following property of the control : DatePickerFrameUrl="../_layouts/15/iframe.aspx" and add the ralative pat of the app like as I added “../”. After that it will render the control on the page.

image

Wednesday, September 25, 2013

SharePoint 2013 : Create a declarative workflow in O365 SharePoint Hosted App

Hi,

Well, recently I encountered Smile with one requirement to send email from Office 365 SharePoint Site. The scenario is like send a mail from SharePoint List, and have to take email address from the SharePoint List column, say Email.

Snap

 

image

Variables image
image image
image image
image image
image image
image image
image image
image image

So, In above activity well achieve to send email from list in O365. But still I am looking for sending email’s to other domains.Right Now its sending the email in its domain, like I have created ZapataIndi.onmicrosoft.com.

Sunday, January 20, 2013

Link for “Sign in as Different User” in SharePoint 2013

It’s think the developer team of the SharePoint 2013 forget to add the  “Sign in as a Different User” menu command in SharePoint 2013 Smile

No worry’s we can add that using the below steps(on premise)

  1. Open the Welcome.ascx from “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES”
  2. Find the “<SharePoint:MenuItemTemplate runat="server" id="ID_RequestAccess"”.
  3. Press enter and add
  4. <SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser"
    Text="<%$Resources:wss,personalactions_loginasdifferentuser%>"
    Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>"
    MenuGroupId="100"
    Sequence="100"
    UseShortId="true"
    />

  5. Save the welcome.ascx

Now you can see that “Sign in as Different User” appears at drop down.


Signin


 



Enjoy SP 2013