• Mike.Katulka
  • NEWBIE
  • 45 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 36
    Replies
Hi, I've a trigger on insert and update task. I uses both API and Web to insert/update task. I would like to stop triggers when they are updated by API. So, added a filter to check if the user is API then do nothing. I can't increase the code coverage in the following code

trigger XmsTaskTrigger on Task (after insert, after update) {
    Task[] tsk = Trigger.new;
       String JSONString = JSON.serialize(tsk);
      if(UserInfo.getProfileId()!='API'){
       XmsTask.doCallout(JSONString);
    }
 }

If I remove   if(UserInfo.getProfileId()!='API') I get 94% code coverage otherwise i get 50%
I keep getting an error on Item #4 "The custom set of fields that are highlighted on account records must be assigned to the required profile."

The requirement is asking for having highlights based on profiles, but as we know compact layouts are applied to the whole system not by profile.

I am not sure how to fix this, any help is appreciated.
I am about to begin working on an API between SFDC(CRM) and KIPU(EMR) 
KIPU's API only allows for POST and GET, so everything I do will need to be within Salesforce.
I want all client information to POST to a new file in KIPU when stage changes to Admit. Thats fine and dandy, but I want to have custom fields/stages in SF update when the client admits and discharges in KIPU.
What would be the best way to go about automating GET from Kipu.
*side note* it could be weeks in between when a client admits and discharges.

Thank You
I'd like to find a way to dynamically assign a "Line Number" to a quote line based on certain criteria. 

For instance, If I have 100 lines on my quote, and only want to show 20 of them and assign a line # 1-20 to those 20 items, how can I accomplish this? The "hidden" quote line items will not show up on the quote template since they are for internal configuration use only, but are throwing off the line #'s since they are hidden, its causing the line #'s for shown items to jump around. 

I'm assuming this may be an "After" trigger on the quote object? I don't know code well but I should be able how to write the trigger if need be with some guidance. 

Am I on the right path of having an "After" trigger and having it cycle through "quote lines" and if "Core Product" is checked and "Line Number" is blank, assign it 1, then go through the loop again and have X++ so the next quote line if it meets criteria, is 2, and so on and so on? 

Thoughts? Thanks for your help 

 
We have a Napili template on our community here. When a user clicks on this link from the twitter app on iOS, they get a message: 'Invalid Page' as described here. When they open in Safari, the community loads as expected. The problem seems to be with iOS web view (is this supported by SF?) or with the Community config somewhere.
Has this problem been reported elsewhere and are there any known fixes/workarounds besides for asking users to open with their browser?


 
Not sure why this isn't working, but is it not enough to have get;set; on a list of objects as a getter to use them in a repeat function with a visualforce page?
public List<Custom_Quote_Item__c> quoteItemList {get;set;}

then in the visualforce page:
<apex:repeat value="{!quoteItemList}" var="qi">

I know the list has about 10 items in it but nothing is executing inside the repeat.

I also tried creating a getter function:
public List<Custom_Quote_Item__c> getQuoteItems() {
        return quoteItemList;
    }
but that isn't working either.  I am confused why this isn't working because i am using repeat on a number of lists in my class which all seem to work find but this one isn't.  If anyone has any input I would greatly appreciate it!

Thanks
Hi,

My users are unable to edit any record. They are getting error:

Error:Apex trigger trgLead caused an unexpected exception, contact your administrator: trgLead: execution of BeforeUpdate caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times): Trigger.trgLead: line 25, column 1
  • April 27, 2016
  • Like
  • 0
I am working on a dynamic table, where i can add and delete rows using a command button. But when i delete a specific row, the values on the look up fields are cleared or assigned to a different row. Below are the code snippets. Thanks.
User-added image
<apex:variable value="{!0}" var="rowNum"/> 
            <apex:pageBlockSection columns="1" title="Adding Multiple Expense" collapsible="False">
            <apex:commandButton value="Add New" action="{!addNewRow}" rerender="ExpenseHead" immediate="true" />       
                <apex:pageBlockTable value="{!ExpenseList}" var="expItem"> 
                    <apex:column headerValue="User"> 
                        <apex:inputField value="{!expItem.User__c}" />
                    </apex:column>            
                    <apex:column headerValue="Category">                    
                       <apex:inputfield value="{!expItem.Category__c}"/>
                    </apex:column>
                    <apex:column headerValue="Amount">
                         <apex:inputField id="AmountId" value="{!expItem.Amount__c}"/>
                    </apex:column>
                    <apex:column headerValue="Use Day">
                        <apex:inputField value="{!expItem.Use_Day__c}"/>
                    </apex:column>
                    <apex:column headerValue="Status">
                        <apex:inputfield styleClass="RemoveNone" value="{!expItem.Status__c}"/>
                    </apex:column>
                    <apex:column headerValue="Done">
                        <apex:inputfield value="{!expItem.Done__c}"/>
                    </apex:column>
                    <apex:column headerValue="Project">
                        <apex:inputField value="{!expItem.Project__c}"/>
                    </apex:column>
                    <apex:column >
                         <apex:commandLink value="Delete" action="{!Deleterow}" rerender="ExpenseHead" immediate="true" > 
                             <apex:param value="{!rowNum}" name="rowToRemove" assignTo="{!rowToRemove}"/>
                         </apex:commandLink>
                         <apex:variable var="rowNum" value="{!rowNum + 1}"/>
                    </apex:column>            
                </apex:pageBlockTable>
            </apex:pageblockSection>
 
