How to replace text in script include

Milan13
Giga Expert

Hello,

I have catalog client script and script include to which I pass value of date_from field from form and I retrieve this in Script include, however I need to replace the dots in the output with slashes but it just does not work.

Anything I have been doing wrong?

Please see below...

Many thanks,

Milan

 

 

Client script code snippet from GlideAjax:

ga.addParam('sysparm_date_from', g_form.getValue('date_from'));

 

Script Include side:
1.) var date_from = this.getParameter('sysparm_date_from');  - when I view the output it gives me a date in this form: 30.10.2019 11:03:07

2.) var date_from = this.getParameter('sysparm_date_from').replace(/\//g, '.'); - the required output is 30/10/2019 11:03:07  however this gives me 'null' instead when being viewed...

 

6 REPLIES 6

Milan13
Giga Expert

Regarding code in Script Include:

1.) this just works fine - required input is 31.10.2019 as expected

var b = '31/10/2019';

var s = b.replace(/\//g, '.');

2.) 

var date_from = this.getParameter('sysparm_date_from'); - this is a g_form date value being passed from catalog client script to script include

what DOES NOT work is this:

date_from = datetime value of 31/10/2019 hh:mm:ss passed fro client script

var s = date_from .replace(/\//g, '.');

the contents of variable 's' is just null.......even in this case:

 

var s = date_from .toString().replace(/\//g, '.');

Any ideas why?

Appreciate your help,

Milan

 

 

 

 

When you pass the value from catalog client script, try to get the display value, so use g_form.getDisplayValue("date_from") instead of getValue().

Doing this you should already have a string in script include.

 

Maddalena