• Jason Kuzmak 12
  • NEWBIE
  • 60 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 24
    Replies
Hi all,

I'm working in Field Service Lightning. Our field service department wants an email to be sent to the customer as soon as a service report is generated.

I figured I'd build a trigger on ContentDocumentLink so I can construct an email as soon as the PDF becomes associated with the Service Appointment. Two are created: one associated to the user, and another to the Service Appointment. However...the ContentDocumentLink associated to the Service Appointment never enters trigger.new. It somehow gets into the system without firing anything or going through any of my code. 

I can query this record using Workbench afterward, however no debug logs show this record having ever existed. Why?

The dev console shows the link between the running user and the document:
User-added image
Workbench allows me to query the link between the document and the Service Appointment, which is the one I ultimately want to trigger from:
User-added imageI'm assuming the latter is inserted in future context. Does future context skip triggers?

Hi all,

There are probably steps I can look into to further optimize my visualforce page, but before I start into that, I'm wondering if it's not some sort of browser issue.

 

When I look at my view state size in the developer window it says 79KB. When my field tech tries to open it, it says that the view state has exceeded the limit of 170KB, and is 194KB instead. Why would it be more than 100KB larger when another viewer tries to access it? 

 

Hello all,

I'm building my first flow, which is now in flow builder. My first major hurdle is that I can't seem to send a string to an apex action, query some records using that string as a soql criterion, then return the list. 

My Apex action looks like this:
 

global class Flow_ChecklistTemplateItemGetter{
	@invocableMethod(label = 'Get Template Items' description = 'gets all Checklist Template Items whose "Applies_To" field contains the provided machine model')
	global static List<Checklist_Template_Item__c> getRelevantTemplateItems(List<String> modelList){
		
		String searchModel;
		
		// this will only be a single value
		for(String s : modelList){
			searchModel = s;
		}
		
		System.debug('SearchModel = '+searchModel);

		String queryString = 'Select Id, Checkbox_Options__c, Checklist_Template_Section__c, Objective__c, Required__c, Sort_Order__c From Checklist_Template_Item__c Where Applies_To__c Includes(:searchModel)';
		List<Checklist_Template_Item__c> itemList = Database.query(queryString);
		
	 	for(Checklist_Template_Item__c cti : itemList){
	 		System.debug('checklist template item = '+cti);
	 	}
	 	
	 	return itemList;
	}
}
"modelList" is only ever going to be a single value, which is why I assign it to its own string for querying. 

I get the error "The number of results does not match the number of interviews that were executed in a single bulk execution request". 
Well...no kidding. I don't want to only return one record just because I only had one string input. 

What I thought might be the reason was that my output variable was not a collection variable, but the collection variable I created in followup to that is un-selectable from my Apex action. 

I can only select variables that accept a single record. 
User-added image

Hi all, 

I'm having a problem related child objects using SOQL. In preparation for another object that has yet to be created, I made corrections to my custom object name, though now I can only query related child records using the old (wrong) name. My code here shows that now, the system recognizes both:


 
// Query child "Checklist_Item_Junctions__r" even though that is no longer the object's name
List<Checklist_Template__c> templateQuery = [Select Id, Machine_Series__c, (Select Id, Checklist_Template__c, Checklist_Template_Item__c From Checklist_Item_Junctions__r) From Checklist_Template__c];
        
        
        // separately query all "Checklist_Template_Item_Junction__c" records, (the new name of the object)
        List<Checklist_Template_Item_Junction__c> junctionQuery = [Select Id, Checklist_Template__c, Checklist_Template_Item__c From Checklist_Template_Item_Junction__c];
       

This saves successfully, and I have no idea why. There is no longer such an object as "Checklist_Item_Junction__c", but it's requiring that I call it that in my child relationship query.
 
There are 3 things that suggest to me I shouldn't store long text fields in a big object, but I'm hoping to be wrong:
1. Data is retrieved from Big Object records with SOQL queries.
2. Only the fields specified in the Big Object's index can be queried.
3. Long Text fields cannot be indexed. 

My use case is that I have a ton of sales emails I'd like to start archiving, since they take up a lot of data space. It does let me add long text fields to my big object (for example, the email body), just not as part of the index.

So these big object records are being successfully built and populated via apex as far as I know, but if I can't query them, how do I view the long text fields in my custom Big Object?

While trying to complete the challenge deployment of a big object through trailhead, workbench repeatedly tells me:

User-added image

