Hi team,
I have a ask where i need a javaScript which can check if a list is updated today (modified today) or not, let me know if anyone have any lead on this?
Thanks in advance.
Regards,
Solved! Go to Solution.
Views
Replies
Total Likes
Hello @fgtrrt,
No the list id montioned in script above is really the list identifier (@id attribut of nms:group schema).
Please find bellow an adaptation of the script if you want to use it with internal name of the list:
var nameList = 'changeThisToInternalNameOfYourList';
var list = xtk.queryDef.create(<queryDef schema="nms:group" operation="get">
<select>
<node expr="@id" />
<node expr="@lastModified" />
<node expr="@name" />
<node expr="@label" />
</select>
<where>
<condition expr={"@name = '"+nameList+"'"}/>
</where>
</queryDef>).ExecuteQuery();
var countList = xtk.queryDef.create(<queryDef operation="count" schema={"temp:group:"+list.@id}/>).ExecuteQuery().@count;
var lastModified = parseTimeStamp(list.@lastModified);
var todayMidnight = new Date(getCurrentDate().setHours(00,00,00));
if (lastModified > todayMidnight ){
logInfo('The group '+list.@label+' has been updated today. The count is : '+countList)
}else {
logInfo('The group '+list.@label+' has not been updated today. Last time it has been updated is '+formatDate(lastModified, '%4Y/%2M/%2D') +'. The count is : '+countList)
}
there no scpecific folder where your list should be to use the script. The important thing is that the user who start the script (or the workflow using the script) should have acces to the list.
Br,
Hello @fgtrrt,
Please find bellow an example on how to do it (i've also added how to have the count of the list content).
Let's say the id of your list is 123456 :
var idList = 123456;
var list = xtk.queryDef.create(<queryDef schema="nms:group" operation="get">
<select>
<node expr="@id" />
<node expr="@lastModified" />
<node expr="@name" />
<node expr="@label" />
</select>
<where>
<condition expr={"@id ="+idList}/>
</where>
</queryDef>).ExecuteQuery();
var countList = xtk.queryDef.create(<queryDef operation="count" schema={"temp:group:"+list.@id}/>).ExecuteQuery().@count;
var lastModified = parseTimeStamp(list.@lastModified);
var todayMidnight = new Date(getCurrentDate().setHours(00,00,00));
if (lastModified > todayMidnight ){
logInfo('The group '+list.@label+' has been updated today. The count is : '+countList)
}else {
logInfo('The group '+list.@label+' has not been updated today. Last time it has been updated is '+formatDate(lastModified, '%4Y/%2M/%2D') +'. The count is : '+countList)
}
result when the list has been refreshed today :
result when the list has not been updated today :
Br,
Views
Replies
Total Likes
Hi @Amine_Abedour ,
Can you confirm if the list id mentioned in script is internal name and is there any specific folder where my list should be while using the mentioned script?
Thanks in advance
Regards,
Views
Replies
Total Likes
Views
Replies
Total Likes
Hello @fgtrrt,
No the list id montioned in script above is really the list identifier (@id attribut of nms:group schema).
Please find bellow an adaptation of the script if you want to use it with internal name of the list:
var nameList = 'changeThisToInternalNameOfYourList';
var list = xtk.queryDef.create(<queryDef schema="nms:group" operation="get">
<select>
<node expr="@id" />
<node expr="@lastModified" />
<node expr="@name" />
<node expr="@label" />
</select>
<where>
<condition expr={"@name = '"+nameList+"'"}/>
</where>
</queryDef>).ExecuteQuery();
var countList = xtk.queryDef.create(<queryDef operation="count" schema={"temp:group:"+list.@id}/>).ExecuteQuery().@count;
var lastModified = parseTimeStamp(list.@lastModified);
var todayMidnight = new Date(getCurrentDate().setHours(00,00,00));
if (lastModified > todayMidnight ){
logInfo('The group '+list.@label+' has been updated today. The count is : '+countList)
}else {
logInfo('The group '+list.@label+' has not been updated today. Last time it has been updated is '+formatDate(lastModified, '%4Y/%2M/%2D') +'. The count is : '+countList)
}
there no scpecific folder where your list should be to use the script. The important thing is that the user who start the script (or the workflow using the script) should have acces to the list.
Br,