• surya kanadhipatla
  • NEWBIE
  • 189 Points
  • Member since 2014

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 8
    Questions
  • 48
    Replies
Hello friends,

probably you are used to looking a bunch of dumb questions or newbie questions, and here goes another one, 
What does the highlighted line means ? I mean I don't understand the structure, why does {get; set;} do in these context ?.

Thanks for your help, David.

User-added image
I need to write  a validation rule on the Quote Line Item that if my formula field "Product" contains some letter for example "ABC". Then it is required to mention the reason in the "Reason" field on the Quote Line Item.  Please help me guys.
Hello,

I have created an email tamplete which is available for use.
Then I have created an Email Alert with following values:
Description: Thank you
Unique Name: Thank_You_Eamil

in Process Builder I have selected "Eamil Alerts" and Thank_You_Eamil for Email Alert Field, but I get an Error message and the Email Alert cannot be recogonized.
any help is apperciated

User-added image,

User-added image
 
whenever a lead is coming i need to populate it ? how it is possible in salesforce
I'm trying to set a custom Opportunity lookup field Sales Rep, which is a lookup to a custom Obj for Sales Reps, to the Opportunity Owner. Pretty new to triggers and would really appreciate any help. Here is where I'm at so far -
trigger SalesRepTrigger on Opportunity (after insert, after update) {
   
     if (trigger.isAfter) {
        if (trigger.isUpdate || trigger.isInsert) {
            
            Opportunity ops = new Opportunity();
            
            //get opporunity that triggered
            Set<ID> Ids = new set<id>();
            
            for(Opportunity o : Trigger.new){
               ids.add(o.Sales_Rep__c);
            }
            
            //get CC_Sales_Rep__c ids and store in Map
            //Map<Id, Id> RepMap = new Map<Id, Id>();
            
            Map<Id, CC_Sales_Rep__c> salesRep = new Map<id, CC_Sales_Rep__c>([Select id, OwnerId FROM CC_Sales_Rep__c
                                              Where CC_Sales_Rep__c =:ids]);
 
            //for(CC_Sales_Rep__c sr : salesRep) {
            //    RepMap.put(sr.Id, sr.OwnerId);
            //}
            
            //Get Opportunity Record Types
            Map<ID,Schema.RecordTypeInfo> rt_Map = Opportunity.sObjectType.getDescribe().getRecordTypeInfosById();
 
            for(Opportunity o : Trigger.new){
                //Only apply trigger to a certain record type
                if(rt_map.get(o.recordTypeID).getName().containsIgnoreCase('xxxx xxxx')){ 
                    ops.Sales_Rep__c = SalesRep.get(o.Sales_Rep__c).OwnerId;
 
                }
            }
         update ops;
        }
}
}
Hi All, Good afternoon...

We have implemented a trigger to associate case team memebers to a case created via communities..
This trigger works fine for internal users but when users with community user profile creates a case its throws following error:
Op:Insert|Type:CaseTeamMember|Rows:1
System.DmlException: Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []
I have verified community user profile does have read/write access to case object and able to create the cases as well.
Even tried without sharing key word still exception.Observed the exception when caseteammember is inserted.
If i comment out the insert caseteammemebr line in trigger helper class no exception and case was created without case team members...

Any Help will be appreaciated...
Hi All,
We have implemented a trigger to associate case team memebers to a case created via community user.
This trigger works fine for internal users but when users with community user profile creates a case its throws following error:
Op:Insert|Type:CaseTeamMember|Rows:1
System.DmlException: Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []

I have verified community user profile does have read/write access to case object and able to create the cases as well.
Even tried without sharing key word still exception.Observed the exception when caseteammember is inserted.
If i comment out the insert caseteammemebr line in trigger helper class no exception and case was created without case team members...

Any Help will be appreaciated...
 Hi All...

I have a multiselect field Production_Region__c contains values A,B,C,D and E.

Using process builder have to create a new record if Production_Region__c field value does not contain value D.
For example: If user selects values A and D , process should not create any new record
If any one or more values(A,B,C and E) except value D is selected, process should create a new record

can any one suggest me some approach?
Hi All...

I have a multiselect field Production_Region__c contains values A,B,C,D and E.

I have to create a record if the Production_Region__c field does not contain value D.
If user selects values A and D , process should not create any new record


can any one suggest me any approach?


 
Hi all, i have used the Vf page and controller to split the values of a single filed into multiple columns.

The issue is each name is getting diplayed 3 times on the page. But if i use Set insted a List i'm able to eliminate the duplicates.

Please see the below code and let me know where exactly the issue is(i guess the issue is inside the for loop but could not sort it out
Note: i'm using custom settings object and retrieving the values to display them on page with a name and checkbox
VF page: 
	<apex:pageBlockTable value="{!MyWrappers}" var="wrap" id="pgtbl">
   <apex:column width="100px">
 <apex:inputCheckBox value="{!wrap.checkbox1}"/>
 <apex:outputField value="{!wrap.mySec1.name}"/>
    </apex:column>
 <apex:column width="100px">
   <apex:inputCheckBox value="{!wrap.checkbox2}"/>
    <apex:outputField value="{!wrap.mySec2.name}"/>
 </apex:column>
 <apex:column width="100px">
   <apex:inputCheckBox value="{!wrap.checkbox3}"/>
   <apex:outputField value="{!wrap.mySec3.name}"/> 
 </apex:column>
</apex:pageBlockTable>

Controller code:
public with class Controller {
Public  List<MyWrapper> myWrappers{get; set;}

public class MyWrapper
 {
    public Boolean checkbox1{get;set;}
    public Boolean checkbox2{get;set;}
    public Boolean checkbox3 {get;set;}
    public Custom_settings_Object__c myLead1{get;set;} 
    public Custom_settings_Object__c myLead2{get;set;}
    public Custom_settings_Object__c myLead3{get;set;}
    
 }     
    public pagereference initiallds()----calling this action from page component
    {     
  myWrappers=new List<MyWrapper>();
  Integer idx=0;
  MyWrapper wrap;      
    for(Custom_settings_Object__c ld: Custom_settings_Object__c.getall().values())   
    {               
      if (Math.mod(idx, 3)==0)
       {   
          wrap =  new MyWrapper();
           wrap.myLead1=ld; 
           
       }
      if (Math.mod(idx, 3)==1)
       {
          wrap.myLead2=ld;
      
       }
   if (Math.mod(idx, 3)==2)
       {           
       wrap.myLead3=ld;
           
       }           
          ++idx;        
          myWrappers.add(wrap);
                }    
return null;
    }
	}



 
I created a roll up smmary field to calclate the sum of detail record values whose created date is today().

Every day we create detail records so want to roll up the records whose created date is only today. (records which are created from 12:AM to 11:59 PM). I cold not use created date is eqal to today in filter criteria while creating the roll up summary fields.

Please help:

 
I have created snapshot cstom object and configured sorce report colmns to snapshot report fields.

I want to move this mapping to stage from sandbox,but i could not see them on eclipse.

or can i directly map them manualy once deployed to production?
 
We are calculating resource productivity and I have attached the screenshot for your reference.

I was able to calculate productivity session wise as well as date wise(per day) but resource wise:

Productivity session wise = Total Author duration/available duration in office for that session(pre lunch)= (2/3.5)*100 = 57.14%(row 4, column F in screenshot)(used formula field in object to calculate this)--- I was able to do this

Productivity date wise(per day) = average Total Author duration per day/Sum of available duration in office = 3/(3.5+4.5+0.5+0)=23.53%(row 3, column H in screenshot)(used formula functions on the report)--)--- I was able to do this