I know what you're going to say. "Jason, just throw a question mark onto the end of the attribute name. That's documented everywhere."
And you're right. Every source I see on Google tells me to simply encapsulate everything with included question marks on both sides. 

But lo, it's already there. Here's my object file:
 

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<deploymentStatus>Deployed</deploymentStatus>
    <fields>
        <fullName>Start_Location_Lat__c</fullName>
        <label>Start Location Latitude</label>       
        <required>false</required>
        <type>Number</type>      
        <scale>4</scale>
        <precision>7</precision>
    </fields>
    <fields>
        <fullName>Start_Location_Long__c</fullName>
        <label>Start Location Longitude</label>       
        <required>false</required>
        <type>Number</type>   
        <scale>4</scale>
        <precision>7</precision>
    </fields>
    <fields>
        <fullName>Start_Time__c</fullName>
        <label>Start Time</label>
        <required>true</required>
        <type>DateTime</type>
        <unique>false</unique>
    </fields>
    <fields>
        <fullName>End_Time__c</fullName>
        <label>End Time</label>
        <required>false</required>
        <type>DateTime</type>
        <unique>false</unique>
    </fields>
    <fields>
        <fullName>Service_Type__c</fullName>
        <label>Service Type</label>
        <length>16</length>
        <required>false</required>
        <type>Text</type>
        <unique>false</unique>
    </fields>
    <fields>
        <fullName>Rider_Account__c</fullName>
        <label>Rider Account</label>
        <length>16</length>
        <required>true</required>
        <type>Text</type>       
    </fields>
    <fields>
        <fullName>Rider_Rating__c</fullName>
        <label>Rider Rating</label>       
        <required>false</required>
        <type>Number</type>
        <unique>false</unique>
        <scale>1</scale>
        <precision>2</precision>
    </fields>
    <indexes>
        <fullName>Rider_History_Index</fullName>
        <label>Rider History Index</label>
        <fields>
            <name>Rider_Account__c</name>
            <sortDirection>DESC</sortDirection>
        </fields>
        <fields>
            <name>Start_Time__c</name>
            <sortDirection>DESC</sortDirection>
        </fields>       
    </indexes>
    <label>Rider History</label>
    <pluralLabel>Rider Histories</pluralLabel>
</CustomObject>
I'm not sure what it doesn't like about the pseudo attribute name, anyone see anything wrong?

I may have promised my boss more than I can deliver, but hopefully you all can help me with something. I created a VisualForce form with "soft-required" fields, which are marked with a red asterisk, and do not prevent the user from saving the record if they are not filled out. This way our field salesmen can start a form, save it, but complete it later. They won't be able to submit for approval unless all those fields are filled, thanks to an additional formula field that doesn't checkmark itself unless all soft-required fields are filled out. 

This part works great, but here's where I'm running into trouble. What I would love to do for our dear team (who have been waiting for this feature for so long) is help them with an additional prompt that says:
"Are you sure you'd like to save this form? Looks like you still have some fields to fill before this is ready to submit."

...What if they don't, though?
Based on what I've seen, I can only add a prompt directly to my button action, and not include it conditionally if such-and-such is true.
Can anyone point me in the right direction?

I have a problem. Or rather, I have a solution that I was expecting to be a problem, and that's bad! 
In the code below, after following some tutorial steps for creating a controller extension, I found that I was able to successfully reference a quote from Salesforce CPQ by binding expressions to a variable named "quote". However, I never named a variable "quote" in any of my code, my controller is pointing to a custom object called "EAM_Form__c", and Salesforce CPQ's custom quote object is called SBQQ__Quote__c, rather than just quote. So, I don't understand why I'm able to successfully reference a variable that I never named, for example "{!quote.Voltage__c}".  

A snippet of my page:
 

<apex:page standardController="EAM_Form__c" extensions="EAMFormExtension" showHeader="true">            
    <apex:form>
        <apex:pageBlock title="Application Analysis">                
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!quote.Voltage__c}"/>
                <apex:inputField value="{!quote.Phase__c}"/>
                <apex:inputField value="{!quote.Conveyor_Height__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    <apex:form>
</apex:page>

My controller extension:
public class EAMFormExtension {
    private final EAM_Form__c myForm;

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public EAMFormExtension(ApexPages.StandardController stdController) {
        this.myForm = (EAM_Form__c)stdController.getRecord();
    }

