• Alain Cabon
  • ALL STAR
  • 9916 Points
  • Member since 2016

  • Chatter
    Feed
  • 317
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 2014
    Replies
There is no option in classic or lightning setup to enable knowledge :

User-added image
I want to generate a consistent number or rows in  a table regardless of how many related objects exists (i.e. I want 7 rows even when there is only 3 related list objects).

I was trying to use a repeat without a value attribute to try to just create a generic looping behavior but that does not work.  I am using a standard controller and didn't want to create an extension just to generate the other rows.  Here is the code...
 
<apex:variable var="rowNum" value="{!1}"/>
			<apex:repeat var="f" value="{!sow__c.Facilities__r}" rows="7">  
                <apex:variable var="rowNum" value="{!rowNum + 1}"/>
            	<div class="row">
                <div class="col-7">
                    <div class="row">
                        <div class="bodycell col-4">
                            <span>{!f.Account__r.Name}</span>
                        </div>
                        
                        <div class="bodycell center col-2">
                            <span>
                                <apex:outputText value="{0, number, 0}">
                                    <apex:Param value="{!f.v1__c}" />
                                </apex:outputText>                                
                            </span>
                        </div>
                        
                        <div class="bodycell center col-2">
                            <span>
                                <apex:outputText value="{0, number, 0}">
                                    <apex:Param value="{!f.v2__c}" />
                                </apex:outputText> 
                            </span>
                        </div>
                        
                        <div class="bodycell col-4">
                            <span>{!f.v3__c}</span>
                        </div>
                    </div>
                </div>
                
                <div class="bodycell col-5">
                    <span>{!f.v4__c}</span>
                </div>
            </div>
            </apex:repeat>
            <apex:repeat var="f" rows="{!(7 - rowNum)}">
            	<div class="row">
                <div class="col-7">
                    <div class="row">
                        <div class="bodycell col-4">
                            <span>&nbsp;</span>
                        </div>
                        
                        <div class="bodycell col-2">
                            <span>&nbsp;</span>
                        </div>
                        
                        <div class="bodycell col-2">
                            <span>&nbsp;</span>
                        </div>
                        
                        <div class="bodycell col-4">
                            <span>&nbsp;</span>
                        </div>
                    </div>
                </div>
                
                <div class="bodycell col-5">
                    <span>&nbsp;</span>
                </div>
            </div>
            </apex:repeat>

This does't work and I have scowered google with not resolution, any help would be greatly appreciated.
I am getting an error when trying to do a sfdx retrieve:
ERROR:  Cannot read property 'fileName' of undefined.

Here is the command that is being issued in VS Code when I click on the package.xml file and retrive source from org:
sfdx force:source:retrieve --manifest c:\_hilton\BossReno\manifest\package.xml

The development environment is Salesforce Spring 2019
Here is my version of sfdx:
sfdx-cli/6.53.0-67a9cbb60c (windows-x64) node-v8.9.4


This package.xml file was generated by VS Code extension.  Here it is:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<types>
<members>*</members>
<name>ApexComponent</name>
</types>
<types>
<members>*</members>
<name>ApexPage</name>
</types>
<types>
<members>*</members>
<name>ApexTestSuite</name>
</types>
<types>
<members>*</members>
<name>ApexTrigger</name>
</types>
<types>
<members>*</members>
<name>AuraDefinitionBundle</name>
</types>
<types>
<members>*</members>
<name>StaticResource</name>
</types>
<version>45.0</version>
</Package>

Hi everyone, can you help me with a rule?

I have a validation rule with 6 level, and I can't to jump this steps, except to the last step(closed). For exemplo: Step 1 to 2 or step 1 to 6 , but step 1 to 3 or 1 to 4 can not. Look how is my code now.

AND
(
    RecordType.DeveloperName = 'test',
    CASE(Status, 
        "step 1",1,
        "step 2",2,
        "step 3",3,
        "step 4",4,
        "step 5",5,
        "Closed 6",6,
    0) 
    !=  
        (CASE(PRIORVALUE(Status), 
        "step 1",1,
        "step 2",2,
        "step 3",3,
        "step 4",4,          
        "step 5",5,
        "Closed 6",6,
    0) + 1)
)

I am trying to convert a CMD field from Text to LongTextArea and it appears that you can't convert CMD fields once they are defined. Is this true and if so, why?
 
If I have a text field on an object, I can convert it to LongTextArea, but the same conversion on a CMD object does not appear to be possible. I am not finding any documentation that says I can't do this, but apparently I can't. Has anybody seen where it is documented that this is *not* possible? Without being able to convert the field (since the CMD being used in a SFDX package), it looks like it will take creating a new field, updating all of the code the references the old field, and then deleting the original field unless somebody else has another idea?
For example:

Input value = 3
then output = 0003

Input value = 64
then output = 0064

Input value = 3269
then output = 3269

Is this possible?
Hi guys, 

I have configured PMD to run with ANT, however I am struggling to write custom rules. I am working with the standard rules which sourceforge provides. Has anyone written custom rules for apex in PMD? 

Thanks for your time.
Hello,

New to Salesforce, and am learning Apex web services.
Assume there is no source-driven development in our team, and developers write their own web services through console, how can I get the whole list of existing Apex web services, any utilities or I have to open each Apex class to figure out?

Thanks.
Hi,

I have a datatable, and I need a text column with hiperlink to the reference object.
I want a similar table to a standard list view, the name of the column record is a hiperlink of the record page

Example:
List view of a record:
User-added image

Datatable with a colum type url
User-added image

Datatable with a colum type text
User-added image

Code:
cmp.set('v.columns', [
            {label: 'Recurso', fieldName: 'Name', type: 'url', sortable: true, editable:'true', initialWidth: 120},
        ]);

Thanks
HI I'm trying top traverse an XML tree to get the Items Tag list. I was using iterative but the problem is that it seems that I can only get the lst item but I don;t get them all. Can someone p0leaswe help me?  Thanks Here's the tree:
 