I got stuck while calculating Below values:
Productivity per resource =average of Productivity date wise(per day) =23.53(for date 5/15/2015)+33.33(for date 5/16/2015)+8.33(for date 5/17/2015)/3(number of days)=21.75%

or
if the below is pssible, it would be fine

Productivity per resource = sum of average Total Author Duration per day/Sum of available duration in office=2( (Author average duration for date 5/15/2015)+ 4(Author average duration for date 5/16/2015) + 1(Author average duration for date 5/17/2015)/=3.5+4.5+0.5+0.0+4.0+6.0+0.5+1.5+4.0+6.0+0.5+1.5(column E)=21.53%

Since I have used formula functions on the sanpshot report for calculating Productivity date wise(per day), I'm not able to re use or reference them in other formula functions

The source report I'm using is a tabular, since I want the sessions on snapshot I could not use summary report as a sourceScreenshot

Your help is much appreciated:
sorry for the lengthy explanation :)
Hello,

Is it possible to store picklist value as a separate variables in visualflow? If so, please help! 

thank you! 
  • November 18, 2016
  • Like
  • 0
Hi All,

Just so I'm clear, I am not a developer. I can kind of read it and make small changes, but trying to learn to write it gives me a headache.

I have a vf page that was created for me, but when a Save is done it is saving all fields instead of just the fields that were edited. This is causing issues of data being deleted because the change was made in a record and not on the vf page. I hope that made sense. 

Here is the page and controller. I do hope that someone can help with a small change to this code and a whole new page doesn't have to be created.
I cannot paste all code with the limit of 32,000 characters.

<apex:page controller="MyOpenTasksController">
    <apex:includeScript value="{!$Resource.JS_Busy_Indicator}"/>
    <script>
        function showFilterData(){
            filterData();
        }
        function setUser(){
            setUser();
        }
        var xval;
        function block_viewport() {
            xval=getBusyOverlay('viewport',{color:'black', opacity:0.35, text:'processing...', style:'text-shadow: 0 0 3px black;font-weight:bold;font-size:12px;color:white'},{color:'#fff', size:75, type:'o'});
        }
    </script>
    <apex:form id="frm">
    
    <apex:actionFunction name="filterData" action="{!filterTaskData}" reRender="frm,pgBlock" oncomplete="xval.remove();"/>
    <apex:actionFunction name="setUser" action="{!setCurrentUser}" reRender="frm,pgBlock" oncomplete="xval.remove();"/>
    
    <apex:pageBlock title="My Open Tasks" id="pgBlock">
    
    
        <apex:pageBlockButtons >
            <apex:commandButton onclick="block_viewport();" oncomplete="xval.remove();" value="Update To Tomorrow" action="{!updateToTomorrow}" reRender="frm,pgBlock" disabled="{!Not(taskList.size > 0)}"/>
            <apex:commandButton onclick="block_viewport();" oncomplete="xval.remove();" value="Save" action="{!saveChanges}" reRender="frm,pgBlock" disabled="{!Not(taskList.size > 0)}"/>            
            <apex:commandButton onclick="block_viewport();" oncomplete="xval.remove();" value="Cancel" action="{!cancelChanges}" reRender="frm,pgBlock" disabled="{!Not(taskList.size > 0)}"/>
        </apex:pageBlockButtons>
        <br/>
        <apex:outputPanel >
            
            