    public SBQQ__Quote__c getQuote() {
        SBQQ__Quote__c myQuote = [Select Id, Name, Voltage__c, Phase__c, Conveyor_Height__c,SBQQ__Opportunity2__c From SBQQ__Quote__c Where Id = :this.myForm.Quote__c Limit 1];
        return myQuote;
    }
}

For the sake of learning how this works, can anyone explain this mysterious reference name to me?

For some reason or another, I can't reference the RelatedToId field on the EmailMessage object. I'm trying to loop through and figure out if this value starts with "006" so I can determine if it's attached to an opportunity. I can see it on the list of fields in both workbench and Salesforce. I don't need to overwrite this information, but I do need to read it.
 

public with sharing class EmailMessageHandler {
	public static void handleAfterInsert() {
		System.debug('successfully handled after email message insert');
		List<String> fieldList = new List<String>();
		Map<Integer,String> fieldOrderMap = new Map<Integer,String>();
		Map<String, Schema.SObjectField> fieldMap = Schema.SObjectType.EmailMessage.fields.getMap();
		for(string fieldName: fieldMap.keySet()){
			if(fieldName == 'RelatedToId'){
				System.debug('Heyyyyy! We found RelatedToId!!');
			}
			else{
				System.debug('fieldname = '+fieldname);
			}
		}
        for(EmailMessage em : (List<EmailMessage>)trigger.new){
            if(em.RelatedToId == '12345'){
                
            }
        }
	}
}

The second for loop to the code above prevents it from saving, with the message 'Variable does not exist: RelatedToId', and the API name listed in Salesforce (RelatedTo) similarly does not work.

I remove this, save, and run the code. When I check the debug log, my goofy message never fires, and yet the field doesn't show up on the list of fields under that object either. Debug log says:

fieldname = id
fieldname = parentid
fieldname = activityid
fieldname = createdbyid
fieldname = createddate
fieldname = lastmodifieddate
fieldname = lastmodifiedbyid
fieldname = systemmodstamp
fieldname = textbody
fieldname = htmlbody
fieldname = headers
fieldname = subject
fieldname = fromname
fieldname = fromaddress
fieldname = toaddress
fieldname = ccaddress
fieldname = bccaddress
fieldname = incoming
fieldname = hasattachment
fieldname = status
fieldname = messagedate
fieldname = isdeleted
fieldname = replytoemailmessageid
fieldname = isexternallyvisible

Dataloader does download the info in this field, but I need apex access to this information. How do I accomplish this? 

Hi all,

I have a ton of code that parses a CSV file of accounts coming from another database (via email services). These sheets can be quite large, and I thought it would be a good time to experiment with apex batch processing.

The trouble is, it looks like all of the examples of apex batches involve a query in the Start method. I don't need to query my accounts; I already have everything broken up into lists, and I want all of the dml for these records to occur in smaller batches.
Can this be done via batch apex, or is some other method better?

I am working with fields in Salesforce CPQ, though I figure all of the custom objects contained in it should respond to Apex as any others would. For some reason though, every time I try to reference a field on a product referenced by one of the custom objects, all fields related to that product show as null. I'm probably making some really obvious mistake. Please take a look:

public without sharing class QuoteLineHandler {
	public static void HandleBeforeDelete(){
		// Removes the Product type of all "Mosca Model" quote line items from the "Product Names" field on quote level

List<SBQQ__QuoteLine__c> quoteLineList = new List<SBQQ__QuoteLine__c>();
		List<Id> productIds = new List<Id>();
		// Add all relevant lines to list for further processing
		for(SBQQ__QuoteLine__c delQuoteLine : (List<SBQQ__QuoteLine__c>)Trigger.old){
			quoteLineList.add(delQuoteLine);
			productIds.add(delQuoteLine.SBQQ__Product__c);
		}

		List<Product2> productList = [Select Id,Name,Product_Type__c
										From Product2
									   Where Id In :productIds];		
		System.debug('productList query size is ' +productList.size()+ ' and product list = ' +productList);				   			   

		for(SBQQ__QuoteLine__c ql : quoteLineList){
			System.debug('checking if quoteline product name is null. Cover thy bases lest ye should receive a null-pointer exception.');
			System.debug('ql.SBQQ__Product__c = '+ql.SBQQ__Product__c+ ' AKA ' + ql.SBQQ__Product__r.Name);
			System.debug('ql.Id = ' +ql.Id);
			if(ql.SBQQ__Product__r.Name != null){
                System.debug('This code is never reached. Product name is always null.");
            }
        }
    }
}
As the last debug says, my null check never passes. My product's name is always null in spite of the fact that it shows in my query as having a name. Help would be greatly appreciated. 
Hi All, 

I'm pretty new to coding, so this may be a really basic question.
I'm trying to modify an Apex class that was created by our original SF org developers. There is a bulk test in one of the classes that fails to pass the governor limits, I assume, because of all of the SOQL queries :
 
private class Test_OpportunityTrigger {

    static testMethod void testOpportunityTriggers()
    {
    	Test_OpportunityTrigger.testOpportunityTriggersHelper(2);
    }

    static testMethod void testOpportunityTriggersBulk()
    {
        Test_OpportunityTrigger.testOpportunityTriggersHelper(200);
    }
    
    static void testOpportunityTriggersHelper(Integer numberOfRecords)
    {
        // find a status for a converted lead
    	LeadStatus convertStatus = [
        	SELECT MasterLabel
        	FROM LeadStatus
        	WHERE IsConverted = true
        	LIMIT 1
        ];
    	
        // create leads
        List<Lead> leadList = TestData.generateLeads(numberOfRecords);
        for(Lead lead : leadList)
        {
            lead.State = 'PA';
        	lead.Stage__c = 'Sales Qualified Lead';
        	lead.Status = 'Working - Contacted';
        	lead.SIC_Code__c = 'siccode';
            lead.Branch_Code__c = '101: Corrugated Products';
        }
        insert leadList;
// convert the leads
        List<Database.LeadConvert> leadConvertList = new List<Database.LeadConvert>();
        for(Integer ii=0; ii<leadList.size(); ++ii)
        {
            Lead lead = leadList[ii];
            Database.LeadConvert lc = new Database.LeadConvert();
            lc.setLeadId(lead.Id);
            lc.setConvertedStatus(convertStatus.MasterLabel);
            leadConvertList.add(lc);
        }
        
        if(!leadConvertList.isEmpty()){
            List<Database.LeadConvertResult> lcrList = Database.convertLead(leadConvertList);
        }
        
        // build a map to correlate an opportunity and contact for role verification
        Map<Id, Id> opportunityToContactMap = new Map<Id, Id>();
        List<OpportunityContactRole> oppConRoleSOQL = [SELECT Id, OpportunityId, ContactId FROM OpportunityContactRole WHERE IsPrimary = true AND Role = 'Decision Maker'];
        for(OpportunityContactRole opportunityContactRole : oppConRoleSOQL){
            opportunityToContactMap.put(opportunityContactRole.OpportunityId, opportunityContactRole.ContactId);
        }
        
        // verify that the lookup was populated on the opportunity and that the opportunity contact roles were created
        


        Map<Id, Contact> oppIdToContactMap = new Map<Id, Contact>();
        Map<Id, Contact> contactMap = new Map<Id, Contact>([SELECT Id, AccountId FROM Contact]);
        List<Opportunity> opportunityList = [SELECT Id, AccountId, Opportunity_Contact__c FROM Opportunity];

        


        for(Opportunity opportunity : opportunityList)
        {
            Contact contact = contactMap.get(opportunity.Opportunity_Contact__c);
            System.assertEquals(opportunity.AccountId, contact.AccountId);
            System.assertEquals(opportunityToContactMap.get(opportunity.Id), opportunity.Opportunity_Contact__c);
        }
        
        // insert new contacts and change the opportunity contact
        List<Contact> contactList = TestData.generateContacts(numberOfRecords);
        for(Integer ii=0; ii<contactList.size(); ++ii){
            contactList[ii].AccountId = opportunityList[ii].AccountId;
        }
        insert contactList;
        for(Integer ii=0; ii<opportunityList.size(); ++ii){
            opportunityList[ii].Opportunity_Contact__c = contactList[ii].Id;
        }
        update opportunityList;
        
        // verify that the contact roles were updated
        opportunityToContactMap.clear();
        // JKK created this line too. Same as above.
        oppConRoleSOQL = [SELECT Id, OpportunityId, ContactId FROM OpportunityContactRole WHERE IsPrimary = true AND Role = 'Decision Maker'];
        for(OpportunityContactRole opportunityContactRole : oppConRoleSOQL){
            opportunityToContactMap.put(opportunityContactRole.OpportunityId, opportunityContactRole.ContactId);
        }
        for(Integer ii=0; ii<opportunityList.size(); ++ii)
        {
            Opportunity opportunity = opportunityList[ii];
            System.assertEquals(opportunityToContactMap.get(opportunity.Id), opportunity.Opportunity_Contact__c);
        }
    }
}


So, I can cause this to pass just by changing the Bulk trigger value from 200 to like, 10. What I would PREFER to do, is just run an if statement for the SOQL variables that says "if this variable already exists, don't run this query for it." If I just test for whether the variable is 'null', it'll just say that the variable doesn't exist. Well shoot, THAT'S what I'd like to test for, then! If it doesn't exist, do a thing! Or, will that not solve my governor limit problem?

Any ideas?

Hi all,

There are probably steps I can look into to further optimize my visualforce page, but before I start into that, I'm wondering if it's not some sort of browser issue.

 

When I look at my view state size in the developer window it says 79KB. When my field tech tries to open it, it says that the view state has exceeded the limit of 170KB, and is 194KB instead. Why would it be more than 100KB larger when another viewer tries to access it? 

 

Hello all,

I'm building my first flow, which is now in flow builder. My first major hurdle is that I can't seem to send a string to an apex action, query some records using that string as a soql criterion, then return the list. 

My Apex action looks like this:
 

global class Flow_ChecklistTemplateItemGetter{
	@invocableMethod(label = 'Get Template Items' description = 'gets all Checklist Template Items whose "Applies_To" field contains the provided machine model')
	global static List<Checklist_Template_Item__c> getRelevantTemplateItems(List<String> modelList){
		
		String searchModel;
		
		// this will only be a single value
		for(String s : modelList){
			searchModel = s;
		}
		
		System.debug('SearchModel = '+searchModel);

		String queryString = 'Select Id, Checkbox_Options__c, Checklist_Template_Section__c, Objective__c, Required__c, Sort_Order__c From Checklist_Template_Item__c Where Applies_To__c Includes(:searchModel)';
		List<Checklist_Template_Item__c> itemList = Database.query(queryString);
		
	 	for(Checklist_Template_Item__c cti : itemList){
	 		System.debug('checklist template item = '+cti);
	 	}
	 	
	 	return itemList;
	}
}
"modelList" is only ever going to be a single value, which is why I assign it to its own string for querying. 

I get the error "The number of results does not match the number of interviews that were executed in a single bulk execution request". 
Well...no kidding. I don't want to only return one record just because I only had one string input. 

What I thought might be the reason was that my output variable was not a collection variable, but the collection variable I created in followup to that is un-selectable from my Apex action. 

I can only select variables that accept a single record. 
User-added image

Hi all, 

I'm having a problem related child objects using SOQL. In preparation for another object that has yet to be created, I made corrections to my custom object name, though now I can only query related child records using the old (wrong) name. My code here shows that now, the system recognizes both:


 
// Query child "Checklist_Item_Junctions__r" even though that is no longer the object's name
List<Checklist_Template__c> templateQuery = [Select Id, Machine_Series__c, (Select Id, Checklist_Template__c, Checklist_Template_Item__c From Checklist_Item_Junctions__r) From Checklist_Template__c];
        
        
        // separately query all "Checklist_Template_Item_Junction__c" records, (the new name of the object)
        List<Checklist_Template_Item_Junction__c> junctionQuery = [Select Id, Checklist_Template__c, Checklist_Template_Item__c From Checklist_Template_Item_Junction__c];
       

This saves successfully, and I have no idea why. There is no longer such an object as "Checklist_Item_Junction__c", but it's requiring that I call it that in my child relationship query.
 

While trying to complete the challenge deployment of a big object through trailhead, workbench repeatedly tells me:

User-added image

I know what you're going to say. "Jason, just throw a question mark onto the end of the attribute name. That's documented everywhere."
And you're right. Every source I see on Google tells me to simply encapsulate everything with included question marks on both sides. 

But lo, it's already there. Here's my object file:
 

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<deploymentStatus>Deployed</deploymentStatus>
    <fields>
        <fullName>Start_Location_Lat__c</fullName>
        <label>Start Location Latitude</label>       
        <required>false</required>
        <type>Number</type>      
        <scale>4</scale>
        <precision>7</precision>
    </fields>
    <fields>
        <fullName>Start_Location_Long__c</fullName>
        <label>Start Location Longitude</label>       
        <required>false</required>
        <type>Number</type>   
        <scale>4</scale>
        <precision>7</precision>
    </fields>
    <fields>
        <fullName>Start_Time__c</fullName>
        <label>Start Time</label>
        <required>true</required>
        <type>DateTime</type>
        <unique>false</unique>
    </fields>
    <fields>
        <fullName>End_Time__c</fullName>
        <label>End Time</label>
        <required>false</required>
        <type>DateTime</type>
        <unique>false</unique>
    </fields>
    <fields>
        <fullName>Service_Type__c</fullName>
        <label>Service Type</label>
        <length>16</length>
        <required>false</required>
        <type>Text</type>
        <unique>false</unique>
    </fields>
    <fields>
        <fullName>Rider_Account__c</fullName>
        <label>Rider Account</label>
        <length>16</length>
        <required>true</required>
        <type>Text</type>       
    </fields>
    <fields>
        <fullName>Rider_Rating__c</fullName>
        <label>Rider Rating</label>       
        <required>false</required>
        <type>Number</type>
        <unique>false</unique>
        <scale>1</scale>
        <precision>2</precision>
    </fields>
    <indexes>
        <fullName>Rider_History_Index</fullName>
        <label>Rider History Index</label>
        <fields>
            <name>Rider_Account__c</name>
            <sortDirection>DESC</sortDirection>
        </fields>
        <fields>
            <name>Start_Time__c</name>
            <sortDirection>DESC</sortDirection>
        </fields>       
    </indexes>
    <label>Rider History</label>
    <pluralLabel>Rider Histories</pluralLabel>
</CustomObject>
I'm not sure what it doesn't like about the pseudo attribute name, anyone see anything wrong?

I may have promised my boss more than I can deliver, but hopefully you all can help me with something. I created a VisualForce form with "soft-required" fields, which are marked with a red asterisk, and do not prevent the user from saving the record if they are not filled out. This way our field salesmen can start a form, save it, but complete it later. They won't be able to submit for approval unless all those fields are filled, thanks to an additional formula field that doesn't checkmark itself unless all soft-required fields are filled out. 

This part works great, but here's where I'm running into trouble. What I would love to do for our dear team (who have been waiting for this feature for so long) is help them with an additional prompt that says:
"Are you sure you'd like to save this form? Looks like you still have some fields to fill before this is ready to submit."

...What if they don't, though?
Based on what I've seen, I can only add a prompt directly to my button action, and not include it conditionally if such-and-such is true.
Can anyone point me in the right direction?

I have a problem. Or rather, I have a solution that I was expecting to be a problem, and that's bad! 
In the code below, after following some tutorial steps for creating a controller extension, I found that I was able to successfully reference a quote from Salesforce CPQ by binding expressions to a variable named "quote". However, I never named a variable "quote" in any of my code, my controller is pointing to a custom object called "EAM_Form__c", and Salesforce CPQ's custom quote object is called SBQQ__Quote__c, rather than just quote. So, I don't understand why I'm able to successfully reference a variable that I never named, for example "{!quote.Voltage__c}".  

A snippet of my page:
 

<apex:page standardController="EAM_Form__c" extensions="EAMFormExtension" showHeader="true">            
    <apex:form>
        <apex:pageBlock title="Application Analysis">                
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!quote.Voltage__c}"/>
                <apex:inputField value="{!quote.Phase__c}"/>
                <apex:inputField value="{!quote.Conveyor_Height__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    <apex:form>
