• Chris Byrom
  • NEWBIE
  • 358 Points
  • Member since 2016
  • Solutions Architect
  • RealPage, Inc.


  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 79
    Replies
All,

I am trying to create my first VF page and running into an error.

So far I just have the default VF page created but trying to add a field from my custom object and getting an error.  I want to add fields from the custom object called Customer Implementation.

This is what I have

<apex:page>
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  {!CustomerImplementation__c.AccountName__c}
  This is your new Page
  <!-- End Default Content REMOVE THIS -->
</apex:page>

This is the error: Error: Unknown property 'CustomerImplementation__c.AccountName__c' referenced in CIGMilestone1

 
I am getting the current date using system.now and then trying to format my date into this format 'MM/dd/yyyy'.
 
When I log the current date is shows today (2016-08-11) which of course is correct. But, when I format the date is reflects the date as yesrterday (08/10/2016).

I am spinning my wheels. Has anyone run into this? Here is what I am doing.
 
DateTime now       = system.now().date();
String day         = now.format('dd');
String nowFormat   = now.format('MM/dd/yyyy','EST');


System.debug('Right now Date: ' + now);
System.debug('Day of the Month: ' + day);
System.debug('Full Date: ' + nowFormat);

 
I have a custom object(Opportunity_Summaries__c) which is related to an Opportunity. When the Opportunity is saved or updated I create 4 instances of this object. On the trigger I want to ensure that I delete all the custom object instances first, adn then re-cerate them if necessary. I want to futrure proof it just incase one of the records get accidently deleted etc. as I always need the 4 records.

My issue is whe I delete the existing Opportunity_Summaries__c records, the list still has 4 in, so they are never being re-created if I'm deleting them first off.
Can anyone suggest a way I get refresh the list without hitting the database again.
Any guidance would be appreciated.

Trigger:

trigger InsertOpportunitySummaries on Opportunity (after insert, after update) {
    List<Opportunity_Summary__C> oppSummariesToInsert = new List<Opportunity_Summary__C>();
    Map<id, List<Opportunity_Summary__C>> mapOfOppSummaries = new Map<id, List<Opportunity_Summary__C>>();
    
    Set<id> oppIDs = new set<id>();
    oppIDs = trigger.newMap.KeySet();
    List<Opportunity> associatedOppSummaries = [SELECT id, (SELECT id, Name, Family_Description__C, Family_Code__c, Value__c FROM Opportunities_Summaries__r) FROM Opportunity WHERE id IN: oppIDs];
    For(Opportunity opp:associatedOppSummaries){
        mapOfOppSummaries.put(opp.id,opp.Opportunities_Summaries__r);
    }
    system.debug('Start');
    system.debug('MapOfOppSummaries is empty = '+ mapOfOppSummaries.isEmpty());
    if(Trigger.IsAfter)
    {
        for(Opportunity opp:trigger.new){
            List<Opportunity_Summary__c> linkedOS = mapOfOppSummaries.get(opp.id);
            system.debug('I-Linked OS list size = '+ linkedOS.size());
            if(linkedOS.size() != 0){
                    for (Opportunity_Summary__c os:linkedOS){
                         system.debug('Deleted Linked OS ID = ' + os.Id);
                         system.debug('Deleted Linked OS Family = ' + os.Family_Description__c);
                         system.debug('Deleted Linked OS Family Code = ' + os.Family_Code__c);
                          system.debug('Deleted Linked OS Value = ' + os.Value__c);
                         database.delete(os, false);
                    }   
                }
        }
        system.debug('Is after');
        if(trigger.IsInsert){
            system.debug('Is insert');
            for(Opportunity opp: Trigger.new){
                List<Opportunity_Summary__c> linkedOS = mapOfOppSummaries.get(opp.id);
                system.debug('I-Linked OS list size = '+ linkedOS.size());
                if(linkedOS.size() == 0){
                    Opportunity_Summary__c os1 = new Opportunity_Summary__c();
                    os1.Name = 'Opp Summary 1-'+ opp.Name;
                    os1.Opportunity_Summary__c = opp.Id;
                    os1.Family_Code__c = 1;
                    os1.Family_Description__c = 'Hardware';
                    os1.Value__c = opp.Net_Hardware_Total__c;
                    oppSummariesToInsert.add(os1);
                    system.debug('I-OS1 name =' + os1.Name);
                    system.debug('I-OS1 Family code = ' + os1.Family_Code__c);
                    system.debug('I-OS1 Family Description = '+ os1.Family_Description__c);
                    system.debug('I-OS1 Value =' + opp.Net_Hardware_Total__c);
                    
                    Opportunity_Summary__c os2 = new Opportunity_Summary__c();
                    os2.Name = 'Opp Summary 2-'+ opp.Name;
                    os2.Opportunity_Summary__c = opp.Id;
                    os2.Family_Code__c = 2;
                    os2.Family_Description__c = 'Licence';
                    os2.Value__c = opp.Net_Licence_Total__c;
                    oppSummariesToInsert.add(os2);
                    system.debug('I-OS2 name =' + os2.Name);
                    system.debug('I-OS2 Family code = ' + os2.Family_Code__c);
                    system.debug('I-OS2 Family Description = '+ os2.Family_Description__c);
                    system.debug('I-OS2 Value =' + opp.Net_Licence_Total__c);
                        
                    Opportunity_Summary__c os3 = new Opportunity_Summary__c();
                    os3.Name = 'Opp Summary 3-'+ opp.Name;
                    os3.Opportunity_Summary__c = opp.Id;
                    os3.Family_Code__c = 3;
                    os3.Family_Description__c = 'Professional Services';
                    os3.Value__c = opp.Net_PS_Total__c;
                    oppSummariesToInsert.add(os3);
                    system.debug('I-OS3 name =' + os3.Name);
                    system.debug('I-OS3 Family code = ' + os3.Family_Code__c);
                    system.debug('I-OS3 Family Description = '+ os3.Family_Description__c);
                    system.debug('I-OS3 Value =' + opp.Net_PS_Total__c);
                    
                    Opportunity_Summary__c os4 = new Opportunity_Summary__c();
                    os4.Name = 'Opp Summary 4-'+ opp.Name;
                    os4.Opportunity_Summary__c = opp.Id;
                    os4.Family_Code__c = 4;
                    os4.Family_Description__c = 'Maintenance';
                    os4.Value__c = opp.Net_Maintenance_Total__c;
                    oppSummariesToInsert.add(os4);
                    system.debug('I-OS4 name =' + os4.Name);
                    system.debug('I-OS4 Family code = ' + os4.Family_Code__c);
                    system.debug('I-OS4 Family Description = '+ os4.Family_Description__c);
                    system.debug('I-OS4 Value =' + opp.Net_Maintenance_Total__c);
                    
                }
            }
        }
        
        if(trigger.isUpdate){
            system.debug('is update');
            for(Opportunity opp: Trigger.new){
               List<Opportunity_Summary__c> linkedOS = mapOfOppSummaries.get(opp.id);
               system.debug('U-Linked OS list size = '+ linkedOS.size());
                if(linkedOS.size() ==0){
                    Opportunity_Summary__c os1 = new Opportunity_Summary__c();
                    os1.Name = 'Opp Summary 1-'+ opp.Name;
                    os1.Opportunity_Summary__c = opp.Id;
                    os1.Family_Code__c = 1;
                    os1.Family_Description__c = 'Hardware';
                    os1.Value__c = opp.Net_Hardware_Total__c;
                    oppSummariesToInsert.add(os1);
                    system.debug('U-OS1 name =' + os1.Name);
                    system.debug('U-OS1 Family code = ' + os1.Family_Code__c);
                    system.debug('U-OS1 Family Description = '+ os1.Family_Description__c);
                    system.debug('U-OS1 Value =' + opp.Net_Hardware_Total__c);
                    
                    Opportunity_Summary__c os2 = new Opportunity_Summary__c();
                    os2.Name = 'Opp Summary 2-'+ opp.Name;
                    os2.Opportunity_Summary__c = opp.Id;
                    os2.Family_Code__c = 2;
                    os2.Family_Description__c = 'Licence';
                    os2.Value__c = opp.Net_Licence_Total__c;
                    oppSummariesToInsert.add(os2);
                    system.debug('U-OS2 name =' + os2.Name);
                    system.debug('U-OS2 Family code = ' + os2.Family_Code__c);
                    system.debug('U-OS2 Family Description = '+ os2.Family_Description__c);
                    system.debug('U-OS2 Value =' + opp.Net_Licence_Total__c);
                        
                    Opportunity_Summary__c os3 = new Opportunity_Summary__c();
                    os3.Name = 'Opp Summary 3-'+ opp.Name;
                    os3.Opportunity_Summary__c = opp.Id;
                    os3.Family_Code__c = 3;
                    os3.Family_Description__c = 'Professional Services';
                    os3.Value__c = opp.Net_PS_Total__c;
                    oppSummariesToInsert.add(os3);
                    system.debug('U-OS3 name =' + os3.Name);
                    system.debug('U-OS3 Family code = ' + os3.Family_Code__c);
                    system.debug('U-OS3 Family Description = '+ os3.Family_Description__c);
                    system.debug('U-OS3 Value =' + opp.Net_PS_Total__c);
                    
                    Opportunity_Summary__c os4 = new Opportunity_Summary__c();
                    os4.Name = 'Opp Summary 4-'+ opp.Name;
                    os4.Opportunity_Summary__c = opp.Id;
                    os4.Family_Code__c = 4;
                    os4.Family_Description__c = 'Maintenance';
                    os4.Value__c = opp.Net_Maintenance_Total__c;
                    oppSummariesToInsert.add(os4);
                    system.debug('U-OS4 name =' + os4.Name);
                    system.debug('U-OS4 Family code = ' + os4.Family_Code__c);
                    system.debug('U-OS4 Family Description = '+ os4.Family_Description__c);
                    system.debug('U-OS4 Value =' + opp.Net_Maintenance_Total__c);
                 } 
            }
        } 
    }
    
    system.Debug('after if statement');
        system.debug(oppSummariesToInsert.size());
        if(oppSummariesToInsert.size() >0){
            Database.upsert(oppSummariesToInsert, false);
            system.debug('os inserted');
        }

}

