I am looking for a solution :
Only for if condition to read first row's modified date and compare it current date [ ex today =21/01/2016 ]
condition :
if [ first row's Modified date == current date (Today)]
{
I have to do nothing
}
else
{
I will run my existing javascript to update all items
}
Javascript :
var clientContext = null;
var globalCount = 0;
var itemCountList = 0;
var curentDate = new Date();
var globalCount = 0;
var itemCountList = 0;
var curentDate = new Date();
function uploadDest(){
clientContext = new SP.ClientContext("");
oList = clientContext.get_web().get_lists().getByTitle("");
camlQuery1 = new SP.CamlQuery();
query1 =' ';
camlQuery1.set_viewXml(query1);
clientContext = new SP.ClientContext("");
oList = clientContext.get_web().get_lists().getByTitle("");
camlQuery1 = new SP.CamlQuery();
query1 ='
camlQuery1.set_viewXml(query1);
this.collListItems1 = oList.getItems(camlQuery1);
clientContext.load(collListItems1);
clientContext.load(collListItems1);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onMultiSelectListDataLoadQuerySucceeded1), Function.createDelegate(this, this.onMultiSelectListDataLoadQueryFailed));
}
function onMultiSelectListDataLoadQuerySucceeded1(sender, args){
listItemEnumerator1 = collListItems1.getEnumerator();
itemCountList = collListItems1.get_count();
while (listItemEnumerator1.moveNext()) {
oListItem1 = listItemEnumerator1.get_current();
oListItem1.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
listItemEnumerator1 = collListItems1.getEnumerator();
itemCountList = collListItems1.get_count();
while (listItemEnumerator1.moveNext()) {
oListItem1 = listItemEnumerator1.get_current();
oListItem1.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
}
function onMultiSelectListDataLoadQueryFailed(){
alert("error occured");
}
alert("error occured");
}
function onQuerySucceeded() {
globalCount = globalCount + 1;
console.log("success / "+ globalCount + "/" + itemCountList);
if(globalCount==itemCountList){
localStorage.setItem("code","1");
window.location = document.location.href;
location.reload();
}
}
globalCount = globalCount + 1;
console.log("success / "+ globalCount + "/" + itemCountList);
if(globalCount==itemCountList){
localStorage.setItem("code","1");
window.location = document.location.href;
location.reload();
}
}
function onQueryFailed(sender, args) {
console.log("error");
}
console.log("error");
}
if(localStorage.getItem("code") === null){
ExecuteOrDelayUntilScriptLoaded(function(){
var div = document.getElementById("WebPartWPQ2");
div.style.opacity = 0;
uploadDest();
},"sp.js");
var div = document.getElementById("WebPartWPQ2");
div.style.opacity = 0;
uploadDest();
},"sp.js");
}else{
localStorage.removeItem("code");
}
localStorage.removeItem("code");
}
}
5 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Payal BanerjeePosted Jan 22, 2016, 5:06 AM
Payal BanerjeePosted Jan 22, 2016, 5:06 AM
Payal BanerjeePosted Jan 22, 2016, 5:06 AM
Payal BanerjeePosted Jan 22, 2016, 5:04 AM
itemCountList = collListItems1.get_count();
while (listItemEnumerator1.moveNext()) {
oListItem1 = listItemEnumerator1.get_current();
oListItem1.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
Raja TPosted Jan 21, 2016, 4:30 AM
http://stackoverflow.com/questions/7335075/compare-2-dates-in-format-dd-mm-yyyy-with-javascript-jquery
https://bytes.com/topic/javascript/answers/485296-dd-mm-yyyy-date-compare-problem
http://forums.asp.net/t/1096556.aspx