JavaScript for list update
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,
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,
Hello @rch_,
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,
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.