- 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 08:42 AM
OK - so your custom table should be using a choice list for Creation Month and Implementation Month. You would set the Labels of these choices to be the English-language month names as you have now, but set the Values to be the numbers 1-12.
That way you can use GlideDateTime.getMonthLocalTime() to get a number. Since Creation Month will default to when the record is submitted, you can have the default value be "javascript:var gdt = new GlideDateTime();gdt.getMonthLocalTime();"
You can do the same thing in a business rule as well, and should do so for Implementation Month. It would be a Before business rule when the field "Implementation Date" changes. The business rule script would be something like "current.u_implementation_month = (new GlideDateTime(current.u_implementation_date)).getMonthLocalTime();"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2019 09:20 AM
Thank you.
- 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 09:59 AM
Thanks everyone, did both by BRs...
Working great, but the system performance seems to have taken a beating...