• Mandy Rawat
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Need help in converting a javaScript Button into lightning component button.
There is a JavaScript button, which I need to convert into lightning component button.
{!REQUIRESCRIPT("/xdomain/xdomain.js")} 
{!REQUIRESCRIPT("/support/console/37.0/integration.js")} 
{!REQUIRESCRIPT("/apex/VFPage1")} 
VFPage1.showLoadingIndicator();
VFPage1.initRequest("../apex/VFPage2?accId={!Account.Id}&guid={!Account.customfield__c}",'StringValue', function(message) { alert(message); },"../{!Account.Id}");
 
VFPage1 page   contentType="text/javascript" has custom javaScript functions in it
( showLoadingIndicator(), initRequest() etc...)
 
 VFPage2  is communicating with Apex Class Controller methods. None of the controller methods are Static.
One of the method is calling the inhouse webservice  using
Continuation con = new Continuation(InhouseService.WebserviceCalloutTimeout);
I have to create a report based on Users' activity. I need to calculate the total number of business days a user has an activity.
Some times user is on leave and he didn't logged in between a month. I want to calculate
 Total business days User worked in a month = Total number of business days in a month  -  Total days the User didn't work.
I created a formula to change the lead created date into a working business hour i.e., 7:00 am to 4:00 pm. 
Lead Created system date             -->     Formula updated date
The formula field  Lead_In_Business_Hours__c is returning Date/Time value.

CASE(MOD( Lead_Created__c - DATE( 1900, 1, 8 ), 7 ), 
4, 
IF(AND ( 
TIMEVALUE(Created_Date_Time__c) >= TIMEVALUE('07:00:00.000'), 
TIMEVALUE(Created_Date_Time__c) < TIMEVALUE('14:00:00.000') 
), 
DATETIMEVALUE(TEXT(Lead_Created__c) & ' 14:00:00'), 
IF( OR (TIMEVALUE(Created_Date_Time__c) > TIMEVALUE('23:00:00.000'), 
AND(TIMEVALUE(Created_Date_Time__c) > TIMEVALUE('00:00:00.000'), 
TIMEVALUE(Created_Date_Time__c) < TIMEVALUE('07:00:00.000')) 
), 
DATETIMEVALUE(TEXT(Lead_Created__c + 3) & ' 14:00:00'), 
Created_Date_Time__c 

), 
5, DATETIMEVALUE(TEXT(Lead_Created__c + 2) & ' 14:00:00'), 
6, DATETIMEVALUE(TEXT(Lead_Created__c + 1) & ' 14:00:00'), 
IF(AND ( 
TIMEVALUE(Created_Date_Time__c) >= TIMEVALUE('07:00:00.000'), 
TIMEVALUE(Created_Date_Time__c) < TIMEVALUE('14:00:00.000') 
), 
DATETIMEVALUE(TEXT(Lead_Created__c) & ' 14:00:00'), 
IF(OR (TIMEVALUE(Created_Date_Time__c) > TIMEVALUE('23:00:00.000'), 
AND(TIMEVALUE(Created_Date_Time__c) > TIMEVALUE('00:00:00.000'), 
TIMEVALUE(Created_Date_Time__c) < TIMEVALUE('07:00:00.000')) 

), 
DATETIMEVALUE(TEXT(Lead_Created__c + 1) & ' 14:00:00'), 
Created_Date_Time__c 


)


This formula is working fine. Lead_Created__c is returning the DATEVALUE(Created_Date_Time__c)
Created_Date_Time__c is also a formula field returning CreatedDate.

I created another formula  FirstCallSinceLeadCreated__c to return the text value which  calculates the days,hours and minutes in between the lead created (in business hours)and the first call made to the lead.
FirstTaskDateTime__c stores Date/time of the first call made to a lead. It can be in non business hours.


IF(FirstTaskDateTime__c - Lead_In_Business_Hours__c > 0, 
TEXT(
FLOOR(FirstTaskDateTime__c -  Lead_In_Business_Hours__c)
) & " Day(s) " &
TEXT(
ROUND(MOD((FirstTaskDateTime__c  - Lead_In_Business_Hours__c )*24,24),0)
) &" Hour(s) " &
TEXT(
ROUND(MOD((FirstTaskDateTime__c  - Lead_In_Business_Hours__c )*1440,60),0)
) &" Minute(s) ", 
   IF((FirstTaskDateTime__c-Lead_In_Business_Hours__c)<0,
    TEXT(
          FLOOR(FirstTaskDateTime__c -  Lead_In_Business_Hours__c)) & " Day(s) " &
    TEXT(
         Floor(MOD((FirstTaskDateTime__c - Lead_In_Business_Hours__c) *24,24))) &" Hour(s) " &
     TEXT(
        ROUND(MOD((FirstTaskDateTime__c - Lead_In_Business_Hours__c)*1440,60),0)
        ) &" Minute(s) ",""
)
)

**This formula gives me an error Error: Compiled formula is too big to execute (12,493 characters). Maximum size is 5,000 characters
The same formula is working in workflow to update the field. But I want it through a formula field only. I tried breaking the formula and storing it to different fields but still getting the same error infact the characters are increasing.
Thanks in advance. 
I have to create a report based on Users' activity. I need to calculate the total number of business days a user has an activity.
Some times user is on leave and he didn't logged in between a month. I want to calculate
 Total business days User worked in a month = Total number of business days in a month  -  Total days the User didn't work.