Controller:
public with sharing class MyOpenTasksController {

    public String eventObject { get; set; }
    public Integer recordsSize {get;set;}
    public Integer totalNumberOfPages { get; set; }
    public Integer pageNumber {get;set;}
    public Boolean hasNext {get;set;}
    public Boolean hasPrevious {get;set;}
    
    public List<SelectOption> contactAttendeeList{get;set;}
    public List<SelectOption> mailingStateList{get;set;}
    public List<SelectOption> activeUsersList{get;set;}
    public Id selectedUserId {get;set;}
    public boolean showUserPicklist {get;set;}
    public String selectedAttendee{get;set;}
    public String selectedState{get;set;}
    public string selectedPriority {get;set;}
    public string selectedTimezone {get;set;}
    
    public List<Task> taskList {get;set;}
    
    private List<Id> taskListWithAllRecords;
    private Integer noOfRecordsPerPage = 50;
    
    public MyOpenTasksController(){
        activeUsersList = new List<SelectOption>();
        
        showUserPicklist = false;
        for(User_Information__c usrInfo : User_Information__c.getAll().values()){
            if(usrInfo.User_Id__c == String.valueOf(UserInfo.getUserId()).substring(0,15)){
                showUserPicklist = true;
            }
        }
        selectedUserId = UserInfo.getUserId();
        activeUsersList.add(new SelectOption(UserInfo.getUserId(),'Current User'));
        for(User usr : [Select Id, Name from User where IsActive = true]){
            if(usr.id != UserInfo.getUserId()){
                activeUsersList.add(new SelectOption(usr.Id,usr.Name));
            }
        }
        populateSelectOptions();
        populateTaskData();
    }
    
    private void populateTaskData(){
        recordsSize = 0;
        totalNumberOfPages = 0;
        pageNumber = 0;
        hasNext = false;
        hasPrevious = false;
        
        //taskList = new List<Task>();
        taskListWithAllRecords = new List<Id>();
        // String Query to have a list of cases for a respective End-user.
        //String soql = 'Select ActivityDate, Status, Priority, Atendee__c, Dummy_Contact__c, WhatId,Dummy_Contact__r.Name,What.Name, Description, Dummy_Contact__r.Title, Dummy_Contact__r.Key_Exec__c, Dummy_Contact__r.Exec_Type__c, Dummy_Contact__r.Direct_Dial__c, Dummy_Contact__r.MobilePhone, Dummy_Contact__r.Phone, Dummy_Contact__r.MailingState, Dummy_Contact__r.Timezone__c, Dummy_Contact__r.Task_Attendee__c from Task where IsClosed = false AND OwnerID =:selectedUserId';
        
        String soql = 'Select id from Task where IsClosed = false AND OwnerID =:selectedUserId';
        if(selectedPriority == null && selectedTimezone == null  && selectedAttendee == null  && selectedState == null){
            
        }
        else if (selectedPriority != null && selectedTimezone == null  && selectedAttendee == null  && selectedState == null){
            soql = soql + ' AND Priority = :selectedPriority '; 
        }
        else if(selectedPriority == null && selectedTimezone != null  && selectedAttendee == null  && selectedState == null){
            soql = soql + ' AND Dummy_Contact__r.Timezone__c = :selectedTimezone '; 
        }
        else if(selectedPriority == null && selectedTimezone == null  && selectedAttendee != null  && selectedState == null){
            soql = soql + ' AND Attendee__c = :selectedAttendee '; 
        }
        else if(selectedPriority == null && selectedTimezone == null  && selectedAttendee == null  && selectedState != null){
            soql = soql + ' AND Dummy_Contact__r.MailingState = :selectedState '; 
        }
        else if(selectedPriority != null && selectedTimezone != null  && selectedAttendee == null  && selectedState == null){
            soql = soql + ' AND Priority = :selectedPriority AND Dummy_Contact__r.Timezone__c = :selectedTimezone '; 
        }
        else if(selectedPriority == null && selectedTimezone != null  && selectedAttendee != null  && selectedState == null){
            soql = soql + ' AND Dummy_Contact__r.Timezone__c = :selectedTimezone AND Attendee__c = :selectedAttendee '; 
        }
        else if(selectedPriority != null && selectedTimezone == null  && selectedAttendee != null  && selectedState == null){
            soql = soql + ' AND Priority = :selectedPriority AND Attendee__c = :selectedAttendee ';
        }
        else if(selectedPriority != null && selectedTimezone == null  && selectedAttendee == null  && selectedState != null){
            soql = soql + ' AND Priority = :selectedPriority AND Dummy_Contact__r.MailingState = :selectedState ';
        }
        else if(selectedPriority == null && selectedTimezone != null  && selectedAttendee == null  && selectedState != null){
            soql = soql + ' AND Dummy_Contact__r.Timezone__c = :selectedTimezone AND Dummy_Contact__r.MailingState = :selectedState ';
        }
        else if(selectedPriority == null && selectedTimezone == null  && selectedAttendee != null  && selectedState != null){
            soql = soql + ' AND Attendee__c = :selectedAttendee AND Dummy_Contact__r.MailingState = :selectedState ';
        }
        else if(selectedPriority != null && selectedTimezone != null  && selectedAttendee != null  && selectedState == null){
            soql = soql + ' AND Priority = :selectedPriority AND Dummy_Contact__r.Timezone__c = :selectedTimezone AND Attendee__c = :selectedAttendee ';
        }
        else if(selectedPriority != null && selectedTimezone != null  && selectedAttendee == null  && selectedState != null){
            soql = soql + ' AND Priority = :selectedPriority AND Dummy_Contact__r.Timezone__c = :selectedTimezone AND Dummy_Contact__r.MailingState = :selectedState ';
        }
        else if(selectedPriority != null && selectedTimezone == null  && selectedAttendee != null  && selectedState != null){
            soql = soql + ' AND Priority = :selectedPriority AND Attendee__c = :selectedAttendee AND Dummy_Contact__r.MailingState = :selectedState ';
        }
        else if(selectedPriority == null && selectedTimezone != null  && selectedAttendee != null  && selectedState != null){
            soql = soql + ' AND Dummy_Contact__r.Timezone__c = :selectedTimezone AND Attendee__c = :selectedAttendee AND Dummy_Contact__r.MailingState = :selectedState ';
        }
        else{
            soql = soql + ' AND Priority = :selectedPriority AND Dummy_Contact__r.Timezone__c = :selectedTimezone AND Attendee__c = :selectedAttendee AND Dummy_Contact__r.MailingState = :selectedState ';
        }
        
        // Passing the String array to a list with Selected field sorting.
        for(Task tsk : Database.query(soql + ' order by ' + sortExpression + ' ' + sortDirection  + ' NULLS LAST')){
            taskListWithAllRecords.add(tsk.id);
        }
        
        recordsSize = taskListWithAllRecords.size();
        if(Math.mod(recordsSize,noOfRecordsPerPage) != 0){
            totalNumberOfPages = (recordsSize / noOfRecordsPerPage) + 1;
        }
        else{
            totalNumberOfPages = recordsSize / noOfRecordsPerPage;
        }
        Set<Id> taskIds = new Set<Id>();
        if(recordsSize > noOfRecordsPerPage){
            for(Integer i=pageNumber*noOfRecordsPerPage ; i<noOfRecordsPerPage ; i++){
                taskIds.add(taskListWithAllRecords[i]);
            }
            hasNext = true;
        }
        else{
            taskIds.addAll(taskListWithAllRecords);
        }
        pageNumber++;
        
        String soqlQuery = 'Select ActivityDate, Status, Priority, Attendee__c, Dummy_Contact__c, WhatId,Dummy_Contact__r.Name,What.Name, Description, Dummy_Contact__r.Title, Dummy_Contact__r.Key_Exec__c, Dummy_Contact__r.Exec_Type__c, Dummy_Contact__r.Direct_Dial__c, Dummy_Contact__r.MobilePhone, Dummy_Contact__r.Phone, Dummy_Contact__r.MailingState, Dummy_Contact__r.Timezone__c, Dummy_Contact__r.Attendee_Contact__c, Dummy_Contact__r.Task_Attendee__c from Task where Id In :taskIds order by ' + sortExpression + ' ' + sortDirection  + ' NULLS LAST';
        taskList = new List<Task>();
        taskList = Database.query(soqlQuery);
    }
    
    private void populateSelectOptions(){
        contactAttendeeList = new List<SelectOption>();
        contactAttendeeList.add(new SelectOption('','---None---'));
        
        mailingStateList = new List<SelectOption>();
        mailingStateList.add(new SelectOption('','---None---'));
        Set<String> setOfAttendee = new Set<String>();
        Set<String> setOfStates = new Set<String>();
        for(Task tsk : [Select Attendee__c,Dummy_Contact__r.Task_Attendee__c, Dummy_Contact__r.MailingState from Task where IsClosed = false AND OwnerID =:selectedUserId]){
            if(tsk.Attendee__c != null){
                setOfAttendee.add(tsk.Attendee__c);
            }
            if(tsk.Dummy_Contact__r.MailingState != null){
                setOfStates.add(tsk.Dummy_Contact__r.MailingState);
            }
        }
        if(setOfAttendee.size() > 0){
            List<String> sortedListOfAttendee = new List<String>();
            sortedListOfAttendee.addAll(setOfAttendee);
            sortedListOfAttendee.sort();
            for(String attendee : sortedListOfAttendee){
                contactAttendeeList.add(new SelectOption(attendee,attendee));
            }
        }
        if(setOfStates.size() > 0){
            List<String> sortedListOfStates = new List<String>();
            sortedListOfStates.addAll(setOfStates);
            sortedListOfStates.sort();
            for(String state : sortedListOfStates){
                mailingStateList.add(new SelectOption(state, state ));
            }
        }
    }
    
    // returns the previous page of records
    public void previous() {
        hasNext = true;
        //taskList = new List<Task>();
        Set<Id> taskIds = new Set<Id>();
        pageNumber--;
        for(Integer i= (pageNumber-1)*noOfRecordsPerPage; i<noOfRecordsPerPage*pageNumber ; i++){
            taskIds.add(taskListWithAllRecords[i]);
        }
        if(pageNumber > 1){
            hasPrevious = true;
        }
        else{
            hasPrevious = false;
        }
        
        String soqlQuery = 'Select ActivityDate, Status, Priority, Attendee__c, Dummy_Contact__c, WhatId,Dummy_Contact__r.Name,What.Name, Description, Dummy_Contact__r.Title, Dummy_Contact__r.Key_Exec__c, Dummy_Contact__r.Exec_Type__c, Dummy_Contact__r.Direct_Dial__c, Dummy_Contact__r.MobilePhone, Dummy_Contact__r.Phone, Dummy_Contact__r.MailingState, Dummy_Contact__r.Timezone__c, Dummy_Contact__r.Attendee_Contact__c, Dummy_Contact__r.Task_Attendee__c from Task where Id In :taskIds order by ' + sortExpression + ' ' + sortDirection  + ' NULLS LAST';
        taskList = new List<Task>();
        taskList = Database.query(soqlQuery);
    }

    // returns the next page of records
    public void next() {
        hasPrevious = true;
        //taskList = new List<Task>();
        Set<Id> taskIds = new Set<Id>();
        if((pageNumber+1)*noOfRecordsPerPage < taskListWithAllRecords.size()){
            for(Integer i = pageNumber*noOfRecordsPerPage ; i<(pageNumber+1)*noOfRecordsPerPage ;i++){
                taskIds.add(taskListWithAllRecords[i]);
            }
        }
        else{
            for(Integer i=pageNumber*noOfRecordsPerPage ; i<recordsSize ;i++){
                taskIds.add(taskListWithAllRecords[i]);
            }
            hasNext = false;
        }
        pageNumber++;
        
        String soqlQuery = 'Select ActivityDate, Status, Priority, Attendee__c, Dummy_Contact__c, WhatId,Dummy_Contact__r.Name,What.Name, Description, Dummy_Contact__r.Title, Dummy_Contact__r.Key_Exec__c, Dummy_Contact__r.Exec_Type__c, Dummy_Contact__r.Direct_Dial__c, Dummy_Contact__r.MobilePhone, Dummy_Contact__r.Phone, Dummy_Contact__r.MailingState, Dummy_Contact__r.Timezone__c, Dummy_Contact__r.Attendee_Contact__c, Dummy_Contact__r.Task_Attendee__c from Task where Id In :taskIds order by ' + sortExpression + ' ' + sortDirection  + ' NULLS LAST';
        taskList = new List<Task>();
        taskList = Database.query(soqlQuery);
    }
    
    public void sortData() {
        // simply toggle the direction
        sortDirection = sortDirection.equals('asc') ? 'desc' : 'asc';

        populateTaskData();
    }
    
    // the current sort direction. defaults to asc
    public String sortDirection {
        // To set a Direction either in ascending order or descending order.
        get  { if (sortDirection == null) {  sortDirection = 'asc'; } return sortDirection;}
        set;
    }

    // the current field to sort by. defaults to last name
    public String sortExpression {
        // To set a Field for sorting.
        get  { if (sortExpression == null) {sortExpression = 'ActivityDate'; } return sortExpression;  }
        set;
    } 
    
    public PageReference filterTaskData() {
        populateTaskData();
        return null;
    }
    
    public PageReference updateToTomorrow() {
        DateTime dateToBeChanged = system.Today().addDays(1);
        
        Datetime dt = DateTime.newInstance(System.today(), Time.newInstance(0, 0, 0, 0));
        String dayOfWeek=dt.format('EEEE');
        
        if(dayOfWeek == 'Friday'){
            dateToBeChanged = system.Today().addDays(3);
        }
        else if(dayOfWeek == 'Saturday'){
            dateToBeChanged = system.Today().addDays(2);
        }
        List<Task> listOfTaskToUpdate = new List<Task>();
        for(Task tsk : [Select ActivityDate from Task where IsClosed = false AND OwnerID =:selectedUserId]){
            if(tsk.ActivityDate <= system.today()){
                tsk.ActivityDate = Date.valueOf(dateToBeChanged);
                listOfTaskToUpdate.add(tsk);
            }
        }
        
        if(listOfTaskToUpdate.size() > 0){
            update listOfTaskToUpdate;
        }
        return null;
    }
    
    public PageReference cancelChanges() {
        return null;
    }
    
    public PageReference saveChanges() {
        Set<Id> conIds = new Set<Id>();
        Set<Contact> setOfContacts = new Set<Contact>();
        List<Contact> listOfContactToUpdate = new List<Contact>();
        
        for(Task tsk : taskList){
            if(tsk.Dummy_Contact__c != null){
                conIds.add(tsk.Dummy_Contact__c);
            }
        }
        for(Contact con : [Select Name,Title, Key_Exec__c, Exec_Type__c, Direct_Dial__c, MobilePhone, Phone, MailingState, Timezone__c, Attendee_Contact__c, Task_Attendee__c from Contact where id in :conIds]){
            for(Task tsk : taskList){
                if(tsk.Dummy_Contact__c == con.id){
                    con.Title = tsk.Dummy_Contact__r.Title;
                    con.Key_Exec__c = tsk.Dummy_Contact__r.Key_Exec__c;
                    con.Exec_Type__c = tsk.Dummy_Contact__r.Exec_Type__c;
                    con.Direct_Dial__c = tsk.Dummy_Contact__r.Direct_Dial__c;
                    con.MobilePhone = tsk.Dummy_Contact__r.MobilePhone;
                    con.Phone = tsk.Dummy_Contact__r.Phone;
                    con.MailingState = tsk.Dummy_Contact__r.MailingState;
                    con.Timezone__c = tsk.Dummy_Contact__r.Timezone__c;
                    setOfContacts.add(con);
                }
            }
        }
        if(setOfContacts.size() > 0){
            listOfContactToUpdate.addAll(setOfContacts);
            update listOfContactToUpdate;
        }
        
        if(taskList.size() > 0){
            update taskList;
        }
        return null;
    }
    public PageReference setCurrentUser() {
        populateSelectOptions();
        populateTaskData();
        return null;
    }
}
Hello friends,

