Knowledge - calculating 'valid to' date

10382
Kilo Contributor

Hello,

I am beginning to look at business requirements for Knowledge, and one of the requirements is that the "valid to" date be calculated to 1 year (365 days), based on the "published date".

Is anyone doing something like this?

Are there reasons you wouldn't want to do this?

Does anyone have a java script that is doing this now, and would be willing to share with me?

Thank you!

Julie

12 REPLIES 12

10382
Kilo Contributor

Thank you for this information, I appreciate everyone's help!


Troy S_
Kilo Expert

Julie,


        This is a road map of what we did, not perfect but a decent start:



  1. Assign Knowledge role to itil users
  2. Create the following:
    1. Topic
    2. Categories (for each topic)
  3. Knowledge Properties
    1. List of Roles that   (comma-separated) that can see user comments on an article:
      1. itil,knowledge,knowledge_admin
  4. Create Knowledge Workflow for article approval
    1. Goes to approver
      1. Approver—approves and the article is published and an email is sent telling them that article was published
      2. Approver—rejects and is set back to draft stage and an email sent telling them that they need to rework the article.
  5. Modify the Knowledge Valid to
    1. Set for 6 months out from the current date
      1. Users can change this, changed depending on what type documentation
  6. Creates a scheduled job that creates an event called
    1. article.expriing.5days
      1. doit();

                                            function doit() {


                                            var gr = new GlideRecord('kb_knowledge');


                                            gr.addQuery("valid_to", "<", gs.daysAgoStart(-5));


                                            gr.addQuery("valid_to", ">", gs.now());


                                          gr.query();


                              while (gr.next())


                                      gs.eventQueue("article.expiring.5days", gr, "", "");


                          }


    7.   Created an Event


                  1.   Article expiring in 5 days


    8. Created an Email Notification


                  1.   Email Notification fired off the Article Expiring in 5 Days event


    9. Create a scheduled job to retire articles


                    1.   Create a scheduled that runs every day at 6pm


zica
Giga Guru

Hi everyone,




Sorry for coming late. You might already have your answer, but this post will help any person who wants to do the same thing


Please follow the steps below in order to set up the date "Valid to' to 12 months on from the published date :


1. Right click on the 'Valid Field'


2. Click on personalize Dictionnary


3. On default Value tabs, write the script below (ensure that the 'Use dynamic default is unchecked) :


                  javascript: var dat = new GlideDate(); dat.setValue(gs.monthsAgo(-12));  


                  dat.getDisplayValue();  


4. Save



You can find further informations into this wiki : http://wiki.servicenow.com/index.php?title=GlideDateTime#addMonths.28int.29




Do not feel shy to put correct or helpful answer If it solves or helps. You can also like the post




Kind Regards,


ZA