Many thanks
 
Scratching my head on this one.  Want to find accounts whose owner is different than its parent account. 

throws a parsing syntax  error  when i compare the 2 fields, although i can compare  them individualy..
  
Query works fine without the Where clause, just wahay too many returns to efficiently process them.

Select  Id,  OwnerId , Parent.OwnerId  From Account 
where   OwnerId  !=  Parent.OwnerId  
Visualforce page:  (Line 72 in bold below)

<apex:page standardController="Sample_Request_Account_Information__c" extensions="SampleEditPAge" tabstyle="Sample_Request_Account_Information__c" id="pg">
     <apex:form id="fm">
       <apex:pagemessages id="SampleNotAllowed"/> <!--07/20/16 MT-->
       <apex:actionFunction name="populateData" action="{!populateData}" immediate="true" reRender="se,se1,se2">
       <apex:param name="accName" assignTo="{!accName}" value=""/>
       </apex:actionFunction>
        
                <div class="bPageTitle">
                <div class="ptBody"> 
                <div class="content">
                <img src="/s.gif" alt="Sample Request Header" class="pageTitleIcon" title="Sample Request Header"/>
                <h1 class="pageType">Sample Request Header Edit<span class="titleSeparatingColon">:</span></h1>
                <h2 class="pageDescription"> New Sample Request Header</h2><div class="blank">&nbsp;</div>
                </div><div class="links">
                <a href="javascript:openPopupFocusEscapePounds(%27https://help.salesforce.com/apex/htdoor?loc=help&amp;target=co_edit.htm&amp;section=CustomObjects&amp;language=en_US&amp;release=198.12.4&amp;instance=CS7%27, %27Help%27, 1024, 768, %27width=1024,height=768,resizable=yes,toolbar=yes,status=yes,scrollbars=yes,menubar=yes,directories=no,location=yes,dependant=no%27, false, false);" title="Help for this Page (New Window)">
                <span class="helpLink">Help for this Page</span>
                <img src="/s.gif" alt="" class="helpIcon"/>
                </a></div></div>
                <div class="ptBreadcrumb">
               </div></div>  
       <apex:pageBlock title="Sample Request Header Edit" mode="edit" id="pd">    
       <apex:pageBlockButtons >
       <apex:commandButton value="Save" action="{!savesamp}"/>
       <apex:commandButton value="Save & New" action="{!saveandnew}" oncomplete="gotoNewpage();" rerender="sureid,fm"/>
       <apex:commandButton value="Cancel" action="{!Cancel}"/>
       </apex:pageBlockButtons>
            
       <apex:pageBlockSection columns="2" id="se">
                          <apex:facet name="header">
                          <span> <h3>Customer Information</h3></span>
                          <span class="pbSubExtra">
                          <span class="requiredLegend brandTertiaryFgr">
                          <span class="requiredExampleOuter">
                          <span class="requiredExample">&nbsp;</span></span>
                          <span class="requiredMark">*</span>
                          <span class="requiredText"> = Required Information</span></span></span>
                        </apex:facet>
       <apex:outputField value="{!samObj.Status__c}" id="f10"/>     
       <apex:inputField value="{!Sample_Request_Account_Information__c.Requested_Ship_From_Location__c}" id="f23"></apex:inputField>    
       <apex:inputField value="{!samObj.Planning_Account__c}" id="f1324"></apex:inputField>   
       <apex:inputField value="{!samObj.Transportation_Method__c}" id="f24"></apex:inputField> 
       <apex:inputField value="{!samObj.Account_Name__c}" required="true" onChange="var v = (document.getElementById(this.id + '_lkid')).value; populateData(v);"  id="se2"/>
       <apex:inputField value="{!samObj.Transportation_Notes__c}" id="f25"></apex:inputField> 
       <apex:inputField value="{!samObj.Contact_Name__c}" required="true" id="f20"></apex:inputField>
          <Br/>  
       <apex:inputHidden value="{!gotoNewPage}" id="sureid"/> 
          <Br/>
               
        <!-- <apex:actionRegion> -->
       <apex:inputField value="{!samObj.LCL_Address__c}"  id="f122">
       <apex:actionSupport event="onchange"  action="{!populatelcladdress}"  reRender="se"/>
       </apex:inputField>
          <Br/>
      <!--  </apex:actionRegion>-->
      
       <apex:inputField value="{!samObj.JDE_Order_Number__c}" id="f215"></apex:inputField>    
       <apex:inputcheckbox value="{!samObj.Invoice_Required__c}" id="f26"></apex:inputcheckbox> 
       <apex:outputField value="{!samObj.Ship_To_Address_Line_1__c}" id="f12"></apex:outputField>  
       <apex:inputcheckbox value="{!samObj.COA_Required__c}" id="f27"></apex:inputcheckbox> 
       <apex:outputField value="{!samObj.Ship_To_Address_Line_2__c}" id="f13"></apex:outputField> 
       <apex:inputcheckbox value="{!samObj.MSDS_Required__c}" id="f28"></apex:inputcheckbox>
       <apex:outputField value="{!samObj.Ship_To_Address_Line_3__c}" id="f14"></apex:outputField> 
       <apex:inputcheckbox value="{!samObj.Data_Sheet_Required__c}" id="fMT001"></apex:inputcheckbox> 
       <apex:outputField value="{!samObj.Ship_To_Address_Line_4__c}" id="f15"></apex:outputField>
       <apex:inputcheckbox value="{!samObj.Freight_Charge__c}" id="f248"></apex:inputcheckbox>
       <Br/>
       <apex:inputField value="{!samObj.Total_weight__c}" id="f21239"></apex:inputField>
       <apex:outputField value="{!samObj.Account_Region__c}" id="f212"></apex:outputField> 
       
       <apex:inputField value="{!samObj.Requested_Delivery_Date__c}" id="f2549"></apex:inputField> 
       <apex:outputField value="{!samObj.Ship_To_Country__c}" id="f17"></apex:outputField>
       <Br/>
       <apex:outputField value="{!samObj.Ship_To_State__c}" id="f18"></apex:outputField>
       <Br/>
       <apex:outputField value="{!samObj.Ship_To_City__c}" id="f16"></apex:outputField>
       <Br/>
       <apex:outputField value="{!samObj.Ship_To_Postal_Code__c}" id="f19"></apex:outputField>
       <apex:outputField value="{!samObj.Approvel_Date__c}" id="f29"></apex:outputField>
       <Br/>  
       <apex:inputField value="{!samObj.Customer_Reference_Number__c}" id="f31"></apex:inputField>
       <Br/>  
       <apex:inputField value="{!samObj.Other_Person_to_Notify_1__c}" id="f35"></apex:inputField>
       <Br/>
       <apex:inputField value="{!samObj.Other_Person_to_Notify_2__c}" id="f37"></apex:inputField>
       <apex:outputField value="{!samObj.CABOT_Segment__c}" id="f211"></apex:outputField>
       <Br/> 
       <apex:inputField value="{!samObj.Customer_Group__c}" id="f2112"></apex:inputField>
       <Br/> 
       <apex:inputField value="{!samObj.Senior_Approver_Name__c}" id="f2341"></apex:inputField>
       <apex:inputField value="{!samObj.Opportunity_Name__c}" id="f21"></apex:inputField>
       <apex:inputField value="{!samObj.Account_Manager__c}" id="f3221"></apex:inputField>
       <Br/>
       <apex:inputField value="{!samObj.Technical_Manager__c}" id="f33"></apex:inputField>  
      </apex:pageBlockSection>  
       
       <apex:pageBlockSection id="se1">
       <apex:inputField value="{!samObj.Notes__c}" style="width: 900px; height: 100px" id="f22"></apex:inputField>  
       </apex:pageBlockSection>  
       <apex:pageBlockSection columns="2" id="se2">
       <apex:outputField value="{!samObj.ownerId}"  id="f11" rendered="{!hasIdval}">{!$User.FirstName} {!$User.LastName}</apex:outputField>
       <apex:outputField value="{!samObj.ownerId}"  rendered="{!hasNotIdval}" id="usr"></apex:outputField> 
      
      
       <apex:outputtext value="{!samObj.OAP_Order_Number__c}" id="f39"></apex:outputtext> 
       <apex:outputtext value="{!samObj.OAP_URL_Link__c}" id="f30"></apex:outputtext> 
       </apex:pageBlockSection>  
       </apex:pageBlock>
  
