- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2017 01:33 PM
In knowledge in Istabul.
i want to set the Valid To date to default to one year from created. Presently, the default is to set it to 2020. This is done by a dynamic filter list
which looks like this
var d = new GlideDate(); d.setValue('2020-01-01'); d.getDisplayValue();
How could i use a dynamic filter list or some other option to set this field to be a year when article is submitted. Just like it i
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2017 03:51 AM
This is worked
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2017 02:07 PM
You can create business rule to set value of valid_to field.
Please use below sample code to set data time field value.
var end = current.end_date.getGlideObject().getNumericValue();
end += (45*24*60*60*1000);
var gdt = new GlideDateTime();
gdt.setNumericValue(end);
current.due_date.setValue(gdt.getValue());
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2017 02:54 PM
Sachin,
Wouldn't a client script be a better action then? I was trying to play with dynamic filter list but if that's not easy. I will accept either method.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2017 02:59 PM
var datee = new GlideDate();
datee.addMonths(12);
var nxt = datee.getDate();
gs.print(nxt);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2017 04:14 PM
use the script provided by @deepak in default value of valid to field