<Shipment id="103052074"> 
    <ClientName>Awana</ClientName> 
    <OrderID>01061767</OrderID> 
    <PurchaseOrder /> 
    <Name>SILVIA GIBSON</Name> 
    <FirstName>SILVIA</FirstName> 
    <LastName>GIBSON</LastName> 
    <Company /> 
    <Address1>11900 TRADITION LN NE </Address1> 
    <Address2 /> 
    <City>ALBUQUERQUE</City> 
    <State>NM</State> 
    <PostalCode>87111-8287</PostalCode> 
    <Country>UNITED STATES</Country> 
    <Email>silviagibson@mailinator.com</Email> 
    <Phone /> 
    <OrderTimestamp>2019-01-18T00:00:00</OrderTimestamp> 
    <ReceivedTimestamp>2019-01-18T13:59:26.007</ReceivedTimestamp> 
    <ShipmentStatus>SHIPPED</ShipmentStatus> 
    <OrderType>Consumer</OrderType> 
    <ShippedDate>2019-01-18T14:16:37.550</ShippedDate> 
    <ExpectedDeliveryDate>2019-01-18T00:00:00</ExpectedDeliveryDate> <DeliveredTimestamp /> <DeliveryException />             
    <Warehouse id="160"> 
       <Name>Greenwood, IN</Name> 
       <Address>1415 Collins Rd.</Address> 
       <City>Greenwood</City> 
       <State>IN</State> 
       <PostalCode>46143</PostalCode> 
       <Country>US</Country> 
    </Warehouse> 
    <ShipMethod>Newgistics Parcel Select</ShipMethod> 
    <ShipMethodCode>NGSPS</ShipMethodCode> 
    <Tracking>9200000000000629213249</Tracking>                  <TrackingUrl>http://shipment.co/tracking/2817/9200000000000629213249</TrackingUrl> 
     <Weight>4.000000</Weight> 
     <Postage /> 
     <GiftWrap>false</GiftWrap> 
     <CustomFields> 
         <BillingAddress1>1620 N Penny Ln</BillingAddress1> 
         <BillingCity>Schaumburg</BillingCity> 
         <BillingCompany>Cherry Hills Community Church</BillingCompany> 
         <BillingCountry>United States</BillingCountry> 
         <BillingEmail>silviagibson@mailinator.com</BillingEmail> 
         <BillingFirstName>Heather</BillingFirstName> 
         <BillingLastName>Oliver</BillingLastName> 
         <BillingPhone>(866) 292-6227</BillingPhone> 
         <BillingState>IL</BillingState> 
          <BillingZip>60173</BillingZip> 
           <Shipping>17.87</Shipping> 
           <Total>190.52</Total> 
      </CustomFields> 
      <BackorderedItems /> 
      <Items> 
         <Item id="1807577"> 
               <SKU>94900</SKU> 
                <UPC /> 
                 <Description>Cubbies AppleSeed Handbook Music CD NIV</Description> 
                <Lot /> 
                <Qty>2</Qty> 
               <CustomFields /> 
               <AssemblyItems /> 
       </Item> 
      <Item id="1807606"> 
             <SKU>96543</SKU> 
             <UPC /> 
             <Description>Cubbies HoneyComb Teaching Plans NKJV</Description> 
             <Lot /> 
             <Qty>1</Qty> 
             <CustomFields />  
             <AssemblyItems /> 
      </Item> 
      <Item id="1807670"> 
           <SKU>96918</SKU> 
           <UPC /> 
           <Description>Game Pin (4)</Description> 
           <Lot /> 
           <Qty>4</Qty> 
           <CustomFields /> 
           <AssemblyItems /> 
     </Item> 
        <Item id="1807691"> 
          <SKU>46421</SKU> 
          <UPC /> 
          <Description>Gray Blouse, Leader Size 4X</Description> <Lot /> 
         <Qty>3</Qty> <CustomFields /> 
          <AssemblyItems /> 
     </Item> 
  </Items> 
 <Packages> 
   <Package id="86892375"> 
      <TrackingNumber>9200000000000629213249</TrackingNumber>
      <Weight>4.30507</Weight> 
      <BillableWeight>4.00000</BillableWeight> 
      <Height>7.00000</Height> 
      <Width>4.00000</Width>  
      <Depth>6.00000</Depth> 
</Package>
</Shipment> 

 
Hi Everyone, 

I need help in making sense of this Apex class that was created years ago in our org. 

Today we ran into an Apex script unhandled exception 

Failed to process batch for class 'VolumeMarketBatch' 

caused by: System.NullPointerException: Attempt to de-reference a null object

Class.VolumeMarketBatch.execute: line 36, column 1

line 36 below is: 
a.Volume_Market__c = pc.Volume_Market__c;​​​​​​​

Any help is greatly appreciated. 

Thank you

 
global with sharing class VolumeMarketBatch implements Database.batchable<sObject> {

	
	global Database.QueryLocator start(Database.BatchableContext info) {

		// Go through and get the list of volume market that has changed
		String returnQuery = 'select Id, Remodeler_Account__c, Postal_Code__c ' +
							 '	from Zip_Assignment__c ' +  
							 '	where Postal_Code__r.Volume_Market_Update__c = true';

        return Database.getQueryLocator(returnQuery); 
   
	}
	
	global void execute(Database.BatchableContext info, List<sObject> sobjectList) {
		// Gets the account and postal codes that have changed
		List<Id> accountIdList = new List<Id>();
		List<Id> pcIdList = new List<Id>();
		for (sObject obj : sobjectList) {
			Zip_Assignment__c zipAssign = (Zip_Assignment__c) obj;
			accountIdList.add(zipAssign.Remodeler_Account__c);
			pcIdList.add(zipAssign.Postal_Code__c);
		}
		
		// Goes through the accounts and postal codes that have changed and sets the Volume Market field on the account
		Map<Id, Account> accountList = new Map<Id, Account>([select Id, Volume_Market__c from Account where Id = : accountIdList]);
		Map<Id, Postal_Code__c> pcList = new Map<Id, Postal_Code__c>([select Id, Volume_Market_Update__c, Volume_Market__c from Postal_Code__c where Id = : pcIdList]);
		
		for (sObject obj : sobjectList) {
			Zip_Assignment__c zipAssign = (Zip_Assignment__c) obj;
			Account a = accountList.get(zipAssign.Remodeler_Account__c);
			Postal_Code__c pc = pcList.get(zipAssign.Postal_Code__c);
			//System.Debug(pc.Volume_Market__c + a.Volume_Market__c);
			if (pc != null) { 
				if (pc.Volume_Market__c != null) {
					a.Volume_Market__c = pc.Volume_Market__c;
				}
				pc.Volume_Market_Update__c = false;
			}
		}
		
		// updates both account and postal codes
		upsert accountList.values();
		upsert pcList.values();
	}
	
	global void finish(Database.BatchableContext info) {
		
	
	}

}

 
  • January 12, 2019
  • Like
  • 0
I'm trying to code a pure function, passing in the component into the helper method and setting:

In the component, I have the following defined:
<aura:attribute name="teamCount" type="integer" default="1"/>
in the controller, I'm trying to do the following:
helper.onSetTeamCountRequest( component.get("v.teamCount"));
And in the helper, I want to change the value:
 
onSetTeamCountRequest: function( teamCountAttribute) {
        teamCountAttribute = 5;
    },

But it does not update the value.

Thanks


 
Hey guys,

Here's what I have right now: MONTH( TODAY() ) + 1, 1) - 1) - 8),(IF( MONTH( TODAY() ) = 12,
DATE( YEAR( TODAY() ), 12, 31 ),
DATE( YEAR( TODAY() ), MONTH( TODAY() ) + 1, 1) - 1) - 7))

What would the formula look like if instead of just counting 7 days down from the last day of the month, and instead count down 7 business days from the last day of the month?

