Posts

Adding Validation to a Custom NewForm.aspx in SharePoint & Redirect

SharePoint has a built in function called "PreSaveAction" that can be invoked to process anything before the form should submit. So now we will create a submit button which calls “PresaveActon” function. Once users Submits the form, PreSaveAction is executed. If PreSaveAction is returns true it will commit and redirect. If the PreSaveAction returns false, then the commit will not happen nor the redirect. Input Button Code: Replace this code <SharePoint:SaveButton runat="server" ControlMode="New" id="savebutton1"/> with <input type="button" value="Submit" name="btnSave" onclick="javascript: if(PreSaveAction()) {ddwrt:GenFireServerEvent('__commit;__redirect={http://<Site>/ SitePages/ThankYou.aspx}')}" /> Add Script in NewCustom Form. Now edit New custom newform.aspx and add content editor webpart and with below script <script type="text/javascript

show append changes to existing multiline textbox in Custom Edit/Display form

To show append changes to existing multiline textbox, use below code: <SharePoint:AppendOnlyHistory runat="server" FieldName="multiple field" ControlMode="Display" ItemId="{@ID}"/> How to Add: 1. in custom display form Try to create a new custom display form in Designer, select the multiple field, then go to code, tries to use the above code to replace <xsl:select value-of="@multiple field" /> 2. In custom edit form Try to create a new custom edit form in Designer, select the multiple field, then go to code, try to use the above code to replace      <SharePoint:FieldDescription runat="server" id="ffndescription{$Pos}" FieldName="mul" ControlMode="Edit"/>

Export and Import SharePoint Designer List Workflow

Exporting and importing of the List Workflow to and from another list or site is actually a non-supported feature. However, there is a "workaround" to achieve this.  In SharePoint Designer 2010, click on your completed List Workflow. Click on "Save" and "Publish" for the completed List Workflow. Next, click on "Export to Visio". Save the file as CompletedWorkflow.vwi or any preferred name. Then create a new "similar" list on the current site or on a new site collection. There is no way to import the exported visio into this new list. In SharePoint Designer 2010, click on this new list and then click on "List Workflow" to create a new workflow for this new list. Please make sure that you do not add any workflow steps! Click on "Save" and "Publish" for this empty List Workflow. Then, click on "Export to Visio" and save this as EmptyWorkflow.vwi or any preferred name. Rename both the

InfoPath form Contact selector

 The Contact Selector consists of 3 data nodes: DisplayName AccountId AccountType Each is just a text field.  When you publish your form, you have the option of promoting one or all of the fields. DisplayName only contains the PreferredName attribute of the User Profile Database, which is typically in the form of LastName, FirstName, but it depends on your AD setup. AccountId is the most valuable field, because it contains the user's domain name in the form of domain\username (i.e. microsoft\userId).  If you promote this field to SharePoint, then this value is immediately usable for sending workflow emails in SharePoint Designer.  I do this all the time.  Also, that value can have the domain portion stripped out and be used to query the GetUserProfileByName web method to retrieve the selected user's profile info, including Email Address, Manager, Department, and many other attributes stored in the profile database. Since these are text fields, they do not match

ECMA Script : To get current logged in user information from User Profile Service Application

ECMA Script to get current logged in user information from User Profile Service Application using "SP.UserProfiles" script files. <!--script src="/_layouts/15/Scripts/MicrosoftAjax.js" type="text/javascript"></script--> <!--script src="/_layouts/15/init.js" type="text/javascript"></script--> <script src="/_layouts/15/sp.runtime.js" type="text/javascript"></script> <script src="/_layouts/15/sp.js" type="text/javascript"></script> <script src="/_layouts/15/SP.UserProfiles.js" type="text/javascript"></script> <script type="text/javascript">     //$(document).ready(function(){         SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js');     //});     var userProfileProperties;     function getUserProperties() {         var clientContext = new SP.ClientConte

ECMA Script : To Add current logged in user to SharePoint group 2013/ 2010

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/ecmascript"> ExecuteOrDelayUntilScriptLoaded(init,'sp.js'); var currentUser; var currentUserName; var currentUserEmail; var currentUserLogin; var siteUrl = '/'; function init(){     var clientContext = new SP.ClientContext.get_current();     var oWeb= clientContext.get_web();           currentUser = oWeb.get_currentUser();     clientContext.load(currentUser);     clientContext.executeQueryAsync(Function.createDelegate(this,this.onQueryUNSucceeded), Function.createDelegate(this,this.onQueryUNFailed)); } function onQueryUNSucceeded() {   currentUserName = currentUser.get_title(); currentUserLogin= currentUser.get_loginName(); currentUserEmail= currentUser.get_email(); document.getElementById('txtUserName').innerHTML =  currentUserName; document.getElementById('txtloginName').innerHTML =  currentUserLogin; document.ge