public class MultipleExpensesController{

    public Expense__c expense{get;set;}
    public Integer rowToRemove {get;set;}
    public List<Expense__c> ExpenseList{get;set;}
      
    public Expense__c setExpense(Expense__c ex){
        this.expense = ex;
        return expense;
    }
    
     public MultipleExpensesController(ApexPages.StandardController controller){
       expense = new Expense__c();
       ExpenseList = new List<Expense__c>();
       ExpenseList.add(expense);
    }

    public void deleteRow(){
      ExpenseList.remove(rowToRemove );
      system.debug(' index '+ rowToRemove );
    }
    
    public void addNewRow(){
       expense = new Expense__c();
       ExpenseList.add(expense);
    }
       
}

 
Hi, I've a trigger on insert and update task. I uses both API and Web to insert/update task. I would like to stop triggers when they are updated by API. So, added a filter to check if the user is API then do nothing. I can't increase the code coverage in the following code

trigger XmsTaskTrigger on Task (after insert, after update) {
    Task[] tsk = Trigger.new;
       String JSONString = JSON.serialize(tsk);
      if(UserInfo.getProfileId()!='API'){
       XmsTask.doCallout(JSONString);
    }
 }

If I remove   if(UserInfo.getProfileId()!='API') I get 94% code coverage otherwise i get 50%
Hi All,

I have overriden a custom object Edit/New button with Visualforce page to leverage some functionalities like adding text instruction on filling up the form, ajax functionality to fetch information based on coditions etc . However I cannot view the button on Community.

I am using Napili theme on community, I know it does not supports visuaforce but how can I add a lightning component  or something to override the records edit functionality. 

Could I create a custom Tab for viewing the record list using lightning component and then eventually will have to create Detail, New, View pages? How can we achieve it if its possible ? Looks lot of work and maintenance in future for this option.

Please help me on this. 
Can I create a lightning page with simple html contents. The side bar is no longer available in the lightning mode.  The client is fine with showing links on the page instead of buttons.  

I need to show these links based on some conditions.  People with some profiles should not have access to some sections.  

Thanks
I have added a VF page, trigger and control and receive Map key a2VD0000000v4AnMAI not found in map.

Any help at all please, new to Apex and using similar development work as a template