Thanks!!
I work for a non profit and need to periodically export a large number (60) of CSV files for gov't reporting.   I have looked through a lot tools to do this and for those that I reviewed, they all have short comings - mostly you need to do them one at a time.   Exporting them one at a time is too labor intensive when you have to do so many of them so often.  So far, I haven't found any solution so am wondering if someone has some ideas on how to do this or know of already developed solutions.  Additionally the names of these csv files change every month so would like to manage the naming under program control.   Thank you.   Steve 
Hi! I'm wanting to make a custom page layout. No Header. No Footer. One left small (~30% or 4 SLDS columns) component section and three stacked right side bar which should take up the rest of the page. I tried this code and it doesn't come out the way I want it to.
<aura:component implements="lightning:appHomeTemplate" description="Main small column
 and three right sidebar. On a phone, the regions are of equal width">
    <aura:attribute name="left" type="Aura.Component[]" />
    <aura:attribute name="topRight" type="Aura.Component[]" />
    <aura:attribute name="middleRight" type="Aura.Component[]" />
    <aura:attribute name="bottomRight" type="Aura.Component[]" />
	<div>
        <lightning:layout>
    		<lightning:layoutItem class="slds-m-right_small">
                {!v.left}
            </lightning:layoutItem>
        </lightning:layout>
    </div>
    
    <div>
        <lightning:layout>
            <lightning:layoutItem flexibility="grow" class="slds-m-left_small">
                {!v.topRight}
            </lightning:layoutItem>
            <lightning:layoutItem flexibility="grow" class="slds-m-left_small">
                {!v.middleRight}
            </lightning:layoutItem>
            <lightning:layoutItem flexibility="grow" class="slds-m-left_small">
                {!v.bottomRight}
            </lightning:layoutItem>
        </lightning:layout>
    </div>
    
</aura:component>
 
<design:component label="Two Column, three right sidebar Custom App Page Template">
    <flexipage:template >
        <!-- The default width for the "left" region is "MEDIUM". In tablets,
        the width is "SMALL" -->
            <flexipage:region name="left" defaultWidth="SMALL">
                <flexipage:formfactor type="MEDIUM" width="SMALL" />
            </flexipage:region>
            <flexipage:region name="topRight" defaultWidth="MEDIUM" />
        	<flexipage:region name="middleRight" defaultWidth="MEDIUM" />
        	<flexipage:region name="bottomRight" defaultWidth="MEDIUM" />
       </flexipage:template>
</design:component>

User-added image

The above image is my result. What I'm trying to do is below. Where the two columns are equal in height but the right side is elongated. 

User-added image

I'm really new to App Page layouts and feel kind of lost.
Hi,
I am trying to read the body of attachment and writing in a text file using Python. Below is the sample code. 
import urllib
import requests
import base64
import json
from simple_salesforce import Salesforce
import urllib.request as urllib



instance = ''

sf = Salesforce(username='username', password='password', security_token='security_token')
sessionId = sf.session_id

attachment = sf.query("SELECT id, name,Body FROM Attachment where parentID =''")
body = ""