</apex:form>

<script>
  function gotoNewpage()
  {
 //  window.parent.location.href = '/apex/SampleEditPAge';
   if(document.getElementById('pg:fm:pd:se:sureid') !=null)
    {
    var vals = document.getElementById('pg:fm:pd:se:sureid').value;
    if(vals == 'sure')
      window.parent.location.href = '/apex/SampleEditPAge';
    }
  }
</script>

</apex:page>
 
@RestResource(urlMapping='/v1/organizations')
global with sharing class OrganizationInfoClass {

	@HttpGet
    global static void doGet() {
    	RestResponse response = RestContext.response;

 		List<Organization> OrgList = [SELECT Id, Name, IsSandbox  FROM Organization limit 1];
 		response.statusCode = 200;
 		response.responseBody = Blob.valueOf(JSON.serialize(OrgList));
    }    
}

I wanted to get the response as XML? How should I do this?
 
@RestResource(urlMapping='/v1/organizations')
global with sharing class OrganizationInfoClass {

	@HttpGet
    global static List<Organization> doGet() {
    	RestResponse response = RestContext.response;

 		List<Organization> OrgList = [SELECT Id, Name, IsSandbox  FROM Organization limit 1];
 		return OrgList;
    }    
}

In the above snippet, the return type is List<sObject> and when I do the API request with .json at the end, I'm getting JSON response and if with .xml at the end, then I'm getting the XML response.

i.e., /services/apexrest/v1/organizations.json - Gives JSON response, 
/services/apexrest/v1/organizations.xml - gives XML response.

Why the same is not working in the first snippet (where the return type is Void and setting the response to the responseBody)?
  • July 11, 2016
  • Like
  • 0
My trigger is too agressive and I am hoping that you can help.

Goal:  Update the boolean Move_to_ProductionP__c (on Project__c) if the following criteria are true:  o.Move_to_Production__c = True and o.RecordTypeId == '012a0000001FqTn'
Problem:  The trigger updates the boolean field Move_to_Production__c on the custom Project object (this is desired)  but it also updates the boolean field on  the Opportunity field Move_to_Production__c as True upon creation of an opportunity, which is not a desired outcome.

