• MattMet86
  • NEWBIE
  • 155 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 65
    Questions
  • 83
    Replies
Data Loader V43

I have used the data loader CLI many times and have never run into this issue.  If i run the following SOQL from Data Loader GUI it will execute and return results. 
Select Hub_Name__r.Name hubName, Account__r.Name accName, Count(ID) FROM Survey_Results__c WHERE Survey_Date__c = THIS_MONTH Group By Hub_Name__r.Name, Account__r.Name ORDER By Hub_Name__r.Name ASC, Account__r.Name ASC
When I then try and run it via CLI however the generated file is blank and has no header or anything else and the CLI window just has a general error message of NullPointerException.  I have tried both a blank SDL file and one with mappings and still have the same issue. 

If I remove the field aliases than the GUI will yell that duplicate "name" aliases exist. 

Any ideas? 
Is there a way to get the total days or hours of each week of a month?

I am using WEEK_IN_MONTH() to get the week number but now I need something like HOURS_IN_WEEK() or DAYS_IN_WEEK() which I can use to generate hours. 
For example, looking at January. 
1st week has 4 days = 96 hours.
2nd week has 7 days =168 hours,
and so on,
Last week has 6 days = 144 hours. 
I am trying to get a horizontal scroll bar to show up on my selectList but can't get it to work. Hoping someone here has faced similar issue and can advise.  Having the text scroll to the next line would also work but i don't know how to do either. 

VF Page:
<style>

        #nav {
        width:15%;
        float:left;
        padding:5px;
        color:black;
        }
        
    </style> 

<div id="nav">
            <apex:pageblock tabStyle="License__c" >
                <apex:pageBlockSection title="Options:" columns="1" collapsible="false">
                    <apex:inputCheckbox value="{!showAll}">
                        Show All Licensed
                        <apex:actionSupport event="onchange" rerender="thePage" status="tbloading"/>
                    </apex:inputCheckbox>
                </apex:pageBlockSection>
                <apex:pageBlockSection title="Licenses:" columns="1" collapsible="false">
                    <apex:outputPanel >
                        <apex:selectList id="statelist"  
                                         value="{!States}" 
                                         multiselect="true" 
                                         size="10" 
                                         style="width: 100%;overflow-x:auto;overflow:auto;">
                            <apex:selectOptions value="{!items}"/>
                        </apex:selectList>
                    </apex:outputPanel>
                </apex:pageBlockSection>
                <apex:pageBlockSection columns="2">
                    <apex:commandButton action="{!stateFilter}" rerender="thePage" title="Filter" value="Filter" status="tbloading">
                        <apex:param name="offsetsize" assignTo="{!offsetsize}" value=""/>
                        <apex:param name="AccRendered" assignTo="{!AccRendered}" value="FALSE"/>
                    </apex:commandButton>
                    <apex:commandButton action="{!resetFilter}" rerender="theForm" title="Reset" value="Reset" status="tbloading">
                        <apex:param name="offsetsize" assignTo="{!offsetsize}" value=""/>
                        <apex:param name="AccRendered" assignTo="{!AccRendered}" value="FALSE"/>
                        <apex:param name="bcsPaging" assignTo="{!bcsPaging}" value="TRUE"/>
                        <apex:param name="showAll" assignTo="{!showAll}" value="FALSE"/>
                    </apex:commandButton>
                </apex:pageBlockSection>
            </apex:pageblock>
        </div>

Currently looks like this:
User-added image

 
I have a visualforce page passing a value to controller.
Variable name is stFilter
My soql is:
Select Id, Name, User__r.Name, 
(Select Id,Account__c,Account__r.Name,Hub_Name__r.Name FROM Account_Counselors__r), 
(Select Name FROM Licenses__r) 
FROM BCS__c WHERE Inactive__C = FALSE
How do I filter it so that only BCS_c records that have a Licenses__r record with "Name" value matching stFilter are returned.

Example
stfilter = Kansas
I only want to get back BCS__c records that have a Licenses__r record for Kansas.
The following code works but I am getting the value as GMT (i think) instead of the local time zone. 

TM.Last_Call_Center_Contact__c = T.CreatedDate;

How do I get the CreatedDate in my locale? Is there a ".locale()" or something you can add to the end? 
Need a little help. I can't figure out the correct syntax to utilize Task What.Type in my trigger. Can someone tell me what I am doing wrong?
 