</apex:page>

My controller extension:
public class EAMFormExtension {
    private final EAM_Form__c myForm;

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public EAMFormExtension(ApexPages.StandardController stdController) {
        this.myForm = (EAM_Form__c)stdController.getRecord();
    }

    public SBQQ__Quote__c getQuote() {
        SBQQ__Quote__c myQuote = [Select Id, Name, Voltage__c, Phase__c, Conveyor_Height__c,SBQQ__Opportunity2__c From SBQQ__Quote__c Where Id = :this.myForm.Quote__c Limit 1];
        return myQuote;
    }
}

For the sake of learning how this works, can anyone explain this mysterious reference name to me?
I've been running into some issues with Process Builder and how it handles duplicate values. To be clear - this is not a question about duplicate contact records. 

I have a Flow and a Process set up to automatically add users to a Case team - such as the case creator.  Separately in Case Assignment rules, I have a default case team established for a specific Record Type. 

The error I am getting is when a user who is on the default case team, also creates a case. This leads to a duplicate value error in the case team (assiged first in the assignment rule / default case team, and then attempts to update again with the Flow and Process builder) and the flow will not execute and no record is created. 

Has anyone dealt with something similar ? Is there a way to prevent the whole process from failing (and thus a record not being created). It seems like there should be a way to handle the error a little less disruptively. 
 