probably you are used to looking a bunch of dumb questions or newbie questions, and here goes another one, 
What does the highlighted line means ? I mean I don't understand the structure, why does {get; set;} do in these context ?.

Thanks for your help, David.

User-added image
Hi, 

 Below is the trigger which is working fine in sandbox when i deploy it is giving me below error from test class please suggest me how to fix this issue

ApprovalUtils_Test_New
System.LimitException: Too many SOQL queries: 101 
Stack Trace: Class.ApprovalUtils.GetSubscripItem: line 273, column 1 Trigger.GenQuoteApproval: line 67, column 1
 
trigger GenQuoteApproval on QuoteLineItem (After Insert, After Update,After Delete) {

  Decimal LineMaxDiscount;
  Decimal LineMaxACV;
  Decimal SubLineMaxDiscount;
  Decimal SubLineMaxACV;
  Decimal SerLineMaxDiscount;
  Decimal SerLineMaxACV;
  Decimal TraLineMaxDiscount;
  Decimal TraLineMaxACV;
  Map<ID, Quote> ParentQuote = new Map<ID, Quote>();
  String SALREPID;
  String MRGID;
  String SALID;
  String CFOID;
  String SERID;
  String TRAID;
  String Level;
  Integer GSublevel1Count;
  Integer GSublevel2Count;
  Integer GSublevel3Count;
  Integer GSublevel4Count;
  Integer GSerlevel1Count;
  Integer GSerlevel2Count;
  Integer GSerlevel3Count;
  Decimal SubscriptionTerm;
  Integer GTralevel1Count;
  Integer GTralevel2Count;
  Integer GTralevel3Count;
 

 
Try 
{
if ( Trigger.isAfter)
  {
 List<Id> listIds = new List<Id>();
 //Set<Id> listIds = new Set<Id>();

 List<Quote> QuotetList = new List<Quote>();

 /* Get Quote ID */
 for (QuoteLineItem childquoteline :  Trigger.new)
 {
        listIds.add(childquoteline.QuoteId);
    }
 
   
 ParentQuote = new Map<Id, Quote>([SELECT id,Level_1__c,Level_2__c,Level_3__c,Level_4__c,Level_5_Service__c,Level_6_Training__c FROM Quote WHERE ID IN :listIds]);
 
  /* Get service list of all quote id */
   list<QuoteLineItem> serqtlne = ApprovalUtils.GetServiceItem(listIds);
   
  //  [select id  from  QuoteLineItem
   //   where quoteid in :listIds and
   //   product2.Productcode  like 'CBSVC%'];
   
  list<id> serviceid = new list<id>();
  for(QuoteLineItem getserviceid : serqtlne )
   {
      serviceid.add(getserviceid.id);

   }


  /* Get subscription list of all quote id */
    list<QuoteLineItem> subqtlne = ApprovalUtils.GetSubscripItem(listIds);
    
   // [select id  from  QuoteLineItem
   //  where quoteid in :listIds and
   //  Subscription_Terms__c <> 0];
      
    
                                     
  list<id> subscriptionid = new list<id>();
  for(QuoteLineItem getsubscriptionid :  subqtlne )
   {
      subscriptionid.add(getsubscriptionid.id);

   }

 /* Subscription Discount and ACV */
    List<AggregateResult> MaxSubscription = [select max(Discount_Percent__c) SubQuoteLineMaxDiscount,sum(f_ACV__c) SubQuoteLineMaxACV
                                                   from  QuoteLineItem
                                                   where quoteid in :listIds and Subscription_Terms__c <> 0 and
                                                         ID not in :serviceid
                                                 ];

  for (AggregateResult SubQuoteMaxDiscount : MaxSubscription)
  {
  SubLineMaxDiscount = (Decimal)SubQuoteMaxDiscount.get('SubQuoteLineMaxDiscount');
  SubLineMaxACV = (Decimal)SubQuoteMaxDiscount.get('SubQuoteLineMaxACV');
  }

   system.debug('Subscription Line Discount  :' + SubLineMaxDiscount);
   system.debug('Subscription Line ACV  :' + SubLineMaxACV);

   /* Service Discount and ACV */
  List<AggregateResult> MaxService = [select max(Discount_Percent__c) SerQuoteLineMaxDiscount,SUM(f_ACV__c) SerQuoteLineMaxACV
                                      from  QuoteLineItem
                                      where quoteid in :listIds and product2.Productcode  like 'CBSVC%' and
                                            id not in :subscriptionid];

  for (AggregateResult SerQuoteMaxDiscount : MaxService)
  {
  SerLineMaxDiscount = (Decimal)SerQuoteMaxDiscount.get('SerQuoteLineMaxDiscount');
  SerLineMaxACV = (Decimal)SerQuoteMaxDiscount.get('SerQuoteLineMaxACV');
  }

   system.debug('Service Line Discount  :' + SerLineMaxDiscount);
   system.debug('Service Line ACV  :' + SerLineMaxACV);
   
   
   /* Training Discount and ACV */
  List<AggregateResult> MaxTraining = [select max(Discount_Percent__c) TraQuoteLineMaxDiscount,SUM(f_ACV__c) TraQuoteLineMaxACV
                                      from  QuoteLineItem
                                      where quoteid in :listIds and product2.Productcode  like 'T%' and
                                            id not in :subscriptionid and id not in :subscriptionid];

  for (AggregateResult TraQuoteMaxDiscount : MaxTraining)
  {
  TraLineMaxDiscount = (Decimal)TraQuoteMaxDiscount.get('TraQuoteLineMaxDiscount');
  TraLineMaxACV = (Decimal)TraQuoteMaxDiscount.get('TraQuoteLineMaxACV');
  }

   system.debug('Training Line Discount  :' + TraLineMaxDiscount);
   system.debug('Training Line ACV  :' + TraLineMaxACV);
   

  Opportunity Opp = [select ownerid
                    from opportunity
                    where
                    id in (select OpportunityId from quote where id in :listIds) ];

  system.debug(listIds);
  
  SubscriptionTerm = ApprovalUtils.GetSubscriptionTerm(listIds);
  

  system.debug('Get New Subscription Term' + SubscriptionTerm);
  
  /* Get Manager ID */
  User Usr = [select managerid from user where id = :opp.ownerid];

 /* Subscription Query to get level 1..4 values */
   if ( SubscriptionTerm != null &&
        SubLineMaxACV != null &&
        SubLineMaxDiscount != null)
   {
       GSublevel1Count = ApprovalUtils.SubLevel1(SubscriptionTerm , SubLineMaxACV , SubLineMaxDiscount);

       system.debug('Subscription Level1 :' + GSublevel1Count);

       GSublevel2Count = ApprovalUtils.SubLevel2(SubscriptionTerm , SubLineMaxACV , SubLineMaxDiscount);

       system.debug('Subscription Level2 :' + GSublevel2Count);

       GSublevel3Count = ApprovalUtils.SubLevel3(SubscriptionTerm , SubLineMaxACV , SubLineMaxDiscount);

       system.debug('Subscription Level3 :' + GSublevel3Count);

       GSublevel4Count = ApprovalUtils.SubLevel4(SubscriptionTerm , SubLineMaxACV , SubLineMaxDiscount);

       system.debug('Subscription Level4 :' + GSublevel4Count);

        
   }    
   
      /* Service Query to get level 1..4 values */
   if (SerLineMaxACV != null && SerLineMaxDiscount != null)
    {
       GSerlevel1Count = ApprovalUtils.SerLevel1(SerLineMaxACV,SerLineMaxDiscount);

       system.debug('Service Level1 :' + GSerlevel1Count);

        GSerlevel2Count = ApprovalUtils.SerLevel2(SerLineMaxACV,SerLineMaxDiscount);

       system.debug('Service Level2 :' + GSerlevel2Count);

        GSerlevel3Count = ApprovalUtils.SerLevel3(SerLineMaxACV,SerLineMaxDiscount);

       system.debug('Service Level3 :' + GSerlevel3Count);
    } 
    
        /* Training Query to get level 1..4 values */
   if (TraLineMaxACV != null && TraLineMaxDiscount != null)
    {
        GTralevel1Count = ApprovalUtils.TraLevel1(TraLineMaxACV,TraLineMaxDiscount);
        system.debug('Training Level1 :' + GTralevel1Count);
        
        GTralevel2Count = ApprovalUtils.TraLevel2(TraLineMaxACV,TraLineMaxDiscount);
        system.debug('Training Level2 :' + GTralevel2Count);
        
        GTralevel3Count = ApprovalUtils.TraLevel3(TraLineMaxACV,TraLineMaxDiscount);
        system.debug('Training Level3 :' + GTralevel3Count);
    }
    
     If( GSublevel1Count >= 1  || GSerlevel1Count >= 1  || GTralevel1Count >= 1)
     {
      SALREPID = Opp.OwnerId;
      }   
     
     
    If (GSublevel2Count >= 1 || GSerlevel2Count >= 1  || GTralevel2Count >= 1)
    {
      SALREPID = NULL;
      MRGID = Usr.managerid;
    }
 
    /* Future here you may have to change for amount > 1000000 if its going only to SVP */
   If ( GSublevel3Count >= 1 || GSerlevel3Count >= 1 ||  GTralevel3Count >= 1)
      {
      SALREPID = NULL;
      MRGID = Usr.managerid;
      SALID = '00580000007jaoA';
      }
   
    /* Assign this to Pete */ 
    If ( GTralevel3Count >= 1)
    {
     TRAID = '00580000006GbpI';
     }
    else
    {
     TRAID = NULL;
     }  
     
     /* Asssing to asif */
    If ( GSerlevel3Count >= 1)
    {
     SERID = '0053400000839zg';
     }
    else
    {
     SERID = NULL;
     } 
      
    If ( GSublevel4Count >= 1 )
    {
    SALREPID = NULL;
    MRGID = Usr.managerid;
    SALID = '00580000007jaoA';
    CFOID = '00534000008oOCr';
    Level = '4sub';
    }  
  
    //system.debug('Which Level :' + Level);
    system.debug('Sales Rep :' + SALREPID);
    system.debug('Manager :' + MRGID);
    system.debug('Sales Ops :' + SALID);
    system.debug('CEO CFO :'  + CFOID);
    system.debug('Service:' + SERID);
    system.debug('Training:' + TRAID);
 
  
for (QuoteLineItem gqtl : Trigger.new)
 {
   Quote MyParentQuote = ParentQuote.get(gqtl.QuoteId);

    MyParentQuote.Level_1__c = SALREPID;
    MyParentQuote.Level_2__c=MRGID;
    MyParentQuote.Level_3__c=SALID;
    MyParentQuote.Level_4__c=CFOID;
    MyParentQuote.Level_5_Service__c = SERID;
    MyParentQuote.Level_6_Training__c = TRAID;
 
  }

  update ParentQuote.values();
  

 }
  
}

catch(Exception e) {
    System.debug('The following exception has occurred: ' + e.getMessage());    
}
  
}

