have to fetch the articles which is going to retire in one month based on valid to field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Articles from Knowledge table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @priyanka Ganta ,
I tried your problem in my PDI and it works for me please check below script
var now = new GlideDateTime();
var oneMonthAhead = new GlideDateTime();
oneMonthAhead.addMonthsUTC(1);
var targetDate = oneMonthAhead.getLocalDate().toString(); // YYYY-MM-DD
gs.print("targetDate = " + targetDate);
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('valid_to', 'ON', targetDate);
gr.query();
while (gr.next()) {
gs.print(gr.number + ' - ' + gr.short_description + ' (Valid To: ' + gr.valid_to + ')');
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago - last edited an hour ago
Hello @priyanka Ganta ,
Please use the below code to do so:
var today = new GlideDate();
var addOneMonth = new GlideDate(today);
addOneMonth.addMonthsUTC(1); // adding 1 month
var knowledge = new GlideRecord('kb_knowledge');
knowledge.addQuery('valid_to', addOneMonth);
knowledge.query();
while (knowledge.next()) {
gs.print(knowledge.number + ' will expire in 1 month');
}If this answer helped you, please accept it as solution and mark it helpful. Thank you.
*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