I am working with fields in Salesforce CPQ, though I figure all of the custom objects contained in it should respond to Apex as any others would. For some reason though, every time I try to reference a field on a product referenced by one of the custom objects, all fields related to that product show as null. I'm probably making some really obvious mistake. Please take a look:

public without sharing class QuoteLineHandler {
	public static void HandleBeforeDelete(){
		// Removes the Product type of all "Mosca Model" quote line items from the "Product Names" field on quote level

List<SBQQ__QuoteLine__c> quoteLineList = new List<SBQQ__QuoteLine__c>();
		List<Id> productIds = new List<Id>();
		// Add all relevant lines to list for further processing
		for(SBQQ__QuoteLine__c delQuoteLine : (List<SBQQ__QuoteLine__c>)Trigger.old){
			quoteLineList.add(delQuoteLine);
			productIds.add(delQuoteLine.SBQQ__Product__c);
		}

		List<Product2> productList = [Select Id,Name,Product_Type__c
										From Product2
									   Where Id In :productIds];		
		System.debug('productList query size is ' +productList.size()+ ' and product list = ' +productList);				   			   

		for(SBQQ__QuoteLine__c ql : quoteLineList){
			System.debug('checking if quoteline product name is null. Cover thy bases lest ye should receive a null-pointer exception.');
			System.debug('ql.SBQQ__Product__c = '+ql.SBQQ__Product__c+ ' AKA ' + ql.SBQQ__Product__r.Name);
			System.debug('ql.Id = ' +ql.Id);
			if(ql.SBQQ__Product__r.Name != null){
                System.debug('This code is never reached. Product name is always null.");
            }
        }
    }
}
As the last debug says, my null check never passes. My product's name is always null in spite of the fact that it shows in my query as having a name. Help would be greatly appreciated. 
I am getting this error: The number of results does not match the number of interviews that were executed in a single bulk execution request.
Here is the apex class I am using, I want to store list<string> data from a json file into a flow variable:
global class par{

    global static List<string> l = new list<string>();
    
@InvocableMethod(label='Get Map' description='Returns the values of Maps')
    global static List<String> CallMap(){
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=AIzaSyBOyIQi54LMykmzSOvCuQ2naVvVQEsEfHw');
        req.setMethod('GET');
        Http http = new Http();
        HTTPResponse res = http.send(req);
        JSONParser parser = JSON.createParser(res.getBody());
        while (parser.nextToken()!= null)
        {
            if ((parser.getCurrentToken() == JSONToken.FIELD_NAME))
            {
                    string fieldName = parser.getText();
                    parser.nextToken();
                if(fieldName == 'place_id')
                {
                    string place = parser.getText();
                    system.debug(place);
                    l.add(place);
                	parser.nextToken();
                }else if(fieldName == 'status')
                	{
                    string status = parser.getText();
                    system.debug(status);
                    l.add(status);
                    }
        	}
    	}
        return l;
    }
}



 

 

Hi,

 

I am fairly new to salesforce and am making a TimeSheet app.

 

What I have is a dropdown box with a list of accounts. Once an account is selected it should show a dropdown box that contains a list of projects connected to that account. The accounts dropdown box shows but every time a click on an item in the account I get:

 

 

System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!projectsByAccount}' in component <apex:page> in page timesheet

