Welcome to Portal

?Unknown\pull-down

Welcome to Zoho Cares

Bienvenido a Soporte de Zoho

Search our knowledge base, ask the community or submit a request.

STEP 1. FIND TIME GAP using `timeBetween`

  1. startTime = zoho.currenttime.subHour(2).subMinutes(24).subSeconds(4);
  2. endTime = zoho.currenttime;
  3. timeGap = startTime.timeBetween(endTime);

STEP 2: Structure Time String for Time Field

There's an issue with the time_gap function. It only returns a value when there's a difference between the compared times. If there's no difference, the function returns nothing.

To address this, we can loop through a range of three values (0 to 2) and replace any empty responses with "00".
  1. timeList = timeGap.toList(":");
  2. finalTime = "";
  3. loopArr = [0,1,2];
  4. for each i in loopArr {
  5. scaleTime = (if(timeList.size() > i,timeList.get(i), "00").toString().leftPad(2)).replaceAll(" ", "0");
  6. finalTime = finalTime +":"+ scaleTime;
  7. }
  8. info finalTime.removeFirstOccurence(":");
You can use finalTime variable to assign in Time field.

Coding is fun :) Have a great day!

2 users have this problem.
1 Reply
Reply

This looks cool. Good informative post.

Seems you have added it in a problem.

I suppose this can cone under discussion or idea

Reply to AshsubA
/* */
  • 12
  • Insert
  • Plain text
Add Comment
(Up to 20 MB )