Below is the helper class 
public with sharing class ApprovalUtils {

  /* Subscription Discount Level 1 */
  public static Integer SubLevel1(Decimal Subscription, Decimal ACV, Decimal Discount) {
    
   Integer L1Count;  
    
   List<AggregateResult> Level1 = [select count(id) Level1Count
              from Discount_Schedule_Matrix__c
              where
              Type__c = 'Subscription' and 
              Subscription_Term__c = :Subscription and
              ACV_Lower__c <= :ACV  and ACV_Upper__c >= :ACV and
              Sales_Rep_Lower__c <= :Discount and Sales_Rep_Upper__c >= :Discount];
              
              
    for (AggregateResult arLevel1 : Level1)
     {
       L1Count = ((Integer)arLevel1.get('Level1Count'));
       
     }         
                                     
    return L1Count;
  }
  
   /* Subscription Discount Level 2 */
   public static Integer SubLevel2(Decimal Subscription, Decimal ACV, Decimal Discount) {
    
   Integer L2Count;  
   
   List<AggregateResult> Level2 = [select count(id) Level2Count
              from Discount_Schedule_Matrix__c
              where
              Type__c = 'Subscription' and 
              Subscription_Term__c = :Subscription and
              ACV_Lower__c <= :ACV  and ACV_Upper__c >= :ACV and
              Direct_Manager_Lower__c <= :Discount and Direct_Manager_Upper__c >= :Discount];
              
              
    for (AggregateResult arLevel2 : Level2)
     {
      L2Count = ((Integer)arLevel2.get('Level2Count'));  
     }        
                                      
    return L2Count;
  }
  
   /* Subscription Discount Level 3 */
   public static Integer SubLevel3(Decimal Subscription, Decimal ACV, Decimal Discount) {
    
   Integer L3Count;  
   
   List<AggregateResult> Level3 = [select count(id) Level3Count
              from Discount_Schedule_Matrix__c
              where
              Type__c = 'Subscription' and 
              Subscription_Term__c = :Subscription and
              ACV_Lower__c <= :ACV  and ACV_Upper__c >= :ACV and
              SVP_Lower__c <= :Discount and SVP_Upper__c >= :Discount];
              
              
    for (AggregateResult arLevel3 : Level3)
     {
      L3Count = ((Integer)arLevel3.get('Level3Count'));
     }        
                                      
    return L3Count;
  }
  
  /* Subscription Discount Level 4 */
  public static Integer SubLevel4(Decimal Subscription, Decimal ACV, Decimal Discount) {
    
   Integer L4Count;  

   List<AggregateResult> Level4 = [select count(id) Level4Count
              from Discount_Schedule_Matrix__c
              where
              Type__c = 'Subscription' and 
              Subscription_Term__c = :Subscription and
              ACV_Lower__c <= :ACV  and ACV_Upper__c >= :ACV and
              CEO_CFO__c <= :Discount and CEO_CFO_Upper__c >= :Discount];
              
              
    for (AggregateResult arLevel4 : Level4)
     {
      L4Count = ((Integer)arLevel4.get('Level4Count'));
     }        
                                      
    return L4Count;
  }
  
  /* Service Discount Level 1 */
  public static Integer SerLevel1(Decimal ACV,Decimal Discount) {
    
   Integer L1Count;  
   
   List<AggregateResult> Level1 = [select count(id) Level1Count
              from Discount_Schedule_Matrix__c
              where
              Type__c = 'Services' and 
              Subscription_Term__c = 1 and
              ACV_Lower__c <= :ACV  and ACV_Upper__c >= :ACV and
              Sales_Rep_Lower__c <= :Discount and Sales_Rep_Upper__c >= :Discount];
              
              
    for (AggregateResult arLevel1 : Level1)
     {
      L1Count = ((Integer)arLevel1.get('Level1Count'));
     }        
                                      
    return L1Count;
  }
  
  /* Service Discount Level 2 */
    public static Integer SerLevel2(Decimal ACV,Decimal Discount) {
    
   Integer L2Count;  
   
   List<AggregateResult> Level2 = [select count(id) Level2Count
              from Discount_Schedule_Matrix__c
              where
              Type__c = 'Services' and 
              Subscription_Term__c = 1 and
              ACV_Lower__c <= :ACV  and ACV_Upper__c >= :ACV and
              Direct_Manager_Lower__c <= :Discount and Direct_Manager_Upper__c >= :Discount];
              
              
    for (AggregateResult arLevel2 : Level2)
     {
      L2Count = ((Integer)arLevel2.get('Level2Count'));
     }        
                                      
    return L2Count;
  }


  /* Service Discount Level 3 */
    public static Integer SerLevel3(Decimal ACV,Decimal Discount) {
    
   Integer L3Count;  
   
   List<AggregateResult> Level3 = [select count(id) Level3Count
              from Discount_Schedule_Matrix__c
              where
              Type__c = 'Services' and 
              Subscription_Term__c = 1 and
              ACV_Lower__c <= :ACV  and ACV_Upper__c >= :ACV and
              SVP_Lower__c <= :Discount and SVP_Upper__c >= :Discount];
              
              
    for (AggregateResult arLevel3 : Level3)
     {
      L3Count = ((Integer)arLevel3.get('Level3Count'));
     }        
                                      
    return L3Count;
  }
 
 
   /* Training Discount Level 1 */
  public static Integer TraLevel1(Decimal ACV,Decimal Discount) {
    
   Integer L1Count;  
   
   List<AggregateResult> Level1 = [select count(id) Level1Count
              from Discount_Schedule_Matrix__c
              where
              Type__c = 'Training' and 
              Subscription_Term__c = 1 and
              ACV_Lower__c <= :ACV  and ACV_Upper__c >= :ACV and
              Sales_Rep_Lower__c <= :Discount and Sales_Rep_Upper__c >= :Discount];
              
              
    for (AggregateResult arLevel1 : Level1)
     {
      L1Count = ((Integer)arLevel1.get('Level1Count'));
     }        
                                      
    return L1Count;
  }
 
 
   /* Training Discount Level 2 */
    public static Integer TraLevel2(Decimal ACV,Decimal Discount) {
    
   Integer L2Count;  
   
   List<AggregateResult> Level2 = [select count(id) Level2Count
              from Discount_Schedule_Matrix__c
              where
              Type__c = 'Training' and 
              Subscription_Term__c = 1 and
              ACV_Lower__c <= :ACV  and ACV_Upper__c >= :ACV and
              Direct_Manager_Lower__c <= :Discount and Direct_Manager_Upper__c >= :Discount];
              
              
    for (AggregateResult arLevel2 : Level2)
     {
      L2Count = ((Integer)arLevel2.get('Level2Count'));
     }        
                                      
    return L2Count;
  }
  
  
   /* Training Discount Level 3 */
   public static Integer TraLevel3(Decimal ACV,Decimal Discount) {
    
   Integer L3Count;  
   
   List<AggregateResult> Level3 = [select count(id) Level3Count
              from Discount_Schedule_Matrix__c
              where
              Type__c = 'Training' and 
              Subscription_Term__c = 1 and
              ACV_Lower__c <= :ACV  and ACV_Upper__c >= :ACV and
              SVP_Lower__c <= :Discount and SVP_Upper__c >= :Discount];
              
              
    for (AggregateResult arLevel3 : Level3)
     {
      L3Count = ((Integer)arLevel3.get('Level3Count'));
     }        
                                      
    return L3Count;
  }
  
  
    /* Service Discount Level 3 */
    public static Decimal GetSubscriptionTerm(list<Id> Quoteid) {
     
     Decimal SubscriptionTerm;
     
    /* Get Subscription Term */ 
    List<AggregateResult> MaxSubscrioptionYear = [select max(f_Approval_Subscription_Years__c) QSubscriptionYear 
                                                  from QuoteLineItem where quoteid in :Quoteid]; 
  
    
    for (AggregateResult GetSubscriptionYear : MaxSubscrioptionYear)
    { 
     SubscriptionTerm = (Decimal)GetSubscriptionYear.get('QSubscriptionYear');
      }
 
       return SubscriptionTerm;
    }
    
    
    public static List<QuoteLineItem> GetServiceItem(list<Id> listIds){
    
     list<QuoteLineItem> serqtlne = new list<QuoteLineItem>();
     Try
     {
     /* Get service list of all quote id */
      serqtlne = [select id  from  QuoteLineItem
                                     where quoteid in :listIds and
                                           product2.Productcode  like 'CBSVC%'];
      }
      catch(Exception ex)
     {
      System.debug(ex);

      }                                       
     
     return serqtlne;
     
     }
    
     public static List<QuoteLineItem> GetSubscripItem(list<Id> listIds){
      list<QuoteLineItem> subqtlne = new list<QuoteLineItem>();
     try
     {
     /* Get service list of all quote id */
      subqtlne = [select id  from  QuoteLineItem
                                     where quoteid in :listIds and
                                           Subscription_Terms__c <> 0];
                                           
                                             
      }
     catch(Exception ex)
     {
      System.debug(ex);
      system.debug('============='+ex.getMessage());
      system.debug('============='+ex.getLineNumber());
      system.debug('============='+ex.getStackTraceString());
      }                                       
     
     return subqtlne;
     
     }
       
}