trigger ININRelatedToFix on Task (after Insert, after Update) {
    
    //Get Record Type    
    RecordType Five9Rec = [select id from RecordType where name = 'Five9 Call' AND sobjecttype = 'Task' limit 1];
    system.debug('RecordType= '+Five9Rec.Id);
    
    //Create List for bulkified update
    List<Task> taskList = new List<Task>();
    
    //Loop through each task handed to trigger
    for (Task T : Trigger.new) {
        
        //If Call is related to Employee Session instead of Employee
        //*******************
        If(T.What.Type.equals('Employee_Session__c') && T.RecordTypeId == Five9Rec.Id){
            
            //Get the employee
            Employee_Session__c Emp = [Select Employee__c FROM Employee_Session__c WHERE ID = :T.WhatId];
            
            //Fix Relationship
            T.WhatId = Emp.Employee__c;
            taskList.add(t);
        }
    }
    
    //Builify Update
    update tasklist;
}

 
I can't find the proper URL syntax for the home tab. Can someone please tell me the proper syntax for Home tab? 

User-added image
Ok, I have the following schedulable class but I am running into the SOQL limit on my query. The query should return back around 60 summaires at most but one of our accounts has 92,000 employees which is where i think I am hitting the limit. Can anyone help me code this to get past the limit? 

I put a comment around the soql block that is breaking. 
global class BCI_Account_State_Count_Rollup implements Schedulable {
/*
Created by MM - 1/25/2016
Purpose - count the state field for each active employee on 
an account and update the corresponding state field count
on the account page. 
*/

//Used for aggregrateresults
Public Summary[] Summaries { get; set; }

//Make class schedulable    
global void execute(SchedulableContext ctx) {        
    CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime
                      FROM CronTrigger WHERE Id = :ctx.getTriggerId()];


    //Create Set with fields from Account page.
    Set<String> statesAcct = new Set<string>{
        'AL','AK','AZ','AR','CA','CO',
            'CT','DE','FL','GA','HI','ID',
            'IL','IN','IA','KS','KY','LA',
            'ME','MD','MA','MI','MN','MS',
            'MO','MT','NE','NV','NH','NJ',
            'NM','NY','NC','ND','OH','OK',
            'OR','PA','RI','SC','SD','TN',
            'TX','UT','VT','VA','WA','WV',
            'WI','WY',
            //Commonwealth/Territories
            'DC'};


                //Create List of active accounts
                list<account> myAccounts = new list<account>();
    myAccounts = [Select ID, Name from Account WHERE Type = 'Client'];

    //Create list to bulkify update command at end of loop
    list<account> accountsToUpdate = new list<account>();

    //Get active employee counts for every account.
    //Getting all at once to limit SOQL queries. 
    Summaries = new List<Summary>();

//CODE THAT IS BREAKING DUE TO SOQL LIMIT
        AggregateResult[] groupedResults = [SELECT COUNT(ID) ct, State__c st, Account__c acct FROM Employees__c WHERE Type__c = 'Client' AND Inactive__c != 'X' GROUP BY Account__c,State__c];
//END BROKEN CODE

    for (AggregateResult ar : groupedResults) {
        Summaries.add(new Summary(ar));
    }


    //Loop MyAccounts
    for ( Account a : myAccounts ){

        //Create map of specific account aggregrate results per state. 
        Map<String, integer> aggregateAcct = new Map<String, integer>();


        //Loop - extract aggregrateResult data just for current account. 
        for(Summary s : Summaries ){
            //system.debug('Summary' + s.acctid);
            //system.debug('Account' + a.Id);

            if(s.acctId == a.id){
                aggregateAcct.put(s.stateName,s.stateCount);
                //System.debug('aggregateAcct - ' + s.stateName + '-' + s.stateCount); 
            } 
        }
        //End Loop - Summaries

        //Create State Name to State count field Map
        Map<String, integer> stateCount = new Map<String, integer>();

        //Link the state count to the field name that is used on the Account object 
        //This way we only get values for states that we have fields for on Account object.
        for(String st : statesAcct){
            StateCount.Put(st, aggregateAcct.get(st));  
        }

        //Now update each state field using our stored values. 
        //Values in StateCount map are now StateAbbreviation and Count

        a.AK__c = stateCount.get('AK');
        a.AL__c = stateCount.get('AL');
        a.AR__c = stateCount.get('AR');
        a.AZ__c = stateCount.get('AZ');
        a.CA__c = stateCount.get('CA');
        a.CO__c = stateCount.get('CO');
        a.CT__c = stateCount.get('CT');
        a.DE__c = stateCount.get('DE');
        a.FL__c = stateCount.get('FL');
        a.GA__c = stateCount.get('GA');
        a.HI__c = stateCount.get('HI');
        a.IA__c = stateCount.get('IA');
        a.ID__c = stateCount.get('ID');
        a.IL__c = stateCount.get('IL');
        a.IN__c = stateCount.get('IN');
        a.KS__c = stateCount.get('KS');
        a.KY__c = stateCount.get('KY');
        a.LA__c = stateCount.get('LA');
        a.MA__c = stateCount.get('MA');
        a.MD__c = stateCount.get('MD');
        a.ME__c = stateCount.get('ME');
        a.MI__c = stateCount.get('MI');
        a.MN__c = stateCount.get('MN');
        a.MO__c = stateCount.get('MO');
        a.MS__c = stateCount.get('MS');
        a.MT__c = stateCount.get('MT');
        a.NC__c = stateCount.get('NC');
        a.ND__c = stateCount.get('ND');
        a.NE__c = stateCount.get('NE');
        a.NH__c = stateCount.get('NH');
        a.NJ__c = stateCount.get('NJ');
        a.NM__c = stateCount.get('NM');
        a.NV__c = stateCount.get('NV');
        a.NY__c = stateCount.get('NY');
        a.OH__c = stateCount.get('OH');
        a.OK__c = stateCount.get('OK');
        a.OR__c = stateCount.get('OR');
        a.PA__c = stateCount.get('PA');
        a.RI__c = stateCount.get('RI');
        a.SC__c = stateCount.get('SC');
        a.SD__c = stateCount.get('SD');
        a.TN__c = stateCount.get('TN');
        a.TX__c = stateCount.get('TX');
        a.UT__c = stateCount.get('UT');
        a.VA__c = stateCount.get('VA');
        a.VT__c = stateCount.get('VT');
        a.WA__c = stateCount.get('WA');
        a.WI__c = stateCount.get('WI');
        a.WV__c = stateCount.get('WV');
        a.WY__c = stateCount.get('WY');
        a.DC__c = stateCount.get('DC');


        accountsToUpdate.add(a);

    }
    //End Loop - Account

    update accountsToUpdate;

}

 
The APEX Dev guide says that you can use a helper method to simplify doing @mentions in chatter posts. I can't get the helper mothod to work. I am getting an error using the example code from the github site. 