req = urllib.Request('https://%s.salesforce.com/services/data/v38.0/sobjects/Attachment/<id>/Body/' % instance,
    headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer %s' % sessionId })
f = urllib.urlopen(req)
f1 = open("demofile.txt", "wb")
for x in f:
    f1.write(x)
f.close()
f1.close()
But, I am getting below error.
f1.write(x)
TypeError: write() argument must be str, not bytes
Please correct me, if something is wrong.

Thanks and Regards,
Diwakar G
Hi everyone, I'm started to learn Lightning and recently faced one problem. I want to create a trivial application. My application has one picklist and one button. I select records in the picklist and output it with the button. But it does not work. 
Please help me solve this problem.
Component:
<aura:component controller="MyObjController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.fetchListOfRecordTypes}"/>
    <aura:attribute name="lstOfRecordType" type="String[]"/>
	<aura:attribute name="atrOgj" type="Sensor__c"/>
    <aura:attribute name="isOpen" type="boolean" default="false"/>
    <div class="slds-modal__container">
    	<div class="slds-modal__content slds-p-around--medium">
                    <div class="slds-grid slds-wrap">
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                             <div class="slds-align--absolute-center">Select a Record Type</div>                            
                        </div>
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                            <ui:inputSelect aura:id="selectid">
                                <aura:iteration items="{!v.lstOfRecordType}" var="contact">                            
                                    <ui:inputSelectOption text="{!contact}" label="{!contact}"  />
                                </aura:iteration>
                            </ui:inputSelect>
                        </div>&nbsp; &nbsp;
                    </div>                   
        </div>
        <div class="slds-modal__footer">
        	<lightning:button class="slds-button slds-button--brand" onclick="{!c.createRecord}">Next</lightning:button>
        </div>
        <aura:if isTrue="{!v.isOpen}">
              
					{!atrOgj.Name}
        </aura:if>
        
       
    </div>
</aura:component>
Controller:
({
    fetchListOfRecordTypes: function(component, event, helper) {
      var action = component.get("c.fetchRecordTypeValues");
      action.setCallback(this, function(response) {
         component.set("v.lstOfRecordType", response.getReturnValue());
      });
      $A.enqueueAction(action);
   },
    
    
    createRecord: function(component, event, helper) { 
      
      var action1 = component.get("c.getRecTypeId");
      var recordTypeLabel = component.find("selectid").get("v.value");
      action1.setParams({
         "recordTypeLabel": recordTypeLabel
      });
        alert(recordTypeLabel);
      action1.setCallback(this, function(response) {
         	var state = response.getState();
          if (state === "SUCCESS")  {
             component.set('v.atrOgj', response.getReturnValue());   
             component.set("v.isOpen", true);
          }
          else {alert('Error');}
      });
      $A.enqueueAction(action1);
   }
})
Apex class:
public with sharing class MyObjController {
    public static Map<Id, String> recordtypemap {get;set;}
    
   @AuraEnabled        
    public static List<String> fetchRecordTypeValues(){
       	List<Sensor__c> recordtypes = [SELECT ID,Name FROM Sensor__c];    
        recordtypemap = new Map<Id, String>();
        for(Sensor__c rt : recordtypes){
            recordtypemap.put(rt.Id, rt.Name);
        }
        system.debug(recordtypemap.values());
        return recordtypemap.values();
    }  
        @AuraEnabled
    public static Sensor__c getRecTypeId(String recordTypeLabel){
        return [SELECT Max_Vectors_Difference__c FROM Sensor__c WHERE Name =:recordTypeLabel Limit 1];
    }
}



 
Dear all,

I am mimicing the behavior of the Event object when entering time and dates in a Custom object (because I cannot use the Event object for this use-case). To be able to show these events well in the Salesforce agenda, show them in a proper format in some tables, but also to integrate with external services I have combined the seperate date and time fields (start time + date & end time + date) in a formula date/time field.

While I have a formula for the start date & time that works well, however my formula for the end date & time is just 162 characters too long when compiling... The workaround via processbuilder is not an option, since time field are (not yet) available... 

Does anybody has a suggestion to shorter the check for the daylight saving time? As a guide to the formula's variables: Datum = Start Date, Einddatum = End Date, Tijd = Time, Eindtijd = End Time.

The functionality is: 
- if no end date & no start time is available, use start date as end date and time in such a way that it is displayed as a day length activitity in SF. 
- if no end date is available, but there is an end time: use the start date and the end time. 
- if an end date is available, but there is no end time (day length activity), use enddate and add time
- if an end date and end time is available, use these

The formula: 
IF(ISNULL(Einddatum__c),

  IF(ISNULL(Tijd__c),
 
  IF(Datum__c > (DATE(YEAR(Datum__c),3,31) - MOD(DATE(YEAR(Datum__c),3,31) - DATE(1900,1,7),7)) 
  && Datum__c < DATE(YEAR(Datum__c),10,31) - MOD(DATE(YEAR(Datum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Datum__c) + ((24-2)/24),  
  DATETIMEVALUE(Datum__c) + ((24-1)/24)),

  IF(Datum__c > (DATE(YEAR(Datum__c),3,31) - MOD(DATE(YEAR(Datum__c),3,31) - DATE(1900,1,7),7)) 
  && Datum__c < DATE(YEAR(Datum__c),10,31) - MOD(DATE(YEAR(Datum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Datum__c) + ((HOUR(Tijd__c)+1.5-2)/24) + (MINUTE(Tijd__c)/1440), 
  DATETIMEVALUE(Datum__c) + ((HOUR(Tijd__c)+1.5-1)/24) + (MINUTE(Tijd__c)/1440))),

  IF(ISNULL(Eindtijd__c),

  IF(Einddatum__c > (DATE(YEAR(Einddatum__c),3,31) - MOD(DATE(YEAR(Einddatum__c),3,31) - DATE(1900,1,7),7)) 
  && Einddatum__c < DATE(YEAR(Einddatum__c),10,31) - MOD(DATE(YEAR(Einddatum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Einddatum__c) - (2/24),  
  DATETIMEVALUE(Einddatum__c) - (1/24)),

  IF(Einddatum__c > (DATE(YEAR(Einddatum__c),3,31) - MOD(DATE(YEAR(Einddatum__c),3,31) - DATE(1900,1,7),7)) 
  && Einddatum__c < DATE(YEAR(Einddatum__c),10,31) - MOD(DATE(YEAR(Einddatum__c),10,31) - DATE(1900,1,7),7), 
  DATETIMEVALUE(Einddatum__c) + ((HOUR(Eindtijd__c)-2)/24) + (MINUTE(Eindtijd__c)/1440), 
  DATETIMEVALUE(Einddatum__c) + ((HOUR(Eindtijd__c)-1)/24) + (MINUTE(Eindtijd__c)/1440)))

)

Any help is higly appreciated! 

 
Hi All,

I'm trying to source a formula that works correctly. I need to display the period between two date fields in Words (Year(s), Month(s), Day(s).
I have found a number of suggessted formulas here and also I have been offered solutions here but they don't seem to work with all date periods. For example, I have a Lease Start Date 01.12.2018 and a Lease End Date 30.11.2021. I was using a formula which was suggested to me in the past but it returns a value of 3 Years, - 1 Month, 29 Days when it should be 2 Years 11 Months 29 Days.
The formula that I have used is below. Maybe it needs some kind of adjustment, I don't really know. 

IF(ISBLANK(End_Date__c),

TEXT(Year(  TODAY()  )- Year(  Start_Date1__c  )) &" "&"Years"&" "&
TEXT(Month(  TODAY()  )-Month(  Start_Date1__c  )) &" "&"Months"&" "&
TEXT(Day(  TODAY()  )-Day(  Start_Date1__c  ))&" "&"Days",

TEXT(Year(  End_Date__c  )- Year(  Start_Date1__c  )) &" "&"Years"&" "&
TEXT(Month(  End_Date__c  )-Month(  Start_Date1__c  )) &" "&"Months"&" "&
TEXT(Day(  End_Date__c  )-Day(  Start_Date1__c  ))&" "&"Days")
 
Hi Friends,

I have a method that updates a lookup field on the task object. The task field is updated based on the value in a lookup field on the Contact. I  know it is inefficient and it fails my bulk test class. But I am not sure how to optimize the SOQL query to get my code under the  100 SOQL query limit. Any tips or pointers would be great.  The tasks are getting passed into the Method through trigger.new in a trigger handler. I am sure that putting the WhoIds into a list and doing a query to get the contacts and add them to a Map is pretty sub-optimal. 
public static void assignTasksToRelationshipOwnersInsert(List<Task> taskList) {
        //assign contacts owner to task look up field
        Set<Id> contactIds = new Set<Id>();
        for (Task t : taskList) {
            if (t.WhoId != null && t.Subject.contains('Pardot List Email')) {
                contactIds.add(t.WhoId);
            }
        }
        //create a map of contacts and regions
        //Fails SOQL limit here
        List<Contact> contactList = [
                SELECT Id, New_Relationship_owner1__c
                FROM CONTACT
                WHERE Id IN:contactIds
                AND New_Relationship_owner1__c != Null
        ];
        Map<Id, ID> contactMap = new Map<Id, Id>();
        for (Contact c : contactList) {
            contactMap.put(c.Id, c.New_Relationship_owner1__c);
        }
        for (Task updatedTask : taskList) {
            if (contactMap.containsKey(updatedTask.WhoId) && contactMap.size() > 0) {
                updatedTask.Relationship_Owner__c = contactMap.get(updatedTask.WhoId);
            }
        }
    }


 
I log into the same org with the same account (system admin profile) on classic view on Chrome on different machine, I noticed the setup page layout is different.
My work machine let me advance search by Select Metadata, my home machine doesn't. Any idea what makes the difference? Thanks.

User-added image 
There is no option in classic or lightning setup to enable knowledge :

User-added image
We're using Sesame RelationalJunction to replicated our Salesforce data into our warehouse. Unfortunately, we're seeing some rows from History tables (field history tracking tables that have the suffix "History" in their name) that have nulls in FIELD, OLDVALUE, and NEWVALUE. This only happens occasionally, and doesn't happen (as far as we can tell) with any other fields in these or any other tables. 

It seems like we're getting rows that have been created but are waiting to have the field name and old and new values entered. Is the populating of those fields a second action under the hood in Salesforce? With no LastModifiedDate field on the History, our replication tool is not going to repull the record unless we manually tell it to do so, which is our current (and unsatisfactory) fix. We're working on automating that process, but if we understood why this was happening, we might be able to avoid it in the first place.
Hi all,

I have a soql query where opportunity is the primary object.  i need to add to it the Name of the primary contact from the Contact Object.  I'm having trouble traversing the Opportunity to Account to Contact relationship.  Can someone help please
Hey everyone-

I have a couple of custom Campaign lookup fields on the Contact object called First Campaign and Most Recent Campaign. These lookup fields need to get populated with the ID of the appropriate Campaign (should be pretty self explanatory-First Campaign would lookup to the first Campaign that the Contact was added to, Most Recent Campaign would lookup to the most recent Campaign that the Contact was added to). This action is supposed to take place when either of a couple of other custom Date/Time fields (Most Recent PQC Date/Most Recent Upsell PQC Date) on the Contact are updated. I would really appreciate help figuring out why the code isn't working as intended and what the fix is. Here is the trigger:
trigger ContactTrigger on Contact ( after update) {

    if(Trigger.isUpdate && Trigger.isafter && RecursionClass.fireContactUpdate)
    {
        ContactTriggerHandler hndl = new ContactTriggerHandler ();  
        hndl.UpdateContact(trigger.OldMap ,trigger.NewMap);
    }
}

Here is the handler class:
public class ContactTriggerHandler {
    ContactTriggerAction act = new ContactTriggerAction();
    public void UpdateContact(Map<id ,Contact> OldMap , Map<id , Contact> NewMap)
    {
        act.UpdateContactCampaignField(OldMap,NewMap);
    }
}

Here is the class that performs the action:
public class ContactTriggerAction {
    
    //METHOD TO SET CAMPAIGN NAME ON CONTACT IF PQC DATE FIELDS ARE UPDATED
    public void UpdateContactCampaignField(Map<id ,Contact> oldMap , Map<id , Contact> newMap)
    {
        List<Id> filteredContactIds = new List<Id>();
        
        //check for fields if updated
        for(Contact newCon :newMap.values())
        {
           Contact oldCon = oldMap.get(newCon.id);
           
           system.debug('___newCon__ContactStatus__c___'+newCon.ContactStatus__c);
           
           //FILTER CONTACTS WHOSE MostRecentPQCDate OR MostRecentUpsellPQCDate IS UPDATED 

           if( (newCon.MostRecentMQCDate__c!=null && oldCon.MostRecentMQCDate__c != newCon.MostRecentMQCDate__c) || (newCon.MostRecentUpsellMQCDate__c !=null && oldCon.MostRecentUpsellMQCDate__c!= newCon.MostRecentUpsellMQCDate__c) )
               filteredContactIds.add(newCon.Id);
        }
        
        system.debug('___filteredContactIds____'+filteredContactIds+'__current__userId___'+UserInfo.getUserId());
        
        //Functionality doesn't run if trigger is fired by integration user to avoid assignment issues
        if(filteredContactIds!=null && filteredContactIds.size()>0 && UserInfo.getUserId() != System.Label.Integration_User_Id)
            CheckRecentCampaignmembers(filteredContactIds);        
    }
    
    //METHOD TO SET RECENT CAMPAIGN AND FRIST CAMPAIGN ON CONTACT 
    @future
    public static void CheckRecentCampaignmembers(List<Id> contactIdLst)
    {
    
        system.debug('___entered____CheckRecentCampaignmembers____');
             
        List<Contact> cLstToUpdate = new List<Contact>();
        
        //SETTING MostRecentCampaign AND FirstCampaign FIELDS OF CONTACT WITH LastModified CAMPAIGNID
        //FETCH CAMPAIGN MEMBER RECORDS TO WHICH CONTACT IS LINKED 
        for(Contact cont : [Select Id, Name, FirstCampaign__c, MostRecentCampaign__c ,(Select Id, CampaignId , HasResponded from CampaignMembers where HasResponded=TRUE ORDER BY LastModifiedDate desc limit 1) from Contact where Id In :contactIdLst])
        {    
        
            Contact con_update = new Contact(Id = cont.Id);
            
           // system.debug('______cont_____'+cont+'____size____'+cont.CampaignMembers.size()+'___campaignId____'+cont.CampaignMembers[0].CampaignId);
            
            //UPDATING MostRecentCampaign AND FirstCampaign FIELDS ON CONTACT WITH CAMPAIGN NAME
            if(cont.CampaignMembers.size()>0){
                
                con_update.MostRecentCampaign__c  = cont.CampaignMembers[0].CampaignId;
                
                //CHECKS IF FIRST CAMPAIGN FIELD IS BLANK
                if(cont.FirstCampaign__c == null)
                {
                    con_update.FirstCampaign__c = cont.CampaignMembers[0].CampaignId;  
                }
            }
            
            system.debug('____con_update_____'+con_update);
            
            cLstToUpdate.add(con_update);

        }
        
        if(cLstToUpdate!=null && cLstToUpdate.size()>0){
            RecursionClass.fireContactUpdate = false;
            update cLstToUpdate ;

        }
    }
      
}

And here is the recursion class:
Public class RecursionClass{
    
    public static Boolean fireContactUpdate = true;
}
Thanks again for your help!
​​​​​​​​​​​​​​
Below is my current formula field used in a field update WFR.
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"NCS"), 
ISPICKVAL(Direct_Match_Vendor__c,"NCS")), 
"NCS", 
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Comscore"), 
ISPICKVAL(Direct_Match_Vendor__c,"Comscore")), 
"Rentrak", 
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Experian"), 
ISPICKVAL(Opportunity.Data_Partners_EU_Entire_Campaign__c, "Experian"),
ISPICKVAL(Direct_Match_Vendor__c,"Experian"),
ISPICKVAL(Data_Partners_EU__c, "Experian")), 
"Experian", 
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Argus"), 
ISPICKVAL(Direct_Match_Vendor__c,"Argus")), 
"Argus", 
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_EU_Entire_Campaign__c,"Epsilon"), 
ISPICKVAL(Data_Partners_EU__c, "Epsilon")), 
"Epsilon", 
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"StatSocial"), 
ISPICKVAL(Opportunity.Data_Partners_EU_Entire_Campaign__c, "StatSocial"),
ISPICKVAL(Direct_Match_Vendor__c,"StatSocial"),
ISPICKVAL(Data_Partners_EU__c, "StatSocial")), 
"StatSocial", 
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Crossix"), 
ISPICKVAL(Direct_Match_Vendor__c,"Crossix")), 
"Crossix",  
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Symphony"), 
ISPICKVAL(Direct_Match_Vendor__c,"Symphony")), 
"Symphony", 
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Urban Science"), 
ISPICKVAL(Direct_Match_Vendor__c,"Urban Science")), 
"Urban Science", 
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"84.51"), 
ISPICKVAL(Direct_Match_Vendor__c,"84.51")),
"84.51",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Acxiom"), 
ISPICKVAL(Direct_Match_Vendor__c,"Acxiom")),
"Acxiom",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Alliant"), 
ISPICKVAL(Direct_Match_Vendor__c,"Alliant")),
"Alliant",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"AMEX Advance"), 
ISPICKVAL(Direct_Match_Vendor__c,"AMEX Advance")),
"AMEX Advance",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Ansa/RSi"), 
ISPICKVAL(Direct_Match_Vendor__c,"Ansa/RSi")),
"Ansa/RSi",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Datalogix"), 
ISPICKVAL(Direct_Match_Vendor__c,"Datalogix")),
"Datalogix",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Dun & Bradstreet"), 
ISPICKVAL(Direct_Match_Vendor__c,"Dun & Bradstreet")),
"Dun & Bradstreet",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"HG Data"), 
ISPICKVAL(Direct_Match_Vendor__c,"HG Data")),
"HG Data",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Infogroup"), 
ISPICKVAL(Direct_Match_Vendor__c,"Infogroup")),
"Infogroup",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Inscape"), 
ISPICKVAL(Direct_Match_Vendor__c,"Inscape")),
"Inscape",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"IRI"), 
ISPICKVAL(Direct_Match_Vendor__c,"IRI")),
"IRI",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Kantar"), 
ISPICKVAL(Direct_Match_Vendor__c,"Kantar")),
"Kantar",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Neustar"), 
ISPICKVAL(Direct_Match_Vendor__c,"Neustar")),
"Neustar",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Oracle (BlueKai)"), 
ISPICKVAL(Direct_Match_Vendor__c,"Oracle (BlueKai)")),
"Oracle (BlueKai)",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"PeopleFinders DaaS"), 
ISPICKVAL(Direct_Match_Vendor__c,"PeopleFinders DaaS")),
"PeopleFinders DaaS",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Transunion"), 
ISPICKVAL(Direct_Match_Vendor__c,"Transunion")),
"Transunion",
IF(or( 
ISPICKVAL(Opportunity.Data_Partners_Entire_Campaign__c,"Nielsen Catalina"), 
ISPICKVAL(Direct_Match_Vendor__c,"Nielsen Catalina")),
"NCS",
null 
))))))))))))))))))))))))))