Below is the Test class
@IsTest(seeAllData=true)
private class ApprovalUtils_Test_New{
    @isTest(SeeAllData=true) // required for using the standard pricebook, unfortunately
    private static void ApprovalUtilsTest() {
    
     test.StartTest();
     
                 ApprovalUtils.SubLevel1(1,0,0);
                 ApprovalUtils.SubLevel2(1,0,10);
                 ApprovalUtils.SubLevel3(1,0,11);
                 ApprovalUtils.SubLevel4(1,0,41);
               
                 ApprovalUtils.SerLevel1(1,1);
                 ApprovalUtils.SerLevel2(1,10);
                 ApprovalUtils.SerLevel3(1,41);
                 
                 ApprovalUtils.TraLevel1(1,1);
                 ApprovalUtils.TraLevel2(1,10);
                 ApprovalUtils.TraLevel3(1,41);
                 
                 
        Account a = new Account(Name = 'Test Account');
        insert a;

        Opportunity o = new Opportunity(Name = 'Test Opp', StageName = 'Test Stage', CloseDate = Date.today(), AccountId = a.Id);
        insert o;

        Pricebook2 pb = [select Id from Pricebook2 where IsStandard = true limit 1];

        Product2 p = new Product2(Name = 'CBSVC', isActive = true);
        insert p;

        PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = p.Id, UnitPrice = 1, isActive = true);
        insert pbe;