Dev Guide:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_post_feed_element_mention.htm
Link to helper on github:
https://github.com/forcedotcom/ConnectApiHelper

Code:
ConnectApi.FeedItem fi = ConnectApiHelper.postFeedItemWithMentions(Network.getNetworkId(), 'me', 'Hey there {005D00000015tjz}, how are you?');
Error Message:
Illegal assignment from ConnectApi.FeedElement to ConnectApi.FeedItem
 
Can anyone tell me the correct syntax for adding an IMG to the headerValue property? 

I currently have this code which displays the image on the inputField line.
<apex:column headerValue="Election Status">
                    <img src="/resource/acorn" title="   {!$ObjectType.Employee_Session_Benefit__c.Fields.Election_Status__c.inlineHelpText}" height="13" width="13" />
                        <apex:inputField value="{!rev.Election_Status__c}" rendered="{!paperRender}" />
                        <apex:outputText value="{!rev.Election_Status__c}" rendered="{!!paperRender}" />
                    </apex:column>

I want to move the <IMG... line up to the headerValue.

Here is a screenshot of how it currently looks. I want to move the image, and help text, to the area where the green arrow is pointing. 

User-added image

Any suggestions? 

 

My pagereference is being shown within the existing VF page instead of redirecting to a new page. Can someone tell me what i have done wrong? 

Here is the VF page before I click the button:

User-added image

Here is the page after I click the button:
User-added image

Here is the code for that group of buttons:

<apex:pageBlockButtons id="pbb_save" location="bottom" rendered="{!!sessionEditDisable}">
                    <apex:commandButton action="{!saveChangesNewPage}" value="Save Voluntary Info" rendered="{!!serviceSession}" rerender="theForm" status="status" />
                    
                    <apex:commandButton action="{!ScheduleReview}" value="Save,Schedule Review" rendered="{!!serviceSession}" rerender="theForm" status="status" />
                    
                    <apex:commandButton action="{!assignFollowUpTask}" value="Save,Assign Follow-Up Task" rendered="{!!serviceSession}" rerender="theForm" status="status" />

                     <apex:actionStatus id="status">
                        <apex:facet name="start">
                            <div style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.50; z-index: 1000; background-color: gray;">
                                &nbsp;
                            </div>
                            <div style="position: fixed; left: 0; top: 0; bottom: 0; right: 0; z-index: 1001; margin: 20% 50%">
                                <img src="/img/loading32.gif"/>
                            </div >
                        </apex:facet>
                    </apex:actionStatus>
                    
                </apex:pageBlockButtons>

Here is the code from the extension controller for the scheduleReview button:
public pageReference scheduleReview() {
        
        system.debug('in scheduleReview method'); 
        
        saveChanges();
        recordTypes = [SELECT id FROM RecordType WHERE (Name = 'ScheduleReview' OR Name = 'Schedule Review') AND sObjectType = 'Event' ];
        Employee_Session__c es = [SELECT id,Employee__c,Session_Status__c FROM Employee_Session__c WHERE id = :esId];
        
        PageReference pr;
        pr = new PageReference('/00U/e?');
        pr.getParameters().put('what_id',es.Employee__c);
        pr.getParameters().put('retURL','%2F' + es.Employee__c);
        pr.getParameters().put('RecordType',recordTypes[0].id);
        pr.getParameters().put('ent','Event');
        return pr;
    }

 
