Set Custom Date Field Value using Business Rule

Muradz1234567
Tera Contributor

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.

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

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.

Muradz1234567
Tera Contributor

I need the format in: 

'EE-MMM-YY'

Muradz1234567
Tera Contributor

I need the date field format to be like "Wed-Jul-23".