SCTASK(Service request) needs to be created based on knowledge article expiry date(valid to date)

k_Mounika
Tera Contributor

Hi All,

 

SCTASK(Service request) needs to be created and should be assigned to ownership group based on knowledge article expiry date(valid to date - i.e. If article is going to expiry in next 30 days then we need to create a request) by using schedule job.

 

Thanks in advance

 

3 REPLIES 3

Brian Lancaster
Tera Sage

Use a scheduled job to call CartJS to order the specific catalog item. You can use variables possibly from data in the knowledge base to have the workflow send the task to the correct group.

Eshwar Reddy
Kilo Sage

Hi @k_Mounika 

Please use below script

var daysUntilExpiry = 30;

var now = new GlideDateTime();
var expiryThreshold = new GlideDateTime();
expiryThreshold.addDays(daysUntilExpiry);

var knowledgeGR = new GlideRecord('kb_knowledge');
knowledgeGR.addQuery('valid_to', '<=', expiryThreshold);
knowledgeGR.addQuery('valid_to', '>=', now);
knowledgeGR.query();


while (knowledgeGR.next()) {
 
var sctaskGR = new GlideRecord('sc_task');
sctaskGR.initialize();
sctaskGR.short_description = 'Review Knowledge Article: ' + knowledgeGR.short_description;
sctaskGR.description = 'The knowledge article "' + knowledgeGR.short_description + '" is set to expire on ' + knowledgeGR.valid_to + '. Please review and take necessary action.';
sctaskGR.insert();
}
 

Please mark this response as Correct and Helpful if it helps you can mark more that one reply as accepted solution

Its not best practice to create a catalog task without an associated Request Item. They are not stand alone tasks.