Class.TimesheetEntry.projectsByAccount: line 36, column 1

Here is my VisualForce code:

 

<apex:page controller="TimesheetEntry" sidebar="false">
    <apex:pageBlock title="Timesheet Entry">
    
    <apex:pageBlockSection >
    Resource Name: {!$User.FirstName} {!$User.LastName}
    </apex:pageBlockSection>
    
    <apex:form >
    <apex:pageBlockSection columns="4">
    
    <apex:pageBlockSectionItem >
    <apex:selectList value="{!accountID}" size="1">
        <apex:selectOptions value="{!accounts}">
        </apex:selectOptions>
        <apex:actionSupport event="onchange" action="{!projectsByAccount}" rerender="projectSectionItem">
            <apex:param name="accountid" assignTo="{!accountID}" value="{!accountID}" />
        </apex:actionSupport>
    </apex:selectList>
    </apex:pageBlockSectionItem>
    
    
    <apex:outputPanel id="projectSectionItem" style="display:{!if(showProjects,'block','none')};">
    <apex:selectList value="{!projectID}" size="1">
        <apex:selectOptions value="{!projects}">
        </apex:selectOptions>
    </apex:selectList>
    </apex:outputPanel>
    
    </apex:pageBlockSection>
    </apex:form>
    </apex:pageBlock>