Anybody know how to create  a content folder? I have tried this command via the execute annonoymous window but I am getting back an incorrect ID for the parentContentFolderID field.  My ID is the chatter library ID. 
List<ContentFolder> folder = new List<ContentFolder>();
            folder.add(new ContentFolder(
                Name 					= 'HR Buzz',
                ParentContentFolderId 	= '05880000000PvIv'
            ));
        
        insert folder;

 
How do you simulate the action of changing the value in a selectlist element for a test class?
<apex:pageBlockSectionItem >
                            <apex:outputText value="Benefits Filter: " />
                            <apex:selectList value="{!benefitType}" size="1">
                                <apex:selectOptions value="{!benefitTypes}" />
                                <apex:actionSupport event="onchange" action="{!loadESBs}" rerender="Detail" status="status"/>
                            </apex:selectList>
                        </apex:pageBlockSectionItem>

 
We have images that are used in formulas in Sandbox like this:
CASE( Session_Status_Picklist__c,
"Complete", IMAGE("/servlet/servlet.FileDownload?file=01518000000EvIC","! Completed",50,50),
"In Progress", IMAGE("/servlet/servlet.FileDownload?file=01518000000EvI2","! In Progess",50,50),
"Under Admin Review", IMAGE("/servlet/servlet.FileDownload?file=01518000000EvIW","! Under Review",50,50),
""
)
When I move the images to Production the ID value for the image will  change.

Is there a better way to reference images so that they can be referenced in both Sandbox and Production? Maybe the thing called Static Resource which I haven't used yet.  

 
Need some help, I can't figure out how to close the publisher window once my record has been saved.
Can someone tell me how to do this?

Controller:
public class ContestEntryController {

    public Contest_Tracking__c contest  { get; private set; }
    public BCS__c hub                   { get; private set; }

    public ContestEntryController() {

        //Capture choices
        contest = new Contest_Tracking__c(); 

        //Find Hub for user
        hub = [Select Id FROM BCS__c WHERE User__c = :UserInfo.getUserId()];
    }

    public PageReference save() {
        try {
            contest.Contest_Name__c     = contest.Picklist_Contest_Name__c;
            contest.Related_to__c       = hub.Id;
            contest.User__c             = UserInfo.getUserId();
            contest.Keyword__c          = contest.Picklist_Contest_Name__c;
            insert(contest);
            return null;
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }

    }
}

Page:
<apex:page controller="ContestEntryController" showHeader="false" sidebar="false" tabStyle="Contest_Tracking__c">

    <script> function refreshFeed() {
    Sfdc.canvas.publisher.publish({name : 'publisher.close', payload : {feed: true}}); }
  </script>

    <apex:form style="width:90%;margin:auto;" >
        <apex:pageBlock mode="edit" >
            <!-- Enter Contest --> 
            <apex:pageBlockSection columns="2" showHeader="true" title="Create Contest Entry">
                <apex:outputLabel value="Contest Name"/>
                             <apex:actionRegion >
                              <apex:inputField value="{!contest.Picklist_Contest_Name__c}" required="true">
                              <apex:actionSupport event="onchange" reRender="MarchMadness"/>
                              </apex:inputField>
                             </apex:actionRegion>
                <apex:outputLabel value="Contest Vote"/>
                             <apex:actionRegion >
                              <apex:inputField value="{!contest.Picklist_Contest_Vote__c}" required="true">
                              <apex:actionSupport event="onchange" reRender="MarchMadness" />
                              </apex:inputField>
                             </apex:actionRegion>
            </apex:pageBlockSection>

            <!-- Button Section -->
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Submit Entry" action="{!save}" oncomplete="refreshFeed();" />
            </apex:pageBlockButtons>

            <!-- Rules -->
            <apex:pageBlockSection columns="1" showHeader="true" title="Contest Rules">
                <apex:pageblocksection id="MarchMadness" columns="1">
                <apex:outputPanel styleClass="rules" style="width:80%" rendered="{!contest.Picklist_Contest_Name__c == 'March Madness'}">
                    1. Be sure to complete you bracket at CBS Sport to be eligible for prizes.<br />
                    2. Guess your champion here to earn 10 points for Culture Club.<br /> <br />
                    If you did not get a CBS Sports bracket invitation, please email Jim.<br /><br />
                </apex:outputPanel>
                    </apex:pageblocksection>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>

    <!-- CSS -->
    <style>
        .logo {
        float: right;
        width: 200px;
        margin: -65px 20px 0 0;
        padding: 20px;
        }
        .rules {
        color: black;
        font-size: 18px;     
        float: left;
        width: 100%;
        }
    </style>
</apex:page>


 
I am getting the following error when I run my test class
System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Account, original object: User: []

Here is my complete test class. I have tried every variation of the test.starttest and test.stoptest I can think of but i can't get past the error. 
 