        Quote q = new Quote(Name = 'Test Quote', OpportunityId = o.Id, PriceBook2Id = pb.Id);
        insert q;

        QuoteLineItem qli = new QuoteLineItem(
            QuoteId = q.Id, 
            PriceBookEntryId = pbe.Id, 
            Quantity = 1, 
            UnitPrice = 500,
            Discount_Percent__c = 0,
            Subscription_Terms__c = 1,
            Number_of_Nodes__c = 10
            );
        insert qli;
        
        /* Training */
        Product2 pt = new Product2(Name = 'T', isActive = true);
        insert pt;

        PricebookEntry pbet = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = pt.Id, UnitPrice = 1, isActive = true);
        insert pbet;

        Quote qt = new Quote(Name = 'Test Quote', OpportunityId = o.Id, PriceBook2Id = pb.Id);
        insert qt;

        QuoteLineItem qlit = new QuoteLineItem(
            QuoteId = q.Id, 
            PriceBookEntryId = pbet.Id, 
            Quantity = 1, 
            UnitPrice = 500,
            Discount_Percent__c = 10,
            Subscription_Terms__c = 1,
            Number_of_Nodes__c = 10
            );
        insert qlit;
        
       test.StopTest(); 
                     
    }
     
    }


 
  • November 17, 2016
  • Like
  • 0