Here is my code.  I would appreciate any help from the experts!  Thanks in advance for looking.

trigger MoveToProduction on Opportunity (before insert, before update) {   

List<ID> ProjIds = New List<ID>();   

for(Opportunity o : Trigger.new){
 if(o.Move_to_Production__c = true && o.RecordTypeId == '012a0000001FqTn')
{       ProjIds.add(o.Project__c);    
 }
  }   
List<Project__c> ProjList = [SELECT id, Move_to_ProductionP__c FROM Project__c WHERE id in :ProjIds];   for(integer i = 0 ; i < ProjList.size(); i++){     
ProjList[i].Move_to_ProductionP__c = true;     
  }
update ProjList;
}
 
Hi,

i have a trigger for account object (after insert), which will invoke a apex class from which the newly inserted (trigger.new/) data must be exported to my local machine. 
Please guide me

thanks,
Karthik S
I am using the rest API to create a new case. Nearly everything is working correctly, except that new cases are always created with Closed (IsClosed) set to true (1).

If I try to set Closed, I get INVALID_FIELD:

"body": "[{\"message\":\"No such column 'Closed' on sobject of type Case\",\"errorCode\":\"INVALID_FIELD\"}]"

If I try to set IsClosed, I get INVALID_FIELD_FOR_INSERT_UPDATE:

 "body": "[{\"message\":\"Unable to create\/update fields: IsClosed. Please check the security settings of this field and verify that it is read\/write for your profile or permission set.\",\"errorCode\":\"INVALID_FIELD_FOR_INSERT_UPDATE\",\"fields\":[\"IsClosed\"]}]"



If I do a describe on the Case object, the result includes this (IsClosed):

[18] => Array
                        (
                            [aggregatable] => 
                            [autoNumber] => 
                            [byteLength] => 0
                            [calculated] => 
                            [calculatedFormula] => 
                            [cascadeDelete] => 
                            [caseSensitive] => 
                            [controllerName] => 
                            [createable] => 
                            [custom] => 
                            [defaultValue] => 
                            [defaultValueFormula] => 
                            [defaultedOnCreate] => 1
                            [dependentPicklist] => 
                            [deprecatedAndHidden] => 
                            [digits] => 0
                            [displayLocationInDecimal] => 
                            [encrypted] => 
                            [externalId] => 
                            [extraTypeInfo] => 
                            [filterable] => 1
                            [filteredLookupInfo] => 
                            [groupable] => 1
                            [highScaleNumber] => 
                            [htmlFormatted] => 
                            [idLookup] => 
                            [inlineHelpText] => 
                            [label] => Closed
                            [length] => 0
                            [mask] => 
                            [maskType] => 
                            [name] => IsClosed
                            [nameField] => 
                            [namePointing] => 
                            [nillable] => 
                            [permissionable] => 
                            [picklistValues] => Array
                                (
                                )

                            [precision] => 0
                            [queryByDistance] => 
                            [referenceTargetField] => 
                            [referenceTo] => Array
                                (
                                )

                            [relationshipName] => 
                            [relationshipOrder] => 
                            [restrictedDelete] => 
                            [restrictedPicklist] => 
                            [scale] => 0
                            [soapType] => xsd:boolean
                            [sortable] => 1
                            [type] => boolean
                            [unique] => 
                            [updateable] => 
                            [writeRequiresMasterRead] => 
                        )


Further, if I go to the web interface and try change the value of the Status field from Closed to New, it shows up as changed (red text), but reverts when I press the Save button.

Any tips on how to create a new case, using the rest API, with a status of "New" and without setting Closed (or IsClosed)?
Hi All,
I'm having a hard time with the controller code for my visualforce Delete Button. When the user clicks the 'X', that entire row should disappear from the view, and the object should be deleted. I've been through so many wikis on the topic. You're help would be appreciated.
(I'd also like to know how to replace the 'X' with a nifty x button .png or similar)

User-added image
<apex:page controller="SockWarehouseController" tabStyle="Sock__c">
  <h1>Ocean Socks</h1>
      <apex:form >
          <apex:pageBlock title="Inventory"> 
              <apex:pageBlockSection columns="1">
                  <apex:pageBlockTable value="{!products}" var="pitem">
                        <apex:column headerValue="" >
                            <apex:commandButton action="{!deleteProduct}" value="X"/>
                        </apex:column>
                        <apex:column headerValue="Product" >                         
                            <apex:outputText value="{!pitem.Name}"/>
                        </apex:column>
                        <apex:column headerValue="Quantity">
                            <apex:outputText value="{!pitem.Quantity__c}"/>
                        </apex:column>
                         <apex:column headerValue="Price">
                            <apex:outputText value="{!pitem.Price__c}"/>
                        </apex:column>
                  </apex:pageBlockTable>
              </apex:pageBlockSection>
          </apex:pageBlock>
      </apex:form>
</apex:page>
 
public class SockWarehouseController {

    List<Sock__c> products;
    
    public List<Sock__c> getProducts() {
        if(products == null) {
           products = [SELECT id, Name, Quantity__c, Price__c FROM Sock__c];
        }
        return products;
    }
    
    public PageReference deleteProduct() {
        String socksId = ApexPages.currentPage().getParameters().get('id');
        System.debug(socksId);
        Sock__c sockObject = [Select id from Sock__c where id=:socksId];
        delete sockObject ;
        return null;
    }
}

 
Hello, 

I am trying to make an HTML table inside of a VF page sortable - but I am having some trouble. 

I am using this sample as a template: http://www.kryogenix.org/code/browser/sorttable/

And if I create a dummy page with static, dummy data this works like a charm.  Howeever if I apply this to a VF page that retruns data from a controller it doesn't work. 

When I click on a table header, the alternating "up/down" arrows appear, but the data doesn't budge.  Is there something that I need to add to my controller to make this work?

Here is my page: 
 
<script src="{!URLFOR($Resource.sorttable)}"> </script>
<meta charset="utf-8" />
<title>R2M PIPELINE</title>
<link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.GUIstyle)}" media="all" />
</head>
<body>
    <div id="header">
            <div id="logo">
                <a href="index.html"><img src="{!URLFOR($Resource.Logo)}" alt="" /></a>       
            </div>
