addDateLocalTime

jon_becker
Kilo Expert

I'm new at the scripting world, so please forgive any simple mistakes. I'm struggling with a server script include that will dynamically add a number of days to a field using addDaysLocalTime. It is called fine from my client script. It reads the record fine and returns the exp_days variable, but...

On the gdt.addDaysLocalTime(exp_days), it works fine if I hard code a value like 14, but doesn't return anything if I use the variable. Thoughts? I've looked at this too long and could use a fresh set of eyes. Thanks!

Best,

Jon Becker

var MyDateTimeAjax = Class.create();

MyDateTimeAjax.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

  nowDateTime: function () {

  var sysID = this.getParameter('sysparm_sysID');

  var gr = new GlideRecord('x_69046_lms_lmscatalog');

  gr.get(sysID);

  var exp_days = gr.expriation_days;

  gs.info(exp_days);

  var gdt = new GlideDateTime();

  gdt.addDaysLocalTime(exp_days);

  gs.info(gdt.getLocalDate());

  return gdt.getLocalDate();

  },

  type: 'MyDateTimeAjax'

});

1 ACCEPTED SOLUTION

nthumma
Giga Guru

Can you try this var exp_days = gr.getValue('expriation_days'); instead of var exp_days = gr.expriation_days;


View solution in original post

2 REPLIES 2

nthumma
Giga Guru

Can you try this var exp_days = gr.getValue('expriation_days'); instead of var exp_days = gr.expriation_days;


jon_becker
Kilo Expert

Thanks! It works perfectly! It makes sense now I see the new line.


I appreciate it.