I need to write  a validation rule on the Quote Line Item that if my formula field "Product" contains some letter for example "ABC". Then it is required to mention the reason in the "Reason" field on the Quote Line Item.  Please help me guys.
What should be done to override the governor limit that restricts you from fetching more than 50,000 records in a SOQL query ?
I have created two classes and a test class to test these classes. The test class creates an Opportunity object and populates a few fields. It continues to pass the id of the opportunity to the class being tested. When a SOQL query is run with the pass Id, none of the other fields included in the SOQL query are being populated.

Here is the test class:
@isTest
public class TestGatewayBalancer {
    @isTest public static void AssignGatewayWithLowestRatio() {
        Opportunity opp = new Opportunity(Name = 'Test', StageName = 'New', CloseDate = Date.Today());
        opp.ChargentSFA__Charge_amount__c = 100;
        Database.insert(opp);
    System.debug(loggingLevel.ERROR, '=> Opp being passed from test to upfront class: ' + opp);

        Test.StartTest();
        UpfrontGatewayBalancer.manualCharge(opp.Id);
        Test.StopTest();

        System.assertEquals(gateway.Id, opp.ChargentSFA__Gateway__c, 'The gateway is incorrect.');
    }

The class that is being tested:
global with sharing class UpfrontGatewayBalancer {
    webService static Boolean manualCharge(Id oppID) {
        Opportunity opp = [SELECT Id, ChargentSFA__Gateway__c, ChargentSFA__Charge_Amount__c FROM Opportunity WHERE Id = :oppID];
        //Find and assign appropriate gateway
        System.debug(loggingLevel.ERROR, '=> Opp being passed from upfront to the handler class: ' + opp);
        GatewayLoadBalancerUtility.OpportunityHandler(opp);
        //Check if gateway was assigned before returning
        if(opp.ChargentSFA__Gateway__c == null) {
            return false;
        }
        else {
            return true;
        }
    }

And the messages I get in the execution log are the following:
13:10:25:909 USER_DEBUG [26]|ERROR|=> Opp being passed from test to upfront class: Opportunity:{Name=Test, StageName=New, CloseDate=2016-11-14 00:00:00, ChargentSFA__Charge_Amount__c=100, Id=00655000007bmnWAAQ}

13:10:26:005 USER_DEBUG [14]|ERROR|=> Opp being passed from upfront to the handler class: Opportunity:{Id=00655000007bmnWAAQ}

So clearly the object has those fields getting set in the test class, but they aren't pulled down from the SOQL query in the class being tested. If anybody has any ideas as to what's going on here I would appreciate the help.
 

This may be a limitation but I would like to confirm that OR find an alternative solution.

I have created a Visualforce page to be used as the Generic Error Page in my site.  However, when an error occurs on the site while being viewed by a Site Guest User instead of displaying my error page the "Authorization Required Page (401)" is displayed.

When a user is logged in (such as then the site is used for a community) then the correct generic error page is displayed.

The same actaully happens when using the default "Exception" page so it is not related to my own Visualforce error page.

Is this a limitation?  Can generic error page only be displayed to logged in users?  If so, any ideas on how to create a similar experience for guest users?

Thanks in advance.
 

Derek 

Hi,

I need to show a list of those leads on which any task or call is created. I have wrote the following query but it is not working.

Select Id, Name from Lead where Id IN (SELECT Who.Id FROM Task where Who.Type='Lead') limit 10

Can anyone help me?

Thanks,
Rohitash
I'm trying to set a custom Opportunity lookup field Sales Rep, which is a lookup to a custom Obj for Sales Reps, to the Opportunity Owner. Pretty new to triggers and would really appreciate any help. Here is where I'm at so far -
trigger SalesRepTrigger on Opportunity (after insert, after update) {
   
     if (trigger.isAfter) {
        if (trigger.isUpdate || trigger.isInsert) {
            
            Opportunity ops = new Opportunity();
            
            //get opporunity that triggered
            Set<ID> Ids = new set<id>();
            
            for(Opportunity o : Trigger.new){
               ids.add(o.Sales_Rep__c);
            }
            
            //get CC_Sales_Rep__c ids and store in Map
            //Map<Id, Id> RepMap = new Map<Id, Id>();
            
            Map<Id, CC_Sales_Rep__c> salesRep = new Map<id, CC_Sales_Rep__c>([Select id, OwnerId FROM CC_Sales_Rep__c
                                              Where CC_Sales_Rep__c =:ids]);
 
            //for(CC_Sales_Rep__c sr : salesRep) {
            //    RepMap.put(sr.Id, sr.OwnerId);
            //}
            
            //Get Opportunity Record Types
            Map<ID,Schema.RecordTypeInfo> rt_Map = Opportunity.sObjectType.getDescribe().getRecordTypeInfosById();
 
            for(Opportunity o : Trigger.new){
                //Only apply trigger to a certain record type
                if(rt_map.get(o.recordTypeID).getName().containsIgnoreCase('xxxx xxxx')){ 
                    ops.Sales_Rep__c = SalesRep.get(o.Sales_Rep__c).OwnerId;
 
                }
            }
         update ops;
        }
}
}

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.