VF Page:
<apex:page controller="CampItineraryController" title="Camp Itinerary">
<apex:sectionHeader title="Camp Itinerary"/>
<apex:pageMessages />
<apex:form >    
  <apex:pageBlock title="Sessions">

        <apex:pageBlockButtons >
          <apex:commandButton action="{!saveSessions}" id="saveButton" value="Save" status="sessionsStatus" rerender="elementsTable"/>
          <apex:commandButton action="{!addSessions}"  id="addButton"  value="Add" rerender="sessionTable, elementsTable" status="sessionsStatus"/>
          <apex:commandButton action="{!deleteSessions}"  id="deleteButton"  value="Delete" rerender="sessionTable" status="sessionsStatus"/>
        </apex:pageBlockButtons>
        <apex:actionStatus id="sessionsStatus" stopText="">
            <apex:facet name="start" >
              <apex:outputPanel >
              <apex:outputtext value="Updating...    "/>
              <apex:image url="/img/loading.gif" />                       
              </apex:outputPanel>
            </apex:facet>          
          </apex:actionStatus>         
        <apex:pageBlockTable value="{!sessions}" var="r" id="sessionTable">   
          <apex:column headerValue="Select" style="width: 30px">        
            <apex:inputCheckbox value="{!r.isSelected}"/>
          </apex:column>
          <apex:repeat value="{!$ObjectType.Session__c.FieldSets.Related_List_Fields}" var="f">
            <apex:column headerValue="{!f.label}" >
              <apex:inputField value="{!r.obj[f]}" />
            </apex:column>
          </apex:repeat>
        </apex:pageBlockTable>
  </apex:pageBlock>

  <apex:pageBlock title="Durations">

        <apex:pageBlockButtons >
          <apex:commandButton action="{!saveDurations}" id="saveButton" value="Save" status="durationsStatus"/>
          <apex:commandButton action="{!addDurations}"  id="addButton"  value="Add" rerender="durationTable" status="durationsStatus"/>
          <apex:commandButton action="{!deleteDurations}"  id="deleteButton"  value="Delete" rerender="durationTable" status="durationsStatus"/>
        </apex:pageBlockButtons>
        <apex:actionStatus id="durationsStatus" stopText="">
            <apex:facet name="start" >
              <apex:outputPanel >
              <apex:outputtext value="Updating...    "/>
              <apex:image url="/img/loading.gif" />                       
              </apex:outputPanel>
            </apex:facet>          
          </apex:actionStatus>         
        <apex:pageBlockTable value="{!durations}" var="d" id="durationTable">   
          <apex:column headerValue="Select" style="width: 30px">        
            <apex:inputCheckbox value="{!d.isSelected}"/>
          </apex:column>
          <apex:repeat value="{!$ObjectType.Session_Duration__c.FieldSets.Related_List_Fields}" var="f">
            <apex:column headerValue="{!f.label}" >
              <apex:inputField value="{!d.obj[f]}" />
            </apex:column>
          </apex:repeat>
        </apex:pageBlockTable>
  </apex:pageBlock>

  <apex:pageBlock title="Elements">

        <apex:pageBlockButtons >
          <apex:commandButton action="{!saveElements}" id="saveButton" value="Save" status="elementsStatus"/>
        </apex:pageBlockButtons>
        
<!--        <apex:repeat value="{!sessions}" var="thisSession">
            <apex:repeat value="{!durations}" var="thisDuration">
                {!thisSession.obj.id} {!thisDuration.obj.id} <br/>
                {!elements[thisSession.obj.id][thisDuration.obj.id].Element__c} <br/>
            </apex:repeat>
        </apex:repeat>-->

        <apex:pageBlockTable value="{!sessions}" var="thisSession" id="elementsTable">
                <apex:column headerValue="Session">
                    <apex:outputField value="{!thisSession.obj['name']}"/>
                </apex:column>
            <apex:repeat value="{!durations}" var="thisDuration">
                <apex:column headerValue="{!thisDuration.obj['name']}">
                    <apex:inputField value="{!elements[thisSession.obj.id][thisDuration.obj.id].Element__c}"/>
                </apex:column>
            </apex:repeat>
        </apex:pageBlockTable>
  </apex:pageBlock>  

</apex:form>
</apex:page>

Controller
 
