- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2016 08:17 AM
Hello Experts,
I have a really Urgent requirement. I have two drop down fields on my Custom Table, Creation Month and Implementation Month - Both have values from January to December.
I have couple of requirements:
1. The Creation Month will be populated based on month when I submit a record for that table. Say I submit today ; Creation Month = August
2. There is a field called implementation date on my Form. Once I select the date, the Implementation Month will auto-populate in accordance. So, basically
if say implementation date is : 2016 - 10 - 10
then Implementation Month = October
Can anyone tell me how to do it OR better provide a sample code for this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2016 08:59 AM
Hi Arnab
First check the values of Creation Month and Implementation Month choice values and give the values 1 to 12 respectively from jan to dec
then write onAfter business rule.
var cMonth = new GlideDateTime(current.creationdate);
current.creationMonth = cMonth.getMonth();
var iMonth = new GlideDateTime(current.creationdate);
current.ImpMonth = iMonth.getMonth();
current.update();
Thanjs
Adi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2016 10:03 AM
It should be a Before business rule, and shouldn't use current.update().

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2016 10:07 AM
It should be a before business rule and you only need 1 business rule
On Friday, August 26, 2016, AEBongiovanni <community-no-reply@servicenow.com>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2016 10:44 AM
It should be a before business rule and you only need 1 business rule
On Friday, August 26, 2016, AEBongiovanni <community-no-reply@servicenow.com>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2016 09:31 AM
What you can do is, make your choice list values as 1,2,...12. Now in your before business rule use this to set the choice field
var gdt = new GlideDateTime();
current.<creation month field name>=gdt.getMonthLocalTime();
var gdt1 = new GlideDateTime();
gdt1.setValue(current.<implementation date field>);
current.<implementation month>=gdt1.getMonthLocalTime();