<ul>
    <li><a href="apex/GUIHome"><span>Gene</span></a></li>
                <li><a href="/apex/HappeningNow"><span>Happening Now</span></a></li>
                <li><a href="/apex/ClientDelivery"><span>Client Delivery</span></a></li>
                <li><a href="/apex/MediaCash"><span>Media Cash</span></a></li>
                <li><a href="/apex/ROIREVENUE"><span>ROI and Revenue</span></a></li> 
                <li><a href="/apex/PRODUCTION"><span>Production</span></a></li>    
                <li><a href="/apex/SalesActivity"><span>Sales Activity</span></a></li> 
                <li><a href="/apex/PIPerformance"><span>PI Performance</span></a></li>
                <li><a href="https://na2.salesforce.com/"><span>Salesforce Home</span></a></li> 
            </ul>
  </div>
    <div id="body">
        <div class="about">
            <h1>R2M Pipeline</h1>
            <div>
            
           <c:PipelineNav />


 <apex:repeat value="{!campaigns}" var="camp">

    <apex:form >
    <apex:pageBlock title="{!camp}" mode="inlineedit">
        <table cellpadding="5" style="border-collapse: collapse;table-layout:fixed" width="1080" border="1" class="sortable" >
                
                <thead>
                <tr>
                              <th style="background-color: #C6D4D4; color: #040404" width="100">
                        <b>Opportunity Name</b>
                    </th>
                    <th style="background-color: #C6D4D4; color: #040404" width="100">
                        <b>Company Name</b>
                    </th>
                    <th style="background-color: #C6D4D4; color: #040404" width="80">
                        <b>Contract Sent</b>
                                   
                    
                    </th>
                     <th style="background-color: #C6D4D4; color: #040404" width="50">
                        <b>Days Idle</b>
                    </th>
                                 
                    <th style="background-color: #C6D4D4; color: #040404" width="70">
                        <b>Created</b>
                    </th>
        <th style="background-color: #C6D4D4; color: #040404" width="450">
                        <b>Next Step</b>
                    </th>
                  
                    <th style="background-color: #C6D4D4; color: #040404" width="50">
                        <b><apex:commandLink reRender="button" onclick="window.open('/apex/Probability_Guide','','width=500,height=300')" id="button">Prob%</apex:commandLink></b>
                    </th>
                    <th style="background-color: #C6D4D4; color: #040404" width="100">
                        <b>Owner</b>
                    </th>
                    <th style="background-color: #C6D4D4; color: #040404" width="100">
                        <b>Stage</b>
                    </th>
                
                </tr>
                </thead>
                
                 <apex:repeat value="{!Opty}" var="cs"> 
                 
                  <apex:outputPanel rendered="{!IF(camp=cs.Vert_Med__c,true,false)}" >
                  <tbody>
                      <tr>
                                  
                            <td width="100">
                                <a href="https://na2.salesforce.com/{!cs.id}">{!cs.name}</a>
                            </td>  
                              <td width="100">
                                {!cs.Company_Name__c}
                            </td> 
                                <td width="80">
                            
                               <apex:outputField value="{!cs.Contract_SENT__c}" >
                                     <apex:inlineEditSupport event="ondblclick" showOnEdit="saveButton, cancelButton" />
                                </apex:outputField>
                            </td>
                          
                           
                            <td width="50">
                                {!cs.Days_Since_Last_Modified__c}
                            </td>
                            <td width="70">
                                 {!MONTH(DATEVALUE(cs.CreatedDate))}/{!DAY(DATEVALUE(cs.CreatedDate))}/{!YEAR(DATEVALUE(cs.CreatedDate))}
                            </td>
                            
                            <td width="450">
                                <apex:outputField value="{!cs.Next_Step__c}" >
                                     <apex:inlineEditSupport event="ondblclick" showOnEdit="saveButton, cancelButton" />
                                </apex:outputField>
                            </td>
                
                           
                             <td width="50">
                                <apex:outputField value="{!cs.Probability}" >
                                     <apex:inlineEditSupport event="ondblclick" showOnEdit="saveButton, cancelButton" />
                                </apex:outputField>
                            </td>
                            <td width="100">
                                {!cs.Owner_Name__c}
                            </td>
                            <td width="100">
                                {!cs.StageName}
                            </td>
                          
                        </tr>
                     </tbody>
                      </apex:outputPanel>
                     </apex:repeat>
                     </table>
                     
                     <apex:commandButton action="{!saveOp}" value="Update Opptys"/>  
    </apex:pageBlock>
    </apex:form>
            <br/>
  </apex:repeat>
           
                          </div>
            <div>
                    
             </div>
            <div> </div>
        </div>
    </div>
         <div id="footer">
            <div>
                <div>
                    <h3></h3>
                    <ul>
                        <li></li>                
                        <li></li>
                    </ul>           
                </div>      
                <div>
                    <h3></h3>
                    <ul>
                        <li></li>                
                        <li></li>
                    </ul>           
                </div>  
                <div>
                    <h3></h3>
                    <ul>
                        <li></li>                
                        <li></li>
                    </ul>           
                </div>  
                <div>
                    <h3></h3>
                    <ul>
                        <li></li>                
                        <li></li>
                    </ul>           
                </div>  
                <div>
                    <h3>Social</h3>
                    <a class="facebook" href="https://www.facebook.com/pages/Ring2Media-INC/845391462194555" target="_blank">R2M Facebook</a>     
                    <a class="twitter" href="https://twitter.com/ring2media" target="_blank">R2M Twitter</a>
                </div>  
            </div>
            <div>
                            </div>
        </div>
        <style>

             .odd {

              background-color: #A4A4A4;

                }

             .even {

             background-color: #E6E6E6;

                }

            </style>
    </body>            
                  


</html>

And here is my controller: 
 
public with sharing class QualOpController
{

public List <Opportunity> Opty {get;set;}
public list<String> campaigns {get;set;}

public PageReference saveOp(){
    UPDATE Opty;
    return null;
    }

 public String getName(){
        return 'QualOpController';
        }

public void load() 
{
  campaigns= new List<String>();
  Opty = [Select id, name, CreatedDate, StageName, Vert_Med__c, Company_Name__c, Next_Step__c, Vertical__c, Weeks_Live__c, Days_Since_Last_Modified__c, Contract_SENT__c, NextStep, LeadSource, Probability, Spend_Last_Week__c, Spend_Last_30_Days__c, Owner_Name__c, Revenue_All_Time__c from Opportunity WHERE Pipeline_Oppty__c = TRUE ]; 
  
  Set<String> campaignSet = new Set<String>();
  for (Opportunity j : Opty)
      campaignSet.add(j.Vert_Med__c);
      
      for (String campaign : campaignSet) 
      {
            campaigns.add(campaign);
      }
      campaigns.sort();
    }
}

Is it possible to achieve what I am trying to accomplish with this method?

Thanks, 

John
Hi Everyone,

I am having trouble getting coverage for my dml exception.
 
global with sharing class ModalFlowAttachment{

    global Flow.Interview.attachmentFlow2 myflow { get; set; }
    global string varAttachmentParentId = 'init';

    global ModalFlowAttachment(){
        myflow  = new Flow.Interview.attachmentFlow2(new map<string, object>{'varAttachmentParentId'=> ''});
    }
    global string getVarAttachmentParentId() {
        if(varAttachmentParentId == 'init'){
            varAttachmentParentId = '';
            return '';
        }
        return myflow.varAttachmentParentId;
    }
    global Attachment attachment {
        get {
            if (attachment == null)
                attachment = new Attachment();
            return attachment;
        }
        set;
    }
    global PageReference upload() {

        attachment.OwnerId = UserInfo.getUserId();
        attachment.IsPrivate = True;
        attachment.parentId = getVarAttachmentParentId();
        
        
        try {
            insert attachment;
        } 
        catch (DMLException e) {
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
            return null;
        } 
        finally {
            attachment = new Attachment();
        }

        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
        varAttachmentParentId = null;
        return null;
    }
}

