Tuesday, August 12, 2014

set textbox value in jquery

$("#s1").val("Glenn Quagmire");

get data row from custom list in sharepoint 2013

getDataRowFromCustomListUsingId: function (customListName, id) {

        var scriptbase = hostUrl + "/_layouts/15/";
        $.getScript(scriptbase + 'SP.Runtime.js',
        function () {
            $.getScript(scriptbase + 'SP.js',
           function () {
               $.getScript(scriptbase + 'SP.RequestExecutor.js', getDataById);
           });
        });

        //Read Data From Custom List - Host Web
        function getDataById() {

            var context;
            var factory;
            var appContextSite;
            var mylist;
            var targetListItem;
            context = new SP.ClientContext(appweburl);
            factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
            context.set_webRequestExecutorFactory(factory);
            appContextSite = new SP.AppContextSite(context, hostUrl);
            this.web = appContextSite.get_web();
            mylist = this.web.get_lists().getByTitle(customListName);//Custom List Name          
            targetListItem = mylist.getItemById(id);
            context.load(targetListItem);
            context.executeQueryAsync(

                function () {

                    editsuccess(targetListItem);

                },
                function () {
                    error();
                });
        }
    }

check undefined variable in jquery

var id = decodeURIComponent(getQueryStringParameter("ID"));

    alert(id);
    if (id != 'undefined') {
        alert('success');
    }
    else {
        alert('fail');
    }

Monday, August 11, 2014

Get Peoplepicker content using JSOM in sharepoint 2013

var html = $("#ctl00_PlaceHolderMain_docReviewerUser_upLevelDiv"); params['DocReviewerLoginName'] = $("#divEntityData", html).attr("key");

Sunday, August 10, 2014

Caml query example with Person or Group (By Name) sharepoint 2013

1) Person or Group (By Name)
2) Value Type - Text
<Query>
<Where>
<Eq>

<FieldRef Name=\'Title\'/>'

      '<Value Type=\'Text\'>Shekhar</Value>

</Eq>
</Where>
</Query>

Caml query example withMultiple Lines of Text sharepoint 2013

1) Multiple Lines of Text
2) Value Type - Text
<Query>
<Where>
<Contains>

<FieldRef Name=\'Title\'/>'

      '<Value Type=\'Text\'>Shekhar</Value>

</Contains>
</Where>
</Query>

Caml query example with Single line of text sharepoint 2013

1) Single line of text

Value Type - Text

<Query>
<Where>
<Eq>
<FieldRef Name=\'Title\'/>'
      '<Value Type=\'Text\'>Shekhar</Value>
</Eq>
</Where>

</Query>