Declare expression is not giving result as expected.
Hi,
I have written a declare expression to calculate age based on customer's Date Of Birth. But I am getting some default value even without entering some DOB value. After entering the some value in DOB field then it returns correct value as expected. Kindly help me out.
My declare expression is @DateTime.DateTimeDifference(.DateOfBirth+"T000000.000 GMT",@(Pega-RULES:DateTime).CurrentDateTime(),"Y")
and default value it's showing is -2.147483648E9.
-
Like (0)
-
Accepted Solution

@DeepakM60 Have you tried with an IF ? Can you rewrite your declare expression to calculate the value only if DateOfBirth has value?
Something similar

@BhanuPrakash_G I haven't tried with IF. I will try and see
Thanks for your reply!

@BhanuPrakash_G Hi,
I tried it with "If and Otherwise" condition and It worked. At run time, when I change DOB value age value is not changing still it shows "zero" because I gave age value equals to "zero" in otherwise condition.
While storing into data base, value is getting stored as expected.
Kindly provide me the solution.
Regards,
M.Deepak
@DeepakM60 Hi Deepak Can you please try using post value on change of date in your Section that would solve your issue
@SrinidhiM I tried but it is not working and age field value is not updating in view at run time. Please look into below picture and let me know if there is any mistake.
@DeepakM60 Hi, Can you try refresh section instead of post value and see if you are seeing the values
@SrinidhiM Hi mam,
It's worked. Thank you so much for your valuable suggestions. Could you please explain what display:refresh does?
@DeepakM60 Hi Deepak,
The refresh section is similar to reload, it just refreshes the current state of the section which would help in displaying the latest data from clipboard.

Please use this expression @whatComesBeforeFirst((.CurrentDate-.DOB)/365,'.')
For your reference, please find attached document.
Thanks

@Sai Guggilla Hi,
I will try this way and check if it is worked or not. Anyway thanks for your suggestion.
Regards,
M.Deepak
Hello @DeepakM60
Try enabling the Legacy from actions and after changing it to legacy expression change the Calculate Value to whenever Input Changes Or whenEver used from Change tracking Tab .Hope this may help