Tuesday, May 9, 2017

Quick Hacks - Access Urls of Nintex Workflows

See All Nintext workflows along with versions  :- 

YourSiteUrl/Lists/NintexWorkflowHistory/AllItems.aspx


See All Nintext workflows history list :-

YourSiteUrl/NintexWorkflows/Forms/AllItems.aspx 

"Sharepoint Error: Save Conflict Your changes conflict with those made concurrently by another user" - What it actually means??

Save Conflict
Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes.
This happens whenever you try to save a SPListItem which has been modified since you opened it. So, it's mandatory to refresh the page for fetching the latest saved data and then edit it. Review your code to ensure that you don’t open the same list item multiple times, work with a single SPListItem object instead.
You can think of it in the same way as you use say :-
TFS server and you are trying to save some item you have opened which is not the latest version and thus you will be popped up witha message saying, "This is not the latest version of the file you are editing, Get the latest version of the file before editing."

Tuesday, April 11, 2017

Change the "Source" redirection of SharePoint New and Edit forms on Save and Cancel

On document.ready put this code:-

    var button = $("input[id$=SaveItem]");
    // change redirection behavior
    button.removeAttr("onclick");
    button.click(function() {
        var elementName = $(this).attr("name");
        var aspForm = $("form[id=aspnetForm]");
        var oldPostbackUrl = aspForm.get(0).action;
        var currentSourceValue = GetUrlKeyValue("Source", true, oldPostbackUrl);
        var newPostbackUrl = oldPostbackUrl.replace(currentSourceValue, "https%3A%2F%2Fint%2Eapac%2Esp%2Ewp%2Ecorpintra%2Enet%2Fsites%2F04400%2FDashboard%2520UAT%2FSitePages%2FProjects%2Easpx");

        if (!PreSaveItem()) return false;
        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", newPostbackUrl, false, true));

    });

Monday, April 10, 2017

2 level Cascading Lookup using SP Services

Pre-requisites :

  • JQuery Reference
  • SP Services Reference
Code :


<script type="text/javascript" src="../../SiteAssets/Scripts/jquery.2.1.3.min.js"></script>
<script type="text/javascript" src="../../SiteAssets/Scripts/jquery.SPServices-2014.02.js"></script>  
<script type="text/javascript">  
$(document).ready(function ()  
{  
$().SPServices.SPCascadeDropdowns({
  relationshipWebURL: "",
  relationshipList: "StateList",
  relationshipListParentColumn: "LookupCountry",
  relationshipListChildColumn: "State",
  parentColumn: "LookupCountryParent",
  childColumn: "LookupStateParent",
  debug: false
});
$().SPServices.SPCascadeDropdowns({
  relationshipWebURL: "",
  relationshipList: "CityList",
  relationshipListParentColumn: "LookupState",
  relationshipListChildColumn: "City",
  parentColumn: "LookupStateParent",
  childColumn: "LookupCityParent",
  debug: false
});

});
</script>

Explanations:-

  1. relationshipList - The list which has parent/child relationship.
  2. relationshipListParentColumn - The lookup column in relationshipList.
  3. relationshipListChildColumn - The column which is dependent on relationshipListParentColumn.
  4. parentColumn - The lookup column in parent list/master.
  5. childColumn - The lookup column in parent list/master list.
Analogy:-

CountryList

Title

India
UK
US

StateList

State LookupCountry

MP              India
Karnataka   India


CityList

City             LookupState

Bangalore    Karnataka
Ujjain          MP

ParentList - This is the list where I want cascading lookups i.e. on change of Country respective State should come, and further city should load for respective states.

Title      LookupCountryParent     LookupStateParent     LookupCityParent

New      India                                    Karnataka                      Bangalore

Wednesday, March 15, 2017

Use keyboard "Enter" to function same as the custom button.

$(document).on("keypress","#txtParam",function (e) {
// Keypress event of the textbox

 var key = e.which;
 if(key == 13)  // the enter key code
  {
    $("input[id ='btnSearch']").click(); // simulates the function of "btnSearch"  button on ENTER.
    return false;
  }
});

Monday, March 13, 2017

Move a SharePoint List Item to another List using SPD 2013 Workflow

The option to move the list item directly was present in SPD 2010 workflows. But in SPD 2013 workflow, we need to  -

1) Create Item in new list with referencing the same column in the current item as shown in the screenshot below.
2) Delete current item.






Calculate days difference between 2 dates sharepoint + JQuery

// This function calculates the difference between the Date field of SharePoint and the current Date.
function calculateDays()
{
var myDate =  $('input[title="Date"]').val();
var chunks = myDate.split('/');
var formattedDate = new Date([chunks[1],chunks[0],chunks[2]].join("/"));
var currDate = new Date(new Date().getTime());
console.log( Math.floor((currDate-formattedDate)/(1000*60*60*24)));
return Math.floor((currDate-formattedDate)/(1000*60*60*24));
}

Clearing Person/Group Values

To clear out or empty the values in person or group columns, how you do it depends on if the column is single-value or multi-value. For ...