ublic with sharing class CampItineraryController {

    public List<sObject> extractObjs(List<sObjectWithSelect> theList) {
        return extractObjs(theList, false);
    }
    
    public List<sObject> extractObjs(List<sObjectWithSelect> theList, boolean testForSelected) {
        List<sObject> rval = new List<sObject>();
    
        for(sObjectWithSelect thisObj : theList) {
            if(!testForSelected || thisObj.isSelected) {
                rval.add(thisObj.obj);
            }
        }
        
        return rval;
    }

    public class sObjectWithSelect {
        
        public sObject obj {get; set;}
        public boolean isSelected {get; set;}
        
        public sObjectWithSelect(sObject obj) {
            this.obj = obj;
            this.isSelected = false;
        }
        
    }

    public List<sObjectWithSelect> sessions {get; set;}
    public List<sObjectWithSelect> durations {get; set;}
    public Map<String, Map<String, Session_To_Duration__c>> elements {get; set;}
    private List<Session_To_Duration__c> rawelements;
    private String sessionQueryString;
    private String durationQueryString;
    
    public CampItineraryController() {
        Schema.FieldSet fs = Schema.SObjectType.Session__c.fieldSets.Related_List_Fields;
        
        String selectfields = 'id ';
        
        for(Schema.FieldSetMember thisField : fs.getFields()) {
            selectFields = selectFields + ', ' + thisField.getFieldPath();
        }

        sessionQueryString = 'SELECT ' + selectfields
                         + ' FROM Session__c ORDER BY Name ASC';

        
        fs = Schema.SObjectType.Session_Duration__c.fieldSets.Related_List_Fields;
        
        selectfields = 'id ';
        
        for(Schema.FieldSetMember thisField : fs.getFields()) {
            selectFields = selectFields + ', ' + thisField.getFieldPath();
        }

        durationQueryString = 'SELECT ' + selectfields
                         + ' FROM Session_Duration__c ORDER BY Name ASC';        

        initSessions();
        initDurations();
        initElements();        
    }
    
    private void initElements() {
        rawElements = [SELECT id, Element__c, Session__c, Session_Duration__c 
                                               FROM Session_To_Duration__c];
                                               
        elements = new Map<String, Map<String, Session_To_Duration__c>>();
        
        for(Session_To_Duration__c thisSTD : rawElements) {
            Map<String, Session_To_Duration__c> thisMap = elements.get(thisSTD.Session__c);
            
            if(thisMap == null) {
                thisMap = new Map<String, Session_To_Duration__c>();
                elements.put(thisSTD.Session__c, thisMap);
            }
            
            thisMap.put(thisSTD.Session_Duration__c, thisSTD);
        }
    }
    
    private void initSessions() {
        system.debug(sessionQueryString);
        List<Session__c> theSessions = Database.query(sessionQueryString);

        sessions = new List<sObjectWithSelect>();

        for(Session__c thisSession : theSessions) {
            sessions.add(new sObjectWithSelect(thisSession));
        }
    }

    private void initDurations() {
        system.debug(durationQueryString);
        List<Session_Duration__c> theDurations = Database.query(durationQueryString);

        durations = new List<sObjectWithSelect>();

        for(Session_Duration__c thisDuration : theDurations) {
            durations.add(new sObjectWithSelect(thisDuration));
        }
    }
        
    public PageReference addSessions() {
        saveSessions();
        Session__c newSession = new Session__c(Name = 'Enter a session name');
        
        try {
            insert newSession;
        } catch(Exception e) {
            ApexPages.addMessages(e);
        }
        
        sessions.add(new sObjectWithSelect(newSession));
        initElements();
        
        return null;
    }

    public PageReference saveSessions() {
        
        try {
            update extractObjs(sessions);
        } catch(Exception e) {
            ApexPages.addMessages(e);
        }
        
        initElements();
        
        return null;
    }

    public PageReference deleteSessions() {
        
        try {
            delete extractObjs(sessions, true);
        } catch(Exception e) {
            ApexPages.addMessages(e);
        }
        
        initSessions();
        initElements();
        
        return null;
    }
    public PageReference deleteDurations() {
        try {
            delete extractObjs(durations, true);
        } catch(Exception e) {
            ApexPages.addMessages(e);
        }
        
        initDurations();
        initElements();
        
        return null;
    }


    public PageReference addDurations() {
        saveDurations();
        Session_Duration__c newDuration = new Session_Duration__c(Name = 'Enter a duration name');
        
        try {
            insert newDuration;
        } catch(Exception e) {
            ApexPages.addMessages(e);
        }
        
        durations.add(new sObjectWithSelect(newDuration));
        initElements();
       return null;
    }


    public PageReference saveDurations() {
        try {
            update extractObjs(durations);
        } catch(Exception e) {
            ApexPages.addMessages(e);
        }
        
        initDurations();
        initElements();
        
        return null;
    }

    public PageReference saveElements() {
        try {
            update rawElements;
        } catch(Exception e) {
            ApexPages.addMessages(e);
        }
        
        return null;
    }

}

 
I have Mass Edit and Mass Update installed in both my Sandbox and Production orgs. When I switch to Lightning Experience the Mass Edit and Mass Update buttons appear on Opportunity and Account Lists but there is no way to actually select individual records to do the Mass Edit/Update funcitons.  Clicking either of the buttons will launch the app but with no records selected you can't do anything and/or you get an error message.  I know I can change back to Classic view to do the edits and updates but if it doesn't work in Lightning maybe they should not dispaly the buttons (?)

Hi.

I have a custom formula set up to score our leads based on information they give us. We have an app set up that tells us the user's visit frequency, and based on that field, I want to update the lead score. Right now, I have this:

 

CASE( Visit_Frequency__c,
"1",3,
"2",4,
"3",4,
"4",4,
"5",5,
0) 

 

The only problem is that if a lead visits the site 3 times, they're getting a score of 11, where I'd like them to have a score of 4. The idea here is that the first time they visit, they should get a score of 3. The next time, their score should have a score of four (adding one). And I'd like to have the lead score increased by a maximum of 5 total for any visits above four. 

 

Can you tell me how to do this? Is it as simple as doing:

 

CASE( hubspot__Visit_Frequency__c,
"1",3,
"2",1,
"5",1,
0) 

 

Or am I missing something (I feel like I am).

 

Thanks!