I have started a case statement below. My question is  how would I condense the above into to one case statement as there are two different picklist values being used one from opportunity and one from opportunity products.
CASE(Data Partners Entire Campaign,
“NCS”, “NCS”,
“Comscore”, “Comscore”,
“Experian”, Experian”
“Argus”, “Argus”,
“Epsilon”, “Epsilon”,
“StatSocial”, “StatSocial”,
“Crossix”, “Crossix”,
“Symphony”, “Symphony”,
“Urban Science”, Urban Science”,
“84.51”, “84.51”,
“Acxiom”, “Acxiom”,
“Alliant”, “Alliant”,
“AMEX Advance”, “AMEX Advance”,
“Ansa/RSi”, “Ansa/RSi”,
“Datalogix”, “Datalogix”,
“Dun & Bradstreet”, “Dun & Bradstreet”,
“HG Data”, “HG Data”,
“Infogroup”, “Infogroup”,
“Inscape”, “Inscape”,
“IRI”, “IRI”,
“Kantar”, “Kantar”,
“Neustar”, “Neustar”,
“Oracle (Blue Kai)”, “Oracle (Blue Kai)”,
“PeopleFinders DAAS”, “PeopleFindersDAAS”,
“Transunion”, “Transunion”,
“Nielsen Catalina”, “NCS”,
“Vizio”, “Inscape”,
“”)

 
Hello,