@isTest
//Created by Matt - March 2016
//Designed for the Acorn Release
//

public class Test_Session_and_Session_Benefit {
    @testSetup static void setupTestData(){
        
        Test.startTest(); 
        List<User>testUsers = new List<User>();
        
        //Create Admin User
        Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
        testUsers.add(new User(Alias = 'SysAdmin', Email='admin@bcinsourcing.com', 
                          EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
                          LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles', ProfileId = p.Id, 
                          UserName='admin@bcinsourcing.com'));

         //Create Manager
        Profile pM = [SELECT Id FROM Profile WHERE Name='BCS Manager']; 
        testUsers.add(new User(Alias = 'TSTMGR', Email='testmanager@bcinsourcing.com', 
            EmailEncodingKey='UTF-8', LastName='TSTMGR', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles', ProfileId = pM.Id, 
            UserName='testmanager@bcinsourcing.com'));

        //Create Standard User
        Profile pS = [SELECT Id FROM Profile WHERE Name='Chatter Only - BCS Standard']; 
        testUsers.add(new User(Alias = 'TSTBCS', Email='TSTBCS@bcinsourcing.com', 
            EmailEncodingKey='UTF-8', LastName='TSTBCS', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles', ProfileId = pS.Id, 
            UserName='TSTBCS@bcinsourcing.com'));
        
        	Insert testUsers;
                 
        //Create Accounts
        List<Account> accounts = new List<Account>();
        for(Integer i=0;i < 2;i++){
            accounts.add(new Account(
                Name = 'Test Acc' +i,
                Account_Code__c = 'AC' +i,
                Type = 'Client',
                Niche__c = 'Services'
            ));
        }
        
        	insert accounts; 
        Test.stopTest();
 
        //Create Public Group
        List<Group> pubGroup = new List<Group>();
        for(Account acc:accounts){
            pubGroup.add(new Group(
                Name             = acc.Name,
                DeveloperName    = acc.Name,
                Type             = 'Regular'
             ));
        }
        
        	insert pubGroup;
        
        //Create Carriers
        List<Account> carriers = new List<Account>();
        for(Integer i=0;i < 2;i++){
            carriers.add(new Account(
                Name = 'Test Carrier' +i,
                Account_Code__c = 'CA' +i,
                Type = 'Carrier'
            ));
        }
        insert carriers;
        
        //Create Hub
        List<BCS__c> theHub = new List<BCS__c>();
        for(Integer i=0;i < 1;i++){
            theHub.add(new BCS__c(
                Name = testUsers.get(0).LastName,
                DOH__c = Date.today().addDays(2),
                User__c = testUsers.get(0).Id
            ));
        }
        insert theHub;
        
        //Create Benefit Masters
        List<Benefit_Master__c> benMasters = new List<Benefit_Master__c>();
        for(Account car:carriers){
            for(Integer i=0;i < 2;i++){
                benMasters.add(new Benefit_Master__c(
                    Name = 'BenMaster'+i,
                    Carrier__c = car.Id
                ));
            }
        }
        insert benMasters;
        
        //Create Account Benefits
        List<Account_Benefit__c> AccBenefit = new List<Account_Benefit__c>();
        for(Benefit_Master__c master:benMasters){
            for(Integer i=0;i < 2;i++){
                AccBenefit.add(new Account_Benefit__c(
                    Name = master.Name,
                    Benefits_Master__c = master.id,
                    Account__c = accounts.get(i).Id,
                    Show_Elimination_Period__c   = false,
                    Show_Volume__c               = false
                ));
            }
        }
        insert AccBenefit;
        
        //Create Employees
        List<Employees__c> employee = new List<Employees__c>();
        for(Account acc:accounts){
            for(Integer i=0;i < 10;i++){
                employee.add(new Employees__c(
                    Name = acc.Account_Code__c + i, //Creates a HBS ID like AC11 and AC12
                    First_Name__c = 'First'+i,
                    Last_Name__c = 'Last'+i,
                    Account__c = acc.Id,
                    Review_End_Date__c = Date.today(),
                    DOH__c = Date.today(),
                    PayCy__c = 'Biweekly'
                ));
            }
        }
        insert employee;
    }
    
    
    //Create Acorn Sessions  
    static testMethod void testCreateSessions(){
        
        ....subsequent code redacted....
}

Any ideas? 
 
I need a "New Record" button to populate a field that is not on the page layout. Is this possible? If so, how do you do it. 

I tried this, the last line is the field that is not on the record create screen. 
/a1M/e?CF00N800000056AV2={!Employees__c.Name}
&CF00N800000056AV2_lkid={!Employees__c.Id}
&retURL=%2F{!Employees__c.Id}
&RecordType=012180000000AhdAAE
&ent=01I80000000pYzR
&Name={!Employees__c.Name} {!TODAY()}
&00N18000000IXlB={!Employees__c.Acquisition_Rollover_Window_Start_Date__c}
&00N18000000IXlG={!Employees__c.Acquisition_Window_End_Date__c}
&00N18000000IXkw={!Employees__c.Review_End_Date__c}
&00N18000000IXlL={!Employees__c.Status_Change_Date__c}
&00N18000000IXf8={!Account.No_Core_Benefits__c}
&00N800000056AVn={!TODAY()}
&No_Core_Account__c={!Account.No_Core_Benefits__c}

 
I am using the login flow to display an alert to our users about maintenance and I want to force a log out once they click Finsih in the flow. I have tried to use the hidden commands for logout but i can't get the log out action to work. The message is displayed to the user but after they click finsih they log right in. 

Overall Flow:
User-added image

Creating variable:
User-added image

Displaying the message to user:
User-added image

Using assginment to set value of variable: I already have it set to True as default value but thought I might need to do it again. 
User-added image

Can anyone spot what I have done wrong here? 
 
I need a formula to count the number of times a semi-colon appears in a variable. This is actually for visual flow but it is a formula like any other in Salesforce.

Any ideas? I need the count not just a TRUE or FALSE result. 

My overall goal is I need to compare the values captured from a  multi-select picklist and identify if values were either added or removed from the list. So I plan on counting the number of ; and then using a decision module to take appropriate action on another object. 

Here is an example:
09:00:25:612 FLOW_VALUE_ASSIGNMENT 3327be5ac80f0d842d9d2f061289153095dc09d-1678|varTMPriorValues|BM Web Enroll;We Care
So I need to get back 1 from this variable. 
 
09:00:25:612 FLOW_VALUE_ASSIGNMENT 3327be5ac80f0d842d9d2f061289153095dc09d-1678|varTMValues|Aflac;BM Web Enroll;We Care
And I should get 2 back from this variable. 

So I can do my decision and know that values were added to the list. 

 
Is there a way to run a trigger or class when a user clicks the New record button? 

For example, I want a bit of code to run when the user clicks the New Account button. This way I can show them an alert or other message before they put an details in for the new record and click Save which fires an existing trigger. 

I need osmething like "onload Insert"...
Anybody know how to create  a content folder? I have tried this command via the execute annonoymous window but I am getting back an incorrect ID for the parentContentFolderID field.  My ID is the chatter library ID. 
List<ContentFolder> folder = new List<ContentFolder>();
            folder.add(new ContentFolder(
                Name 					= 'HR Buzz',
                ParentContentFolderId 	= '05880000000PvIv'
            ));
        
