• CommaSpace
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
Hello! I'm trying to use an apex trigger to update the starttime of an event.  I have a visualflow intake form that creates an event on a future date based on the information provided. The event is created in GMT and after scouring the interwebs and piecing code/ideas together I think I am making progress, but now I'm getting an error Line 20: Variable does not exist: time.
Would greatly appreciate if you'd take a look and provide input/assistance. 
Best,
Ruth
 
trigger FindTime on Event (before insert) {
//If type is "call" Pull event startdatetime
//Pull month from startdatetime

//Event Months during daylight savings add 6hrs
//Event Month after daylight savings add 5 hrs
//Event Months before daylight savings add 5 hrs

//Event Month of March, check which week event date falls in and add 6 hrs if in or after the 3rd week of the month; otherwise add 5hrs.
//Event Month of November, check which week event date falls in and add 5 hrs if in or after the 2rd week of the month; otherwise add 6hrs.


//Setting up trigger info
    Public Date mydate{get;set;}
    Public Time mytime{get;set;}
    for (Event id: trigger.new){
        if(id.type =='Call'){
            DateTime dT = id.startdatetime;
            myDate = date.newinstance(dT.year(), dT.month(), dT.day());
            mytime = time.newinstance(dT.hour(), dT.minute(), dT.second());
            Integer WeekOfMonth = Math.ceil((Double)(id.startdatetime().Day()) / 7).intValue();               

//if Month is greater than 3 and less than 11
            If(dt.month() >3){
                IF(dt.month()<11){
                    dt.addHours(6);
                }
                //following code is if month = 12 (because the 2nd if above returned false)
                dt.addHours(5);
                // following code is when the first IF returns false
                dt.addhours(5);
            } //closing bracket on first set of if's

//starting IF set for dates in March
            else If (dt.month = 3){
                If(weekofmonth >= 3){
                    //if week of month is greater than or equal to 3 (meaning into the 3rd week, meaning after the 2nd weekend) then DST is in effect; add 6 hrs
                    dt.addHours(6);
                    dt.addHours(5);
                    
                }}
//starting Else set for dates in November
            Else //last option is for event to be in november
                If (weekofmonth >= 2){
                 //meaning it's in the 2nd week or after the first weekend
                 dt.addHours(5);
                 dt.addHours(6);
                }}}}

 
I've created a customer intake form for internal use and need some help determining the best way to create a lead record (which will immediately be converted to account/contact/opportunity thanks to that awesome plugin I found in help)
All of my detail fields pull data from the first input screen, and I don't know how to get only the selected decision branch into the record create.  I also don't fully understand Collection Variables, sObject Variables, or sObject Collection Variables (despite going through the trailhead) but I feel like the solution is along that route?  All I can figure right now is propulating fields using a whole bunch of IF() formulas but I think there has to be a stronger, more efficient way.  Guidance please? Many thanks! 

Image depicting my cloud flow design for customer intake
Hi All, First of all, thank you in advance! I'm having trouble sorting out why my formula inside flow designer isn't working.  I have a lead input screen that creates a record, with an IF formula on company name that if left blank use last name + " Household" for the company name.  I swear the formula worked yesterday, but today I am boggled!  Interestingly I don't get errors if a company name is input on the lead input screen.  Please let me know your thoughts or if you need additional information.  

if(
isblank ({!WebCompany_Organization}),
{!WebLast_Name}&" Household",
{!WebCompany_Organization}
)

Many thanks! Ruth
Hello! I'm trying to use an apex trigger to update the starttime of an event.  I have a visualflow intake form that creates an event on a future date based on the information provided. The event is created in GMT and after scouring the interwebs and piecing code/ideas together I think I am making progress, but now I'm getting an error Line 20: Variable does not exist: time.
Would greatly appreciate if you'd take a look and provide input/assistance. 
Best,
Ruth
 
trigger FindTime on Event (before insert) {
//If type is "call" Pull event startdatetime
//Pull month from startdatetime

//Event Months during daylight savings add 6hrs
//Event Month after daylight savings add 5 hrs
//Event Months before daylight savings add 5 hrs

//Event Month of March, check which week event date falls in and add 6 hrs if in or after the 3rd week of the month; otherwise add 5hrs.
//Event Month of November, check which week event date falls in and add 5 hrs if in or after the 2rd week of the month; otherwise add 6hrs.


//Setting up trigger info
    Public Date mydate{get;set;}
    Public Time mytime{get;set;}
    for (Event id: trigger.new){
        if(id.type =='Call'){
            DateTime dT = id.startdatetime;
            myDate = date.newinstance(dT.year(), dT.month(), dT.day());
            mytime = time.newinstance(dT.hour(), dT.minute(), dT.second());
            Integer WeekOfMonth = Math.ceil((Double)(id.startdatetime().Day()) / 7).intValue();               

//if Month is greater than 3 and less than 11
            If(dt.month() >3){
                IF(dt.month()<11){
                    dt.addHours(6);
                }
                //following code is if month = 12 (because the 2nd if above returned false)
                dt.addHours(5);
                // following code is when the first IF returns false
                dt.addhours(5);
            } //closing bracket on first set of if's

//starting IF set for dates in March
            else If (dt.month = 3){
                If(weekofmonth >= 3){
                    //if week of month is greater than or equal to 3 (meaning into the 3rd week, meaning after the 2nd weekend) then DST is in effect; add 6 hrs
                    dt.addHours(6);
                    dt.addHours(5);
                    
                }}
//starting Else set for dates in November
            Else //last option is for event to be in november
                If (weekofmonth >= 2){
                 //meaning it's in the 2nd week or after the first weekend
                 dt.addHours(5);
                 dt.addHours(6);
                }}}}

 
I've created a customer intake form for internal use and need some help determining the best way to create a lead record (which will immediately be converted to account/contact/opportunity thanks to that awesome plugin I found in help)
All of my detail fields pull data from the first input screen, and I don't know how to get only the selected decision branch into the record create.  I also don't fully understand Collection Variables, sObject Variables, or sObject Collection Variables (despite going through the trailhead) but I feel like the solution is along that route?  All I can figure right now is propulating fields using a whole bunch of IF() formulas but I think there has to be a stronger, more efficient way.  Guidance please? Many thanks! 

Image depicting my cloud flow design for customer intake
Hi All, First of all, thank you in advance! I'm having trouble sorting out why my formula inside flow designer isn't working.  I have a lead input screen that creates a record, with an IF formula on company name that if left blank use last name + " Household" for the company name.  I swear the formula worked yesterday, but today I am boggled!  Interestingly I don't get errors if a company name is input on the lead input screen.  Please let me know your thoughts or if you need additional information.  

if(
isblank ({!WebCompany_Organization}),
{!WebLast_Name}&" Household",
{!WebCompany_Organization}
)

Many thanks! Ruth