I have an excel spreadsheet with a list of thousands name, last name ans mail address. These people have left their company and I am supposed to update the information on salesforce.
the process is:

- search the contact
- edit contact
- click on has left the company
- save
Repeat.

Does anyone has a code that does that?
Or can anyone, tell me what/how can I learn to implement that?

I usually code in VBA and I have some notions in Python.
It's the first time I try to implement a code on a website and I'm a bit lost.
I just learned HTML5 so now I can understand how the page is written. But I  don't know how to send a request and interact with the webpage.
Also I read about API, I think I understand what they're used for, but not how to use them.

Thank you for your help, I really need that.
 
1) What do you think, when Salesforce completely (or almost completely) abandons VisualForce and switches to Lightning?
2) And why do you think that you should not switch from VisualForce to Lightning?
I want to generate a consistent number or rows in  a table regardless of how many related objects exists (i.e. I want 7 rows even when there is only 3 related list objects).

I was trying to use a repeat without a value attribute to try to just create a generic looping behavior but that does not work.  I am using a standard controller and didn't want to create an extension just to generate the other rows.  Here is the code...
 
<apex:variable var="rowNum" value="{!1}"/>
			<apex:repeat var="f" value="{!sow__c.Facilities__r}" rows="7">  
                <apex:variable var="rowNum" value="{!rowNum + 1}"/>
            	<div class="row">
                <div class="col-7">
                    <div class="row">
                        <div class="bodycell col-4">
                            <span>{!f.Account__r.Name}</span>
                        </div>
                        
                        <div class="bodycell center col-2">
                            <span>
                                <apex:outputText value="{0, number, 0}">
                                    <apex:Param value="{!f.v1__c}" />
                                </apex:outputText>                                
                            </span>
                        </div>
                        
                        <div class="bodycell center col-2">
                            <span>
                                <apex:outputText value="{0, number, 0}">
                                    <apex:Param value="{!f.v2__c}" />
                                </apex:outputText> 
                            </span>
                        </div>
                        
                        <div class="bodycell col-4">
                            <span>{!f.v3__c}</span>
                        </div>
                    </div>
                </div>
                
                <div class="bodycell col-5">
                    <span>{!f.v4__c}</span>
                </div>
            </div>
            </apex:repeat>
            <apex:repeat var="f" rows="{!(7 - rowNum)}">
            	<div class="row">
                <div class="col-7">
                    <div class="row">
                        <div class="bodycell col-4">
                            <span>&nbsp;</span>
                        </div>
                        
                        <div class="bodycell col-2">
                            <span>&nbsp;</span>
                        </div>
                        
                        <div class="bodycell col-2">
                            <span>&nbsp;</span>
                        </div>
                        
                        <div class="bodycell col-4">
                            <span>&nbsp;</span>
                        </div>
                    </div>
                </div>
                
                <div class="bodycell col-5">
                    <span>&nbsp;</span>
                </div>
            </div>
            </apex:repeat>

This does't work and I have scowered google with not resolution, any help would be greatly appreciated.
I have created an Add/Edit modal popup that is working well.  I have a couple required validations and also a couple custom validation rules.  How do I get the validation errors and display them?

Here is my component:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="FRCAddRenoPopupController">
    <aura:attribute name="accountId" type="Id"/>
	<aura:attribute name="PageHeading" type="String" default="Add Renovation" />
    
    <aura:attribute name="reno" type="FRC_Renovation__c" default="{'sobjectType' : 'FRC_Renovation__c',
                                                                  'Id' : '',
                                                                  'Name' : '',
                                                                  'Property__c' : '',
                                                                  'Renovation_Start_Date__c' : '',
                                                                  'Renovation_End_Date__c' : '',
                                                                  'Renovation_Notes__c' : '',
                                                                  'Scope_Confirmed__c' : false }"/>    
       
    <lightning:button label="Add Renovation"
                      iconName="utility:new_window"
                      iconPosition="left"
                      variant="brand"
                      onclick="{!c.newPopup}"
                      />   
    
    <aura:method name="editPopupMethod" action="{!c.editPopup}" access="public">
      <aura:attribute name="columnIdentifier" type="String" />
    </aura:method>
    
    <div role="dialog" tabindex="-1" aria-labelledby="header43" aura:id="renoAddModal" class="slds-modal slds-modal_large">
        <div class="slds-modal__container" style="width: 65%;">
            <div class="slds-modal__header" style="font-size: 1.5em">
                {!v.PageHeading}             
            </div>
            
            <div class="slds-modal__content slds-p-around--medium">
                <div class="slds-p-left_xx-large slds-p-right_xx-large" style="padding-left:0px">
                    <div class="slds-page-header" style="padding-top: 9px; padding-bottom: 9px;padding-right: 9px;">
                        <h3 style="font-size: 1rem;" title="">Renovation Information</h3>
                    </div> 
                </div>    
                <div class="slds-grid slds-p-top_medium">
                    <div class="slds-size_11-of-12 slds-p-left_xx-large slds-p-horizontal_x-large " >
                        <lightning:input label="Renovation Name" required="true" name="renovationName" value="{!v.reno.Name}"/> 
                    </div>
                </div>
                <div class="slds-grid slds-p-top_x-small">
                    <div class="slds-size_6-of-12 slds-p-left_xx-large slds-p-horizontal_x-large " >
                        <ui:inputDate label="Renovation Start Date" aura:id="renovationStartDate" required="true" value="{!v.reno.Renovation_Start_Date__c}" displayDatePicker="true" format="MM/dd/yyyy"/>
                    </div>
                    <div class="slds-size_5-of-12 slds-p-left_xx-small slds-p-horizontal_x-large " >
                        <ui:inputDate label="Renovation End Date" aura:id="renovationEndDate" value="{!v.reno.Renovation_End_Date__c}" displayDatePicker="true" format="MM/dd/yyyy"/>                        
                    </div>
                </div>
                <div aura:id="scopeConfirmedDiv" class="slds-grid slds-p-top_medium">
                    <div class="slds-size_11-of-12 slds-p-left_xx-large slds-p-horizontal_x-large " >
                        <lightning:input label="Scope Confirmed" type="checkbox" name="scopeConfirmed" checked="{!v.reno.Scope_Confirmed__c}"/> 
                    </div>
                </div>                 
                <div class="slds-grid slds-p-top_medium">
                    <div class="slds-size_11-of-12 slds-p-left_xx-large slds-p-horizontal_x-large " >
                        Renovation Notes<br />
                        <lightning:inputRichText label="Renovation Notes" value="{!v.reno.Renovation_Notes__c}" />
                    </div>
                </div>                
            </div>
            <div class="slds-modal__footer">
                <lightning:button label="Save" onclick="{!c.saveModal}" />
                <lightning:button label="Cancel" onclick="{!c.closeNewModal}" />
            </div>
        </div>
    </div>   
    <div aura:id="Modalbackdrop" class="slds-backdrop"></div>
</aura:component>

Here is my controller:
({
    editPopup : function(component, event, helper)
    {
        var args = event.getParam("arguments");
        var columnIdentifier = args.columnIdentifier;
                
        var action = component.get("c.loadReno");
        action.setParams({renoID  : columnIdentifier});
        
        action.setCallback(this, function(response) {
            var state = response.getState();          
            if (state === "SUCCESS") {
				component.set("v.PageHeading", "Edit Renovation");
                var record = response.getReturnValue();
                component.set("v.reno.Id", record.Id);
                component.set("v.reno.Name", record.Name);
                component.set("v.reno.Property__c", record.Property__c);
                component.set("v.reno.Renovation_Start_Date__c", record.Renovation_Start_Date__c);
                component.set("v.reno.Renovation_End_Date__c", record.Renovation_End_Date__c);
                component.set("v.reno.Renovation_Notes__c", record.Renovation_Notes__c);
                component.set("v.reno.Scope_Confirmed__c", record.Scope_Confirmed__c);

                helper.applyShowFormStyles(component);
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } 
                else {
                    console.log(response.getReturnValue());
                }
            }
        });
        $A.enqueueAction(action);
        
      
    },
    newPopup : function(component, event, helper)
    {
        //Initialize Fields
        component.set("v.PageHeading", "Add Renovation");
        component.set("v.reno.Id", "");
        component.set("v.reno.Name", "");
        component.set("v.reno.Property__c", "");
        component.set("v.reno.Renovation_Start_Date__c", "");
        component.set("v.reno.Renovation_End_Date__c", "");
        component.set("v.reno.Renovation_Notes__c", "");
        component.set("v.reno.Scope_Confirmed__c", false);
        
        helper.applyShowFormStyles(component);
        
        //Hide the scope confirmed checkbox when adding a renovation
        var cmpScopeConfirmed = component.find('scopeConfirmedDiv');
        $A.util.addClass(cmpScopeConfirmed, 'slds-hide');
    },
	closeNewModal : function(component, event, helper)
    {
        helper.applyHideFormStyles(component);
    },
    saveModal : function(component, event, helper){
        var renoAttr = component.get("v.reno");        
        var accountIdAttr = component.get("v.accountId");
        console.log(renoAttr.Id);
        
        if (renoAttr.Id == '')
        {
            helper.insertReno(component, helper, renoAttr, accountIdAttr);
        }
        else
        {
            helper.updateReno(component, helper, renoAttr);
        }		
    },
})

Here is my helper:
({
	applyHideFormStyles : function(component) {
		var cmpTarget = component.find('renoAddModal');
        $A.util.removeClass(cmpTarget, 'slds-fade-in-open');

        var cmpBack = component.find('Modalbackdrop');
        $A.util.removeClass(cmpBack,'slds-backdrop_open');        
                        
        var cmpScopeConfirmed = component.find('scopeConfirmedDiv');
        $A.util.removeClass(cmpScopeConfirmed, 'slds-hide');
	},
	applyShowFormStyles : function(component) {
        var cmpTarget = component.find('renoAddModal');
        $A.util.addClass(cmpTarget, 'slds-fade-in-open');

        var cmpBack = component.find('Modalbackdrop');
        $A.util.addClass(cmpBack, 'slds-backdrop_open');
	},
	insertReno : function(component, helper, renoAttr, accountIdAttr) {
        var action = component.get("c.insertReno");
        action.setParams({reno  : renoAttr, accountId  : accountIdAttr});
        action.setCallback(this, function(response) {
            var state = response.getState();          
            if (state === "SUCCESS") {
                $A.get('e.force:refreshView').fire();
                helper.applyHideFormStyles(component);               
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } 
                else {
                    console.log(response.getReturnValue());
                }
            }
        });
        $A.enqueueAction(action);
	},
	updateReno : function(component, helper, renoAttr) {
        var action = component.get("c.updateReno");
        action.setParams({reno  : renoAttr});
        action.setCallback(this, function(response) {
            var state = response.getState();          
            if (state === "SUCCESS") {
                $A.get('e.force:refreshView').fire();
                helper.applyHideFormStyles(component);               
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } 
                else {
                    console.log(response.getReturnValue());
                }
            }
        });
        $A.enqueueAction(action);
	}      
})



 
HI all, 

I have a simple brief to insert a contract on an account once the account has been created while using a factory trigger. I am getting a AccountTrigger: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object () error when trying to create an Account.

Here is my ITrigger interface:
public interface ITrigger {
	void bulkAfter();

	//For records inserted during a AFTER trigger
	void afterInsert(SObject so);
    
