Duration calculation gives NULL value from the script include (scoped app)

arnabwa
Giga Guru

Hi Snow Enthusiasts,

I'm trying to calculate difference between two dates viz. planned_start and planned_end. This difference I need to out in the duration field on the same form.

Pretty common I know. Very common as their are ample scripts as OOB and in community as well. The problem with me is I'm working in a completely scoped environment and not sure if I'm doing everything correct. So the process is :

Issue : final variable gives NULL value.

1. An onChange client script on Planned End Date (planned_end)

2. CS code :

              Capture1.PNG

Commented lines will give you an idea what are other variations I have tried.

2. Common Script Include (scoped environment) :

                  Capture2.PNG

Again commented lines will give you what are the other variations I tried here.

The "ans2" variable in the client script gives me a NULL value.

Please guide me to enlightenment.

Thanks,

Arnab

1 ACCEPTED SOLUTION

arnabwa
Giga Guru

Hi All,



I could figure out what was actually resulting the output to be NULL.


Since I'm working on a scoped app as I had mentioned, the gs.dateDiff() function does not work in the scoped environment. The AJAX call is directed to a script include which too was in the scoped environment. Hence the difference of the dates were not calculated and NULL was the output.



What I did to resolve :


From the scoped script include I called a another Script Include in the GLOBAL scope and it was there I used the gs.dateDiff() to calculate the difference and return the result to the script include in scoped environment. Now I was able to get the required value and set it in the Duration field in the client script on the desired form.


Thanks to all of you. Ever Helping guys.



On this context if I can make a request of a link or a document which mentions all the functions and classes that are not available in a private scope.



Thanks,


Arnab


View solution in original post

8 REPLIES 8

adityaghosh
Tera Guru

modify line 15 as gta.addParam('sysparam_planned_start', startDate.getDisplayValue());


modify line 16 as gta.addParam('sysparam_planned_end', endDate.getDisplayValue());




also make sure the script include is client callable (i.e. its checked)


Hi Shiladitya Ghosh,



Thanks for your reply.



When I add the function in the CS, it gives me an error in the form :


Object does not support the property or method getDisplayValue function() {[native code]}



Please let me know what can be done further.



Thanks,


Arnab


Also we cannot use getDisplayValue() function in a client side code. It is a server side function.


Mihir Mohanta
Kilo Sage

Please check "Accesible from" field value is All application scopes or not in the script include you have written.



find_real_file.png