can anyone help me with this?

 
any help would be appreciated!

Hi,

Is it possible to test External objects on Developer edition. Making a connection to Heroku table and displaying the information on Salesforce to be able to test "External Objects" before making a decision to pay for External objets on production?
Is it possible to create a Custom Object using Rest API?

I am aware that is possible to insert , update and delete to a custom object 

 
All,

I am trying to create my first VF page and running into an error.

So far I just have the default VF page created but trying to add a field from my custom object and getting an error.  I want to add fields from the custom object called Customer Implementation.

This is what I have

<apex:page>
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  {!CustomerImplementation__c.AccountName__c}
  This is your new Page
  <!-- End Default Content REMOVE THIS -->
</apex:page>

This is the error: Error: Unknown property 'CustomerImplementation__c.AccountName__c' referenced in CIGMilestone1

 
Let's say I have a Java web server application that uses a single user server@example.com to read and write all data from an org. The username / password credentials are part of the server's configuration.

My goal is to "reuse" the same connection info / session info in that I want the best performance possible and in a thread-safe manner.

If for every request, I use all this code https://github.com/forcedotcom/wsc#write-application-code to create a new connection, I think each connection will require a login to get a session ID, before making an actual request. On the other hand, I think sharing the same object from Connector.newConnection(config) would lead to issues if I wanted to different timeouts for various requests or wanted allOrNone set for some requests but not others. I've actually been using this latter method, but now want to vary some of these parameters.

What's the best way to ensure that each SOAP API request can have its own settings like timeout or allOrNone while avoiding extra SOAP API login requests? Am I overthinking this?

One thought I had was to store connection.getConfig().getSessionId() as a static volatile variable, then create each connection with that session ID and a session renewer that would update the global if the session had to be renewed. Is that a good apporach? Is there something simpler?

Thanks!
I am getting the current date using system.now and then trying to format my date into this format 'MM/dd/yyyy'.
 
When I log the current date is shows today (2016-08-11) which of course is correct. But, when I format the date is reflects the date as yesrterday (08/10/2016).

I am spinning my wheels. Has anyone run into this? Here is what I am doing.
 
DateTime now       = system.now().date();
String day         = now.format('dd');
String nowFormat   = now.format('MM/dd/yyyy','EST');


System.debug('Right now Date: ' + now);
System.debug('Day of the Month: ' + day);
System.debug('Full Date: ' + nowFormat);

 
Hi there
I have a Salesforce site set up, with a number of pages which are accessible without authenticating, i configured this by adding the VisualForce pages to the Site and then clicking on 'Public Access Settings' and made sure that the relevant objects had read (write where required) access. 

It seems that while the object has Read access there is a field which is hidden from the Public user, in searching the forums i can see that i should be able to modify the field level accessibility for the public user in much the same way you do for a normal profile but i cannot seem to find the field level accessibility button on the Public Profile (found by going to the site and clicking on 'Public access settings'). 

How do you change, or view the field level accessibility settings for the public user for the site?

Cheers
​Dale
 
 
 

Hello, 

I have a project coming up and I am interested in finding out if salesforce can be used to tackle it. 

Basically we are building a website that enables users to join, choose between one of two types of accounts and then search our database of users for other users. 

We would use Salesforce as the backend database that saves all our user informtion once they sign up via the website. They would need to have access to their profile to update it and make amends etc. 

Also we would need to create a search page that basically quieries the salesforce database and pulls back information such as users and some of their saved information. The search would need to have a filter option to enable people searching the database to change the requirements of the search and get specific results... Ie location, skills etc. 

Is this all possible via sales force and if so is there any documentation on how to do it?

Also what languages would I need to use to achieve this? Im thinking php? 
Thanks

When a person adds a new note to an opportunity can we have a trigger that comes up once they click save, so they HAVE to create a new task?
I came across to the followin error:

Error:
This grid is not Active. Please contact your administrator.

Please advise how to be able to resolve such error.

Here is the code of the vf page:
<apex:page StandardController="Opportunity" showHeader="false" sidebar="false">
<apex:form >
<GridWiz_Unlimit:GridWizardComponent ObjectName="Opportunity" Objunique="{!Opportunity.Id}" grid="a0hD000000ENwKBIA1"/>
</apex:form>
</apex:page>

 
Hi, I have a problem with my visualforce. I would like to show a particular panel if I choose a record type, initially it works, but when I try to click save button, the records of the contract are not saved and the page remains as I left it.
Here' s my visualforce code:

<apex:page StandardController="Contract">
<apex:variable value="{!Contract.Account}" var="Account"/>
<apex:variable value="{!Contract.RecordType}" var="recordtype"/>
  <h1>Contract</h1>
  <apex:define name="Header">
         <apex:sectionHeader title="{!$ObjectType.Contract.label}" subtitle="Nuovo Contratto"/>
             <apex:form >
                <apex:inlineEditSupport event="ondblClick">
                <apex:pageBlock mode="view">
                    <apex:pageBlockButtons location="both">
                        <apex:commandButton value="Save" action="{!save}"/>
                        
                        <apex:outputPanel id="ContrattoProgettazione">
                        <apex:commandButton value="Contratto Progettazione" action="{! URLFOR($Action.Contract.Contratto_Progettazione, Id)}" rendered="{!Contract.accordo_prog__c=='Si'}"/>
                        <apex:inputField value="{!Contract.RecordTypeId}"/>
                        </apex:outputPanel>
                    </apex:pageBlockButtons>
                    <apex:actionRegion >
                 <apex:outputPanel id="Contratto_Shop" rendered="{!Contract.RecordTypeId = '01230000000EeSO'}">
                    <apex:pageBlockSection id="Shop1" columns="2" title="Dettagli Contratto Shop" >
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:outputField value="{!Contract.ContractNumber}" />
                            <apex:inputField value="{!Contract.AccountId}" required="true"/>
                            <apex:inputField value="{!Contract.Tipo__c}" required="true"/>
                            <apex:outputField value="{!Contract.agente__c}"/>
                            <apex:inputField value="{!Contract.Stato__c}" required="true"/>
                            <apex:outputField value="{!Contract.customercode__c}"/> 
                            <!--<apex:inputField value="{!Contract.Status}"/>-->
                            <apex:outputField value="{!Contract.PrimoContratto__c}"/>
                            <apex:inputField value="{!Contract.SpazioEsposizione__c}" required="true"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection id="Shop2" columns="2" title="Condizioni" >
                        <apex:inlineEditSupport event="ondblClick">
                        <apex:inputField value="{!Contract.Type__c}" required="true"/>  
                        <apex:inputField value="{!Contract.contract_sign_date__c}"/>
                        <apex:inputField value="{!Contract.discount__c}" required="true"/>
                        <apex:inputField value="{!Contract.StartDate}"/>
                        <apex:inputField value="{!Contract.ChiaviInMano__c}"/>
                        <apex:inputField value="{!Contract.endContractDate__c}"/>
                        <apex:inputField value="{!Contract.ServizioOutlet__c}"/>
                        <apex:inputField value="{!Contract.addebito_spese__c}"/>
                        <apex:inputField value="{!Contract.data_start_add_spese__c}"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection id="Shop3" columns="2" title="Budget" >
                        <apex:inlineEditSupport event="ondblClick">
                        <apex:inputField value="{!Contract.Budget_2016__c}"/>
                        <apex:inputField value="{!Contract.target_2016__c}"/>
                        <apex:inputField value="{!Contract.Budget_2017__c}"/>
                        <apex:inputField value="{!Contract.target_2017__c}"/>
                        <apex:inputField value="{!Contract.Budget_2018__c}"/>
                        <apex:inputField value="{!Contract.bdg_rinnovo_2016__c}"/>
                        <apex:inputField value="{!Contract.budget_2019__c}"/>
                        <apex:inputField value="{!Contract.rinnovo_2017__c}"/>
                        <apex:inputField value="{!Contract.sconto_prec__c}"/>  
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
               </apex:outputPanel>
               <apex:outputPanel id="Contratto_Discover" rendered="{Contract.RecordTypeId ==‘012a0000001W9qA'}">
                    <apex:pageBlockSection id="section1" columns="2" title="Dettagli Contratto Discover" >
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:inputField value="{!Contract.AccountId}"/>
                            <apex:inputField value="{!Contract.ContractNumber}" />
                            <apex:inputField value="{!Contract.Type__c}" required="true"/>
                            <apex:inputField value="{!Contract.Tipo__c}" required="true"/> 
                            <apex:inputField value="{!Contract.agente__c}"/>
                            <apex:inputField value="{!Contract.Status}" required="true"/>
                            <apex:inputField value="{!Contract.accordo_prog__c}" required="true"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
                        
                    <apex:pageBlockSection id="section2" columns="2" title="Condizioni Commerciali">
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:outputField value="{!Contract.invio_lett_intenti__c}"/>
                            <apex:outputField value="{!Contract.ricez_lettera_intenti__c}" />
                            <apex:outputField value="{!Contract.StartDate}"/> 
                            <apex:outputField value="{!Contract.endContractDate__c}" />
                            <apex:outputField value="{!Contract.discount__c}"/>
                            <apex:outputField value="{!Contract.contract_sign_date__c}"/> 
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>  
                </apex:outputPanel>    
                    
                
                   <apex:pageBlockSection id="section4" columns="2" title="Informazioni sul sistema">
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:inputField value="{!Contract.CreatedById}"/>
                            <apex:inputField value="{!Contract.LastModifiedById}"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>  
                </apex:actionRegion>
                    
                </apex:pageBlock>
                </apex:inlineEditSupport>
             </apex:form>
  </apex:define>
</apex:page>
                   
Thank you in advance!!!
I have a custom object(Opportunity_Summaries__c) which is related to an Opportunity. When the Opportunity is saved or updated I create 4 instances of this object. On the trigger I want to ensure that I delete all the custom object instances first, adn then re-cerate them if necessary. I want to futrure proof it just incase one of the records get accidently deleted etc. as I always need the 4 records.

My issue is whe I delete the existing Opportunity_Summaries__c records, the list still has 4 in, so they are never being re-created if I'm deleting them first off.
Can anyone suggest a way I get refresh the list without hitting the database again.
Any guidance would be appreciated.

Trigger:

trigger InsertOpportunitySummaries on Opportunity (after insert, after update) {
    List<Opportunity_Summary__C> oppSummariesToInsert = new List<Opportunity_Summary__C>();
    Map<id, List<Opportunity_Summary__C>> mapOfOppSummaries = new Map<id, List<Opportunity_Summary__C>>();
    
    Set<id> oppIDs = new set<id>();
    oppIDs = trigger.newMap.KeySet();
    List<Opportunity> associatedOppSummaries = [SELECT id, (SELECT id, Name, Family_Description__C, Family_Code__c, Value__c FROM Opportunities_Summaries__r) FROM Opportunity WHERE id IN: oppIDs];
    For(Opportunity opp:associatedOppSummaries){
        mapOfOppSummaries.put(opp.id,opp.Opportunities_Summaries__r);
    }
    system.debug('Start');
    system.debug('MapOfOppSummaries is empty = '+ mapOfOppSummaries.isEmpty());
    if(Trigger.IsAfter)
    {
        for(Opportunity opp:trigger.new){
            List<Opportunity_Summary__c> linkedOS = mapOfOppSummaries.get(opp.id);
            system.debug('I-Linked OS list size = '+ linkedOS.size());
            if(linkedOS.size() != 0){
                    for (Opportunity_Summary__c os:linkedOS){
                         system.debug('Deleted Linked OS ID = ' + os.Id);
                         system.debug('Deleted Linked OS Family = ' + os.Family_Description__c);
                         system.debug('Deleted Linked OS Family Code = ' + os.Family_Code__c);
                          system.debug('Deleted Linked OS Value = ' + os.Value__c);
                         database.delete(os, false);
                    }   
                }
        }
        system.debug('Is after');
        if(trigger.IsInsert){
            system.debug('Is insert');
            for(Opportunity opp: Trigger.new){
                List<Opportunity_Summary__c> linkedOS = mapOfOppSummaries.get(opp.id);
                system.debug('I-Linked OS list size = '+ linkedOS.size());
                if(linkedOS.size() == 0){
                    Opportunity_Summary__c os1 = new Opportunity_Summary__c();
                    os1.Name = 'Opp Summary 1-'+ opp.Name;
                    os1.Opportunity_Summary__c = opp.Id;
                    os1.Family_Code__c = 1;
                    os1.Family_Description__c = 'Hardware';
                    os1.Value__c = opp.Net_Hardware_Total__c;
                    oppSummariesToInsert.add(os1);
                    system.debug('I-OS1 name =' + os1.Name);
                    system.debug('I-OS1 Family code = ' + os1.Family_Code__c);
                    system.debug('I-OS1 Family Description = '+ os1.Family_Description__c);
                    system.debug('I-OS1 Value =' + opp.Net_Hardware_Total__c);
                    
                    Opportunity_Summary__c os2 = new Opportunity_Summary__c();
                    os2.Name = 'Opp Summary 2-'+ opp.Name;
                    os2.Opportunity_Summary__c = opp.Id;
                    os2.Family_Code__c = 2;
                    os2.Family_Description__c = 'Licence';
                    os2.Value__c = opp.Net_Licence_Total__c;
                    oppSummariesToInsert.add(os2);
                    system.debug('I-OS2 name =' + os2.Name);
                    system.debug('I-OS2 Family code = ' + os2.Family_Code__c);
                    system.debug('I-OS2 Family Description = '+ os2.Family_Description__c);
                    system.debug('I-OS2 Value =' + opp.Net_Licence_Total__c);
                        
                    Opportunity_Summary__c os3 = new Opportunity_Summary__c();
                    os3.Name = 'Opp Summary 3-'+ opp.Name;
                    os3.Opportunity_Summary__c = opp.Id;
                    os3.Family_Code__c = 3;
                    os3.Family_Description__c = 'Professional Services';
                    os3.Value__c = opp.Net_PS_Total__c;
                    oppSummariesToInsert.add(os3);
                    system.debug('I-OS3 name =' + os3.Name);
                    system.debug('I-OS3 Family code = ' + os3.Family_Code__c);
                    system.debug('I-OS3 Family Description = '+ os3.Family_Description__c);
                    system.debug('I-OS3 Value =' + opp.Net_PS_Total__c);
                    
                    Opportunity_Summary__c os4 = new Opportunity_Summary__c();
                    os4.Name = 'Opp Summary 4-'+ opp.Name;
                    os4.Opportunity_Summary__c = opp.Id;
                    os4.Family_Code__c = 4;
                    os4.Family_Description__c = 'Maintenance';
                    os4.Value__c = opp.Net_Maintenance_Total__c;
                    oppSummariesToInsert.add(os4);
                    system.debug('I-OS4 name =' + os4.Name);
                    system.debug('I-OS4 Family code = ' + os4.Family_Code__c);
                    system.debug('I-OS4 Family Description = '+ os4.Family_Description__c);
                    system.debug('I-OS4 Value =' + opp.Net_Maintenance_Total__c);
                    
                }
            }
        }
        
        if(trigger.isUpdate){
            system.debug('is update');
            for(Opportunity opp: Trigger.new){
               List<Opportunity_Summary__c> linkedOS = mapOfOppSummaries.get(opp.id);
               system.debug('U-Linked OS list size = '+ linkedOS.size());
                if(linkedOS.size() ==0){
                    Opportunity_Summary__c os1 = new Opportunity_Summary__c();
                    os1.Name = 'Opp Summary 1-'+ opp.Name;
                    os1.Opportunity_Summary__c = opp.Id;
                    os1.Family_Code__c = 1;
                    os1.Family_Description__c = 'Hardware';
                    os1.Value__c = opp.Net_Hardware_Total__c;
                    oppSummariesToInsert.add(os1);
                    system.debug('U-OS1 name =' + os1.Name);
                    system.debug('U-OS1 Family code = ' + os1.Family_Code__c);
                    system.debug('U-OS1 Family Description = '+ os1.Family_Description__c);
                    system.debug('U-OS1 Value =' + opp.Net_Hardware_Total__c);
                    
                    Opportunity_Summary__c os2 = new Opportunity_Summary__c();
                    os2.Name = 'Opp Summary 2-'+ opp.Name;
                    os2.Opportunity_Summary__c = opp.Id;
                    os2.Family_Code__c = 2;
                    os2.Family_Description__c = 'Licence';
                    os2.Value__c = opp.Net_Licence_Total__c;
                    oppSummariesToInsert.add(os2);
                    system.debug('U-OS2 name =' + os2.Name);
                    system.debug('U-OS2 Family code = ' + os2.Family_Code__c);
                    system.debug('U-OS2 Family Description = '+ os2.Family_Description__c);
                    system.debug('U-OS2 Value =' + opp.Net_Licence_Total__c);
                        
                    Opportunity_Summary__c os3 = new Opportunity_Summary__c();
                    os3.Name = 'Opp Summary 3-'+ opp.Name;
                    os3.Opportunity_Summary__c = opp.Id;
                    os3.Family_Code__c = 3;
                    os3.Family_Description__c = 'Professional Services';
                    os3.Value__c = opp.Net_PS_Total__c;
                    oppSummariesToInsert.add(os3);
                    system.debug('U-OS3 name =' + os3.Name);
                    system.debug('U-OS3 Family code = ' + os3.Family_Code__c);
                    system.debug('U-OS3 Family Description = '+ os3.Family_Description__c);
                    system.debug('U-OS3 Value =' + opp.Net_PS_Total__c);
                    
                    Opportunity_Summary__c os4 = new Opportunity_Summary__c();
                    os4.Name = 'Opp Summary 4-'+ opp.Name;
                    os4.Opportunity_Summary__c = opp.Id;
                    os4.Family_Code__c = 4;
                    os4.Family_Description__c = 'Maintenance';
                    os4.Value__c = opp.Net_Maintenance_Total__c;
                    oppSummariesToInsert.add(os4);
                    system.debug('U-OS4 name =' + os4.Name);
                    system.debug('U-OS4 Family code = ' + os4.Family_Code__c);
                    system.debug('U-OS4 Family Description = '+ os4.Family_Description__c);
                    system.debug('U-OS4 Value =' + opp.Net_Maintenance_Total__c);
                 } 
            }
        } 
    }
    
    system.Debug('after if statement');
        system.debug(oppSummariesToInsert.size());
        if(oppSummariesToInsert.size() >0){
            Database.upsert(oppSummariesToInsert, false);
            system.debug('os inserted');
        }

}

Many thanks
 
HI,

I have a trigger on Cases that populates the Contact lookup field by using two fields (Concat_Id__c) in each object as a reference. The logic for this works, however as we have thousands of contact records, I am getting the error message: Non-selective query against large object type (more than 200000 rows)

I have read that using a @future class is a good workaround but have never come across them before.

Woud anyone be able to show me how to use this with my trigger?

Trigger:
trigger UpdateContact on Case (before update) {

for (Case createdCase : Trigger.New) {
            if(createdCase.SuppliedEmail!=null) {
            Case[] Cases = [Select Id,concat_ID__c,SuppliedEmail from Case where SuppliedEmail != Null];
           
                //look for a Contact that matches the email address
                Account[] AccountsMatched = [Select Id,concat_ID__c,PersonEmail, Name from Account where concat_ID__c =:createdCase.concat_ID__c  LIMIT 1];
                //if we found a match, use it
                if (AccountsMatched.size()>0) {
                    createdCase.Contactid = AccountsMatched[0].Id;
                
               }
               
          }
     }
  }

 

This is an informational posting since I couldn't find it documented anywhere:

 

If a report is in a folder, the OwnerID of the report corresponds to the ID of the folder object, so you can query a report folder's contents like this:

 

 

folder[] ff = [select id from folder where developername = 'Community_Inventory_Tool_Reports'];
id fid = (ff.isEmpty()) ? null : ff[0].id;
report[] rpts = [select id, name, description from report where ownerid = : fid and ownerid != null order by name];
return (rpts.isEmpty() == null) ? null : rpts;