Set Custom Date Field Value using Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2023 02:58 AM
Hi I have a made an attempt to create a custom date field (u_glide_date_1) using business rule (before insert/update) but returns nothing on the incident form. This is my code :
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gdt = new GlideDateTime();
var tdg = gdt.getDate();
tdg = tdg.getByFormat('EE-MMM-YY');
current.u_glide_date_1 = tdg.getDisplayValue();
})(current, previous);
Can someone help me and where I am going wrong in this code. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2023 05:49 AM
Have you tried just:
var gdt = new GlideDateTime();
current.u_glide_date_1 = gdt.getDate();
You can run a similar rule on Display, then add some gs.addInfoMessage lines to see the values at each step, but if you're populating a field before/when the record is created display/format shouldn't matter as gdt will be in the system format, and will populate the same in the custom field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2023 05:57 AM
I need the format in:
'EE-MMM-YY'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2023 06:03 AM
I need the date field format to be like "Wed-Jul-23".