        insert folder;

 
I have a visualforce page passing a value to controller.
Variable name is stFilter
My soql is:
Select Id, Name, User__r.Name, 
(Select Id,Account__c,Account__r.Name,Hub_Name__r.Name FROM Account_Counselors__r), 
(Select Name FROM Licenses__r) 
FROM BCS__c WHERE Inactive__C = FALSE
How do I filter it so that only BCS_c records that have a Licenses__r record with "Name" value matching stFilter are returned.

Example
stfilter = Kansas
I only want to get back BCS__c records that have a Licenses__r record for Kansas.
Need a little help. I can't figure out the correct syntax to utilize Task What.Type in my trigger. Can someone tell me what I am doing wrong?
 
trigger ININRelatedToFix on Task (after Insert, after Update) {
    
    //Get Record Type    
    RecordType Five9Rec = [select id from RecordType where name = 'Five9 Call' AND sobjecttype = 'Task' limit 1];
    system.debug('RecordType= '+Five9Rec.Id);
    
    //Create List for bulkified update
    List<Task> taskList = new List<Task>();
    
    //Loop through each task handed to trigger
    for (Task T : Trigger.new) {
        
        //If Call is related to Employee Session instead of Employee
        //*******************
        If(T.What.Type.equals('Employee_Session__c') && T.RecordTypeId == Five9Rec.Id){
            
            //Get the employee
            Employee_Session__c Emp = [Select Employee__c FROM Employee_Session__c WHERE ID = :T.WhatId];
            
            //Fix Relationship
            T.WhatId = Emp.Employee__c;
            taskList.add(t);
        }
    }
    
    //Builify Update
    update tasklist;
}

 
Ok, I have the following schedulable class but I am running into the SOQL limit on my query. The query should return back around 60 summaires at most but one of our accounts has 92,000 employees which is where i think I am hitting the limit. Can anyone help me code this to get past the limit? 

I put a comment around the soql block that is breaking. 
global class BCI_Account_State_Count_Rollup implements Schedulable {
/*
Created by MM - 1/25/2016
Purpose - count the state field for each active employee on 
an account and update the corresponding state field count
on the account page. 
*/

//Used for aggregrateresults
Public Summary[] Summaries { get; set; }

//Make class schedulable    
global void execute(SchedulableContext ctx) {        
    CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime
                      FROM CronTrigger WHERE Id = :ctx.getTriggerId()];


    //Create Set with fields from Account page.
    Set<String> statesAcct = new Set<string>{
        'AL','AK','AZ','AR','CA','CO',
            'CT','DE','FL','GA','HI','ID',
            'IL','IN','IA','KS','KY','LA',
            'ME','MD','MA','MI','MN','MS',
            'MO','MT','NE','NV','NH','NJ',
            'NM','NY','NC','ND','OH','OK',
            'OR','PA','RI','SC','SD','TN',
            'TX','UT','VT','VA','WA','WV',
            'WI','WY',
            //Commonwealth/Territories
            'DC'};


                //Create List of active accounts
                list<account> myAccounts = new list<account>();
    myAccounts = [Select ID, Name from Account WHERE Type = 'Client'];

    //Create list to bulkify update command at end of loop
    list<account> accountsToUpdate = new list<account>();

    //Get active employee counts for every account.
    //Getting all at once to limit SOQL queries. 
    Summaries = new List<Summary>();

//CODE THAT IS BREAKING DUE TO SOQL LIMIT
        AggregateResult[] groupedResults = [SELECT COUNT(ID) ct, State__c st, Account__c acct FROM Employees__c WHERE Type__c = 'Client' AND Inactive__c != 'X' GROUP BY Account__c,State__c];
//END BROKEN CODE

    for (AggregateResult ar : groupedResults) {
        Summaries.add(new Summary(ar));
    }


    //Loop MyAccounts
    for ( Account a : myAccounts ){

        //Create map of specific account aggregrate results per state. 
        Map<String, integer> aggregateAcct = new Map<String, integer>();


        //Loop - extract aggregrateResult data just for current account. 
        for(Summary s : Summaries ){
            //system.debug('Summary' + s.acctid);
            //system.debug('Account' + a.Id);

            if(s.acctId == a.id){
                aggregateAcct.put(s.stateName,s.stateCount);
                //System.debug('aggregateAcct - ' + s.stateName + '-' + s.stateCount); 
            } 
        }
        //End Loop - Summaries

        //Create State Name to State count field Map
        Map<String, integer> stateCount = new Map<String, integer>();

        //Link the state count to the field name that is used on the Account object 
        //This way we only get values for states that we have fields for on Account object.
        for(String st : statesAcct){
            StateCount.Put(st, aggregateAcct.get(st));  
        }

        //Now update each state field using our stored values. 
        //Values in StateCount map are now StateAbbreviation and Count

        a.AK__c = stateCount.get('AK');
        a.AL__c = stateCount.get('AL');
        a.AR__c = stateCount.get('AR');
        a.AZ__c = stateCount.get('AZ');
        a.CA__c = stateCount.get('CA');
        a.CO__c = stateCount.get('CO');
        a.CT__c = stateCount.get('CT');
        a.DE__c = stateCount.get('DE');
        a.FL__c = stateCount.get('FL');
        a.GA__c = stateCount.get('GA');
        a.HI__c = stateCount.get('HI');
        a.IA__c = stateCount.get('IA');
        a.ID__c = stateCount.get('ID');
        a.IL__c = stateCount.get('IL');
        a.IN__c = stateCount.get('IN');
        a.KS__c = stateCount.get('KS');
        a.KY__c = stateCount.get('KY');
        a.LA__c = stateCount.get('LA');
        a.MA__c = stateCount.get('MA');
        a.MD__c = stateCount.get('MD');
        a.ME__c = stateCount.get('ME');
        a.MI__c = stateCount.get('MI');
        a.MN__c = stateCount.get('MN');
        a.MO__c = stateCount.get('MO');
        a.MS__c = stateCount.get('MS');
        a.MT__c = stateCount.get('MT');
        a.NC__c = stateCount.get('NC');
        a.ND__c = stateCount.get('ND');
        a.NE__c = stateCount.get('NE');
        a.NH__c = stateCount.get('NH');
        a.NJ__c = stateCount.get('NJ');
        a.NM__c = stateCount.get('NM');
        a.NV__c = stateCount.get('NV');
        a.NY__c = stateCount.get('NY');
        a.OH__c = stateCount.get('OH');
        a.OK__c = stateCount.get('OK');
        a.OR__c = stateCount.get('OR');
        a.PA__c = stateCount.get('PA');
        a.RI__c = stateCount.get('RI');
        a.SC__c = stateCount.get('SC');
        a.SD__c = stateCount.get('SD');
        a.TN__c = stateCount.get('TN');
        a.TX__c = stateCount.get('TX');
        a.UT__c = stateCount.get('UT');
        a.VA__c = stateCount.get('VA');
        a.VT__c = stateCount.get('VT');
        a.WA__c = stateCount.get('WA');
        a.WI__c = stateCount.get('WI');
        a.WV__c = stateCount.get('WV');
        a.WY__c = stateCount.get('WY');
        a.DC__c = stateCount.get('DC');


        accountsToUpdate.add(a);

    }
    //End Loop - Account

    update accountsToUpdate;

}

 
The APEX Dev guide says that you can use a helper method to simplify doing @mentions in chatter posts. I can't get the helper mothod to work. I am getting an error using the example code from the github site. 

Dev Guide:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_post_feed_element_mention.htm
Link to helper on github:
https://github.com/forcedotcom/ConnectApiHelper

Code:
ConnectApi.FeedItem fi = ConnectApiHelper.postFeedItemWithMentions(Network.getNetworkId(), 'me', 'Hey there {005D00000015tjz}, how are you?');
Error Message:
Illegal assignment from ConnectApi.FeedElement to ConnectApi.FeedItem
 
Can anyone tell me the correct syntax for adding an IMG to the headerValue property? 

I currently have this code which displays the image on the inputField line.
<apex:column headerValue="Election Status">
                    <img src="/resource/acorn" title="   {!$ObjectType.Employee_Session_Benefit__c.Fields.Election_Status__c.inlineHelpText}" height="13" width="13" />
                        <apex:inputField value="{!rev.Election_Status__c}" rendered="{!paperRender}" />
                        <apex:outputText value="{!rev.Election_Status__c}" rendered="{!!paperRender}" />
                    </apex:column>

I want to move the <IMG... line up to the headerValue.

Here is a screenshot of how it currently looks. I want to move the image, and help text, to the area where the green arrow is pointing. 

User-added image

Any suggestions? 

 
We have images that are used in formulas in Sandbox like this:
CASE( Session_Status_Picklist__c,
"Complete", IMAGE("/servlet/servlet.FileDownload?file=01518000000EvIC","! Completed",50,50),
"In Progress", IMAGE("/servlet/servlet.FileDownload?file=01518000000EvI2","! In Progess",50,50),
"Under Admin Review", IMAGE("/servlet/servlet.FileDownload?file=01518000000EvIW","! Under Review",50,50),
""
)
When I move the images to Production the ID value for the image will  change.

Is there a better way to reference images so that they can be referenced in both Sandbox and Production? Maybe the thing called Static Resource which I haven't used yet.  

 
I am using the login flow to display an alert to our users about maintenance and I want to force a log out once they click Finsih in the flow. I have tried to use the hidden commands for logout but i can't get the log out action to work. The message is displayed to the user but after they click finsih they log right in. 

Overall Flow:
User-added image

Creating variable:
User-added image

Displaying the message to user:
User-added image

Using assginment to set value of variable: I already have it set to True as default value but thought I might need to do it again. 
User-added image

Can anyone spot what I have done wrong here? 
 
I need a formula to count the number of times a semi-colon appears in a variable. This is actually for visual flow but it is a formula like any other in Salesforce.

Any ideas? I need the count not just a TRUE or FALSE result. 

My overall goal is I need to compare the values captured from a  multi-select picklist and identify if values were either added or removed from the list. So I plan on counting the number of ; and then using a decision module to take appropriate action on another object. 

Here is an example:
09:00:25:612 FLOW_VALUE_ASSIGNMENT 3327be5ac80f0d842d9d2f061289153095dc09d-1678|varTMPriorValues|BM Web Enroll;We Care
So I need to get back 1 from this variable. 
 
09:00:25:612 FLOW_VALUE_ASSIGNMENT 3327be5ac80f0d842d9d2f061289153095dc09d-1678|varTMValues|Aflac;BM Web Enroll;We Care
And I should get 2 back from this variable. 

So I can do my decision and know that values were added to the list. 

 
Is there a way to run a trigger or class when a user clicks the New record button? 

For example, I want a bit of code to run when the user clicks the New Account button. This way I can show them an alert or other message before they put an details in for the new record and click Save which fires an existing trigger. 

I need osmething like "onload Insert"...
Hi, I am trying to write my first trigger and need some help. 

We have a custom object called Employee that has a field named "Scheduled Review Date". 
I need to create a trigger that upon creation of an Event record this field is updated with the date from Event in field "StartDateTime" < API name. The Related to (who) field on event is my employee. 

I have come up with this so far:
trigger ScheduledReviewDate on Event (after insert) {
    for (Event e: trigger.new){
    
    }
}

I'm not sure where to go from here. I think I need to query employee and then put the field update but I don't really know how to do this. 

I think this is pretty simple so hopefully someone can point me in the right direction. 

Thanks!
Matt

 

Hi,

 

I would like to be able to show a gif spinner on my visual force page as I am doing something on the background like loading data or waiting for data to come back before I update the page.

 

It will be ideal if I can replace apex:tags with a stylesheet that will be turned off or on based on user click.

 

 

Does anyone have a good solution for that I ma not very ajax savvy per say so any ideas will be appreciated.

 

 


Thank you. 

 

 

  • October 16, 2009
  • Like
  • 0