The CreatorCon Call for Content is officially open! Get started here.

Getting wrong value for Business Duration field on RITM

raj99918
Tera Contributor

Hi 

 

Getting wrong value for Business Duration field on RITM below is my Business rule:

 

var opened = current.opened_at.getValue();
var closed = current.closed_at.getValue();

        if (current.business_duration.nil())
            current.business_duration = gs.calDateDiff(opened, closed, false); // Business Duration
 
Thanks.
 
3 REPLIES 3

Valmik Patil1
Kilo Sage

Hello @raj99918 ,

Try below script

 

var opened = current.getValue('opened_at');
var closed = current.getValue('closed_at');

        if (current.business_duration.nil())
            current.business_duration = gs.calDateDiff(opened, closed, false); // Business Duration

 

Thanks,

Valmik Patil

Hi @Valmik Patil1  Still no luck please see this screeshot am getting the Business Duration as 0 seconds instaed of 3 minutues

 

raj99918_0-1731324352582.png

 

Hello @raj99918 ,

Can you try as below

var opened = current.opened_at.getDisplayValue();
var closed = current.closed_at.getDisplayValue();

        if (current.business_duration.nil() || current.business_duration.getDisplayValue() == ''){
            current.business_duration = gs.calDateDiff(opened, closed, false); // Business Duration
      }

There could be issue that if condition is not getting satisfied.

Please log the value of if condition to check what exact value it displays

 

Thanks,

Valmik Patil