• Kurt A Brimberry
  • NEWBIE
  • 0 Points
  • Member since 2016
  • Harvey Tool


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hello.  I have a custom List Button that calls some onClick Javascript.  The button works for all but the first argument, and I can't seem to wrestle this to the ground.  We have 4 Account record types, and 4 matching Contact records types.  When you create a new contact (from the Account related list) on an account, I want to skip the record type slection page entirely, since the Contact's record type is related to the Account's in a 1:1 fashion.

To do this, I created a custom formula field on the Account with the developer name for the Record Type.  Then I wrote this JS.  It works for 3 of the 4, but for End User it fails.  Any Thoughts?  Thanks in advance!
 
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")} 

var agmt = new sforce.SObject("Account"); 
agmt.Id = '{!Account.Id}'; 

var agmtStats = sforce.connection.query("SELECT Account_Record_Type_for_Flows__c FROM Account WHERE id = '{!Account.Id}'"); 

records = agmtStats.getArray("records"); 
var agmtStat = records[0].Account_Record_Type_for_Flows__c; 

if(agmtStat == 'End User'){ 
alert('System Out'); 
} 
else if(agmtStat == 'Competitor'){ 
window.open('/003/e?retURL={!Account.Id}&accid={!Account.Id}&RecordType=0120j0000000EZh&ent=Contact '); 
} 
else if(agmtStat == 'Distributor'){ 
window.open('/003/e?retURL={!Account.Id}&accid={!Account.Id}&RecordType=0120j0000000EZX&ent=Contact '); 
} 
else if(agmtStat == 'Production Partner'){ 
window.open('/003/e?retURL={!Account.Id}&accid={!Account.Id}&RecordType=0120j0000000EZc&ent=Contact'); 
} 
else{ 
alert('Please Send Ticket to Helpdesk'); 
}

 
I created a report from Campaign members that will act as a call down report for the Sales team.  I then created a custom link that passes the Campaign ID and up to 3 Campaign Member Statuses.  This is the framework for the report:

pv0 = Campaign.ID
pv1 = Campaing Member Status 1
pv2 = Campaing Member Status 2
pv3 = Campaing Member Status 3

The report has filter logic of 1 AND (2 OR 3 OR 4).

When building the URL the campaign ID is always {!Campaign.ID}.  However, based on the value of a custom pick-list field on the campaign I need to dynamically pass values to pv1 through pv3.  The following is my formula which returns a syntax error.

/00O0j000000O5jt?pv0={!Campaign.Id}
{!IF( ISPICKVAL( Campaign.Targeted_Audience__c , "Distributor") ,
pv1="Planned Invitation"&pv2="Invited",&pv3="Committed"
pv1="Planned Outreach"&pv2="In Process")}

Thanks in advance for any help the community can provide!
Hello All,

I created a custom Apex class with invocable method to be able to perform some timezone conversion calculations at a certain point in a Visual Flow.  It works great, but I need to create a test class to get my test coverage above 75% to be able to create a managed package with it.

This is the class with the invokable method:
 
global class TimeZoneConverter
{
    @InvocableMethod(label='Convert Timezone DateTime' description='Converts a date time timezone string to a DateTime value')
    public static List<Datetime> UTCdateValue(List<TimezoneConvertRequest> ConvertMe)
    {
        Timezone tz = Timezone.getTimeZone(ConvertMe[0].tzRequest); //now I have an official Timezone datatype variable tz
        Datetime dt = Datetime.parse(ConvertMe[0].dtRequest.format()); //now I have a UTC Datetime string
        Integer offsetMS = tz.getOffset(dt); //now I have the Milliseconds difference between the timezone selected and the UTC datetime string
        Integer offsetHrs = (((offsetMS / 1000)/60)/60)*-1; //now I have the offset in hours
        
        Datetime adjdt = dt.addHours(offsetHrs); //should be the adjusted value.
        
        List<Datetime> returnMe = new List<Datetime>();
        returnMe.add(adjdt);
        return returnMe;
    }
    
    global class TimezoneConvertRequest {
        @InvocableVariable(required=true)
        public String tzRequest;
        @InvocableVariable(required=true)
        public Datetime dtRequest;
    }

}

and this is as far as I've been able to get with creating the test class:
 
@isTest
	class TimeZoneConverterTest {
        @isTest static void testTimezoneConvertRequest() {
            Test.startTest();
            DateTime BroadcastItemDateTimeTest = Datetime.parse('2016-01-01 13:00:00');
            string Timezone_Selected = 'US/Eastern';
            List<TimeZoneConverter.TimezoneConvertRequest> testingThis = new List<TimeZoneConverter.TimezoneConvertRequest>();
            TimeZoneConverter.TimezoneConvertRequest ConvertMeTest = new TimeZoneConverter.TimezoneConvertRequest();
            ConvertMeTest.tzRequest = Timezone_Selected;
            ConvertMeTest.dtRequest = BroadcastItemDateTimeTest;
            testingThis.add(ConvertMeTest);
            TimeZoneConverter ConvertTest = new TimeZoneConverter();
            ConvertTest.UTCdateValue(TestingThis);
            DateTime testResponse = ConvertTest[0];
			Test.stopTest();
    System.assertEquals(Datetime.parse('2016-01-01 13:00:00'), testResponse);
    }
  }

I'm getting an error of "Static methods cannot be invoked through an Object instance: UTCdateValue(List)" on line 13 - the one that reads:
 
ConvertTest.UTCdateValue(TestingThis);

I've gone around and around on this one and can't find a resource that spells it out quite clearly enough for me... Can someone help me get my code coverage up to snuff?

Thanks!

Adam