</apex:page>

 and here is my Custom Controller code:

 

public with sharing class TimesheetEntry { // sharing class so that user permissions are respected
    
    public String projectID { get; set; }
    public String accountID { get; set; }
    public Boolean showProjects { get; set; }
    public List<SelectOption> projOptions { get; set;}
    
    // Constructor
    public TimesheetEntry() {
        // Do not show the projects dropdown on page load
        System.debug('Constructor');
        showProjects = false;
        List<SelectOption> projOptions = new List<SelectOption>();
    }
    
    // Method referenced in VF page as {!accounts}
    public List<SelectOption> getAccounts() {
        System.debug('getAccounts');
        List<SelectOption> accOptions = new List<SelectOption>();
        accOptions.add(new SelectOption('Select Account', '--Select Account--'));
        for (Account account: [SELECT id, Name FROM Account]) {
           accOptions.add(new SelectOption(account.id, account.Name));
        }
        return accOptions;
    }
    
    // Method referenced in VF page as {!projects}
    public List<SelectOption> getProjects() {
        System.debug('getProjects');
        return projOptions;
    }
    
    // Action call in VF page {!projectsByAccount} referecnces this method
    public PageReference projectsByAccount() {
        System.debug('Inside page reference');
        projOptions.add(new SelectOption('Select Project', '--Select Project--'));
        System.debug('Added first item');
        for (Project__c project: [SELECT id, Name FROM Project__c WHERE 
                Project__c.Account__r.id =: accountID]) {
                projOptions.add(new SelectOption(project.id, project.Name));
            }
        return null;
    }
}

 The only debug statement that is not displayed in the System log is:

 

 

System.debug('Added first item');

so I believe that the problem lies in what happens before this line. Being new to the Salesforce platform I am finding it difficult to work it out.

 

Thanks in advance.

nav

 

I know how to write dynamic sSoql in Apex where I can control the select list with code.

 

What I want to do is dynmically set certain fields in an sObject before I save it.  I'll have the names of the fields in variables.

 

Anyone know if there's a way to set a field in an sObject where the field name is set dynamically. 

 

I want to do something like--

 

  mySObject.setField('FieldName', 'NewValue');

 

 

Since last year we're using Salesforce.com in our organisation and I'm appointed as administrator.

 

I discovered Salesforce as being a nice tool with lots of possibilities. In many situations however I get the feeling that even much more could be achieved using Apex-code and Visualforce.

 

Is it possible to learn Apex and Visualforce from scratch, without any technical knowledge nor formation in informatics/programming...?

 

How long would it take then before one can implement a few 'basic' things like e.g. creating a custom button with apex or overriding a standard button?

 

Are there any usefull manuals for beginners regarding Apex and Visualforce? Would you recommend following specific formations/trainings?

 

 

Thanks.

  • September 30, 2010
  • Like
  • 0

I'm trying to copy a new user as contact by using a trigger but I'm getting the following error

 

MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Contact, original object: User

 

trigger Acceleration_User_Copyto_Contact on User (after insert, after update) {
    
   // Map<String,User> newLead = new Map <String, User>();
    
    system.debug('Acceleration_User_Copyto_Contact Trigger....');
 
    for ( User user : System.Trigger.new)
    {
        if  (user.Email.contains('acceleration'))
        {
            system.debug('Acceleration_User_Copyto_Contact Trigger..2.');
            Integer RecordCount = [select count() from Contact c where c.Email = : user.Email];
            
            system.debug('Acceleration_User_Copyto_Contact Trigger..2a .' + RecordCount);
            
            if (RecordCount == 0)
            {
                String AccountId = '';
                for ( Account a : [Select a.Id From Account a where Name = 'Acceleration']) 
                {
                    system.debug('Acceleration_User_Copyto_Contact Trigger..3.');
                     
                    AccountId = a.Id;
                
                    Contact con = New Contact();
                    con.AccountId = AccountId ;
                    con.Email = user.Email;
                    con.Firstname = User.Firstname;
                    con.Lastname = User.Lastname ;
                    con.User__c = User.Id;
                    insert con;
                }          
            }                   
        }
        
     }
    
    
}