    void andFinally();
}
Account Handler:
public with sharing class AccountHandler
implements ITrigger
{
    private Set<Id> cont_inUseIds = new Set<Id>();
    
    private List<Contract> contr = new List<Contract>();


	public AccountHandler()
	{

	}

    
	public void bulkAfter()
	{
		if(Trigger.isInsert){
            cont_inUseIds = AccountGateway.findAccountIdsInUse(Trigger.oldMap.keySet());
        }
	}
    
    
    public void afterInsert(SObject so){
        Account myAccount = (Account)so;

        Contract contrTemp = new Contract();
        contrTemp.Name = myAccount.Name;
        contrTemp.id = myAccount.Id;
        
        
        contr.add(contrTemp);
        }
    
    
    public void andFinally(){
        if(!contr.isEmpty()){
            insert contr;
        }
    }
}
Trigger Factory:
public with sharing class TriggerFactory{
	public static void createHandler(Schema.sObjectType objType){
		ITrigger handler = getHandler(objType);

		if (handler == null){
			throw new TriggerException('no registered handler for object type '+ objType);
		}

		execute(handler);
	}

	private static void execute (ITrigger handler){       
		if(Trigger.isAfter){
			handler.bulkAfter();
            if(Trigger.isInsert){
                for(SObject so : Trigger.new){
                    handler.afterInsert(so);
                }
            }
			

			//Actions for after delete and update would go here
		}

		handler.andFinally();
	}


	public static ITrigger getHandler(Schema.sObjectType objType){
		if (objType == Account.sObjectType){
			return new AccountHandler();
		}
		return null;
	}
}
The trigger itself:
trigger AccountTrigger on Account ( after insert){
	TriggerFactory.createHandler(Account.sObjectType);
}
and the additional supporting classes:
public class TriggerException extends Exception {}

AccountGateway class:
public without sharing class AccountGateway
{
    public static Set<Id> findAccountIdsInUse(Set<Id> accIds)
    {
        Set<Id> inUseIds = new Set<Id>();

        for (Account[] accounts : [Select p.Id, (Select Id From Contracts Limit 1) From Account p where p.Id in : accIds])
        {  
            for (Account acc : accounts)
            {
                if (acc.Contracts.size() > 0)
                {
                    inUseIds.add(acc.id);
                }
            }
     	}
     	return inUseIds;
	}
}





 
Hello,

I am trying to use the xmlstreamwriter class in a lighting component and I keep getting an error "Non static method cannot be referenced from a static context", and i cannot figure out how to fix it.  My code is below, any help is appreciated.


@auraEnabled
public static String getOrderURL(string recordId) {
system.debug('get Order URL called Record Id is '+recordId);

system.debug('record Id is not Null');
Contact C;
C = [SELECT CreatedById, Id, FirstName, LastName, Account.ID, Account.Name,
MailingStreet, MailingCity, MailingStateCode, MailingPostalCode, MailingCountry,
Phone, Email
FROM Contact WHERE Id = :recordId];
system.debug('contact is '+C);
FGS_SSO__c sso = FGS_SSO__c.getInstance(); // Custom Settings data for URL, Company ID, etc.
system.debug('sso is '+sso);
XmlStreamWriter w = new XmlStreamWriter();
w.writeStartDocument('utf-8', '1.0');
w.writeStartElement(null, 'NewDataSet', null);
w.writeStartElement(null, 'Customer', null); // Customer
w.WriteElement(w, 'CustomerID', sso.CustomerID__c);
w.WriteElement(w, 'FirstName', UserInfo.getFirstName());
w.WriteElement(w, 'LastName', UserInfo.getLastName());
w.WriteElement(w, 'UserEmail', UserInfo.getUserEmail());
w.WriteElement(w, 'UserName', UserInfo.getFirstName() + ' ' + UserInfo.getLastName());
w.WriteElement(w, 'UserID', UserInfo.getUserName());
w.writeEndElement(); //end Customer
w.writeStartElement(null, 'Recipients', null); // Recipients
w.writeStartElement(null, 'Recipient', null); // Recipient
w.WriteElement(w, 'ShipFirstName', C.FirstName);
w.WriteElement(w, 'ShipLastName', C.LastName);
w.WriteElement(w, 'ShipCompany', C.Account.Name);
w.WriteElement(w, 'ShipAddress', C.MailingStreet);
w.WriteEmptyElement(null, 'ShipAddress2', null); // Required
w.WriteEmptyElement(null, 'ShipAddress3', null); // Required
w.WriteElement(w, 'ShipCity', C.MailingCity);
w.WriteElement(w, 'ShipStateProvince', C.MailingStateCode);
w.WriteElement(w, 'ShipZipPostal', C.MailingPostalCode);
w.WriteElement(w, 'ShipCountry', C.MailingCountry);
w.WriteElement(w, 'ShipPhone', C.Phone);
WriteElement(w, 'ShipEmail', C.Email);
w.WriteElement(w, 'CustomerID', C.Id); // Must be non-null
w.WriteElement(w, 'CreatedBy', UserInfo.getUserId()); // this is wrong - should be the UserInfo.getUserId()
w.WriteElement(w, 'AccountID', C.Account.Id);
w.WriteElement(w, 'ContactID', C.Id);
w.WriteEmptyElement(null, 'CampaignID', null); // Required
w.writeEndElement();
w.writeEndElement();
w.writeEndDocument();
String xmlOutput = 'inputXML=' + EncodingUtil.urlEncode(w.getXmlString(), 'UTF-8');
system.debug('xmlOutput is '+xmlOutput);
XmlStreamWriter.close();
// III. Post XML to FGS Web Service and return redirect URL.
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(sso.URL__c);
req.setMethod('POST');
req.setHeader('Content-Length', String.valueOf(xmlOutput.length()));
req.setBody(xmlOutput);
HttpResponse res;
if (!isApexTest){
// Make a real callout since we are not running a test
res = h.send(req);
Dom.Document doc = res.getBodyDocument();
return doc.getRootElement().getText();
} else {
// A test is running
return '';
}
}

 

Lightning Experience Reports & Dashboards Specialist Trailhead challenge 3 in a brand new Trailhead Playground results in error id: EYSPRGBK

 

Just created this org and so the error tells me to post here:

 

There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: EYSPRGBK

While MavensMate is riding off into the sunset, it's going to remain relevant for a bit.  That said, what's The Thing to use moving forward to connect VS Code, Atom, or Sublime to the Salesforce backend?

Thanks,

Steve 
Hi guys,
We just created a library named R.apex, which helps simplify the common tasks in apex code development by adopting a functional style.
It offers tons of utility functions to work with lists, sets, maps and sobjects, making apex code clean and readable. We were suffering from the pain points of writing similar Apex code to complete trivial tasks once and once again, and that is the reason why we want to stop that and start to write reusable code. Here are some examples of what R.apex can do:
 
// Reverse a list
List<Integer> reversedList = R.of(new List<Integer>{ 1, 2, 3 })
    .reverse()
    .toIntegerList();
 
// Fina specific account
List<Account> accountList = ...;
Account acc = (Account)R.of(accountList)
    .find(R.whereEq.apply(new Map<String, Object>{
        'LastName' => 'Wilson',
        'IsDeleted' => false
    }))
    .toSObject();

Hopefully R.apex can help make your Apex code development easier, and you are always welcome to give feedback so that we can improve it.

R.apex is an open source project hosted at https://github.com/Click-to-Cloud/R.apex/.
You can check it out. Feel free to clone it, make changes or submit a PR.

^_^

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.