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

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 33
    Replies

Hi All, 

I'm iterating over a list of components, and add or remove instances of that component from the iterated list.

The list on the parent object is 2-way bound to a matching list on the child component.

My problem is, every time I "add' an instance using the button, it refreshes all fields from the prior instance that already had information in them. 
Deleting an item, similarly, removes all data in the other iterations.
The actions performed by these controllers are based on the instructions from a Udemy series, and repurposed for custom objects 
"EAM_Form__c" and "Customer_Product__c", who are parent and child, respectively.

Below is a very simplified version of the code. 
How do I prevent the fields from blanking out every time I change the list? 

My Parent Component: 

<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="customerProductList" type="List" default="[]" />
    
    <aura:iteration items="{!v.customerProductList}" var="myProduct" indexVar="index">
        <c:DemoIterationChild customerProductListChild="{!v.customerProductList}" indexNo="{!index}"/>
    </aura:iteration>
    
    <div class="buttonSection">
	    <lightning:button iconName="utility:add" variant="border-filled" label="Add Customer Product" onclick="{!c.addCustomerProduct}"/>
    </div>
</aura:component>

 Parent Component Controller: 
({
    addCustomerProduct : function(cmp,evt,hlp){
        
        var currentList = cmp.get("v.customerProductList");
        var currentSize = parseInt((currentList.length));
        var newSize 	= parseInt((currentSize.length) + 1);
        console.log("newSize = "+newSize);
        currentList.push(newSize);
        cmp.set("v.customerProductList",currentList);
        
    },
})

Child Component:
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    
    <aura:attribute name="thisProduct" type="Customer_Product__c" default="{'sobjectType':'Customer_Product__c'}" />
    <aura:attribute name="customerProductListChild" type="List" default="[]"/>
    <aura:attribute name="indexNo" type="Integer"/>
    
    <lightning:input name="productL" value="{!v.thisProduct.Length__c}" label="Product Length (l)" ></lightning:input>
    <lightning:input name="productW" value="{!v.thisProduct.Width__c}" label="Product Width (w)" ></lightning:input>
    <lightning:input name="productH" value="{!v.thisProduct.Height__c}" label="Product Height (h)" ></lightning:input>
    <lightning:input name="productWt" value="{!v.thisProduct.Weight__c}" label="Product Weight" ></lightning:input>
    
    <div style="float:right; margin-right:25px;">
        <lightning:button iconName="utility:delete" variant="border-filled" label="Delete This Product" onclick="{!c.deleteProduct}" />
    </div>
    
</aura:component>

Child Component Controller:
({
	deleteProduct : function(cmp, evt, hlp) {
		var newList = cmp.get("v.customerProductListChild");
        	var currentIndex = cmp.get("v.indexNo");
        	if(currentIndex > -1)
        	newList.splice(currentIndex,1);
        	cmp.set("v.customerProductListChild", newList);    
	},
})

 
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, 

I'm iterating over a list of components, and add or remove instances of that component from the iterated list.

The list on the parent object is 2-way bound to a matching list on the child component.

My problem is, every time I "add' an instance using the button, it refreshes all fields from the prior instance that already had information in them. 
Deleting an item, similarly, removes all data in the other iterations.
The actions performed by these controllers are based on the instructions from a Udemy series, and repurposed for custom objects 
"EAM_Form__c" and "Customer_Product__c", who are parent and child, respectively.

Below is a very simplified version of the code. 
How do I prevent the fields from blanking out every time I change the list? 

My Parent Component: 

<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="customerProductList" type="List" default="[]" />
    
    <aura:iteration items="{!v.customerProductList}" var="myProduct" indexVar="index">
        <c:DemoIterationChild customerProductListChild="{!v.customerProductList}" indexNo="{!index}"/>
    </aura:iteration>
    
    <div class="buttonSection">
	    <lightning:button iconName="utility:add" variant="border-filled" label="Add Customer Product" onclick="{!c.addCustomerProduct}"/>
    </div>
</aura:component>

 Parent Component Controller: 
({
    addCustomerProduct : function(cmp,evt,hlp){
        
        var currentList = cmp.get("v.customerProductList");
        var currentSize = parseInt((currentList.length));
        var newSize 	= parseInt((currentSize.length) + 1);
        console.log("newSize = "+newSize);
        currentList.push(newSize);
        cmp.set("v.customerProductList",currentList);
        
    },
})

Child Component:
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    
    <aura:attribute name="thisProduct" type="Customer_Product__c" default="{'sobjectType':'Customer_Product__c'}" />
    <aura:attribute name="customerProductListChild" type="List" default="[]"/>
    <aura:attribute name="indexNo" type="Integer"/>
    
    <lightning:input name="productL" value="{!v.thisProduct.Length__c}" label="Product Length (l)" ></lightning:input>
    <lightning:input name="productW" value="{!v.thisProduct.Width__c}" label="Product Width (w)" ></lightning:input>
    <lightning:input name="productH" value="{!v.thisProduct.Height__c}" label="Product Height (h)" ></lightning:input>
    <lightning:input name="productWt" value="{!v.thisProduct.Weight__c}" label="Product Weight" ></lightning:input>
    
    <div style="float:right; margin-right:25px;">
        <lightning:button iconName="utility:delete" variant="border-filled" label="Delete This Product" onclick="{!c.deleteProduct}" />
    </div>
    
</aura:component>

Child Component Controller:
({
	deleteProduct : function(cmp, evt, hlp) {
		var newList = cmp.get("v.customerProductListChild");
        	var currentIndex = cmp.get("v.indexNo");
        	if(currentIndex > -1)
        	newList.splice(currentIndex,1);
        	cmp.set("v.customerProductListChild", newList);    
	},
})

 
Remove back slash in response json through rest API in workbench post method in salesforce

Eg:- "[{\"Result\":\"No Data Found\",\"RequestType\":\"Delete\",\"RequestID\":\"YPN\"}]"

We want to delete the \ from above json.
0
Hi I have created a VF page to call a Lightning component. The function of the lightning component is to display value on it based upon the record ID in Lightning page.
Now in Classic UI we are trying to add VF Button when user clicks it it should get the current page ID and show the lightning component. But , when I click on the button the new screen opens and it keeps on loading without displaying the value. At the bottom of the screen we see the error "Lightning out App error in callback function" but we are not loading any files.


VF Page:
<apex:page StandardController="SG_ProductBook__c" >
    <apex:includeLightning />
<div  id="LightningCompContainer" />
<script>
    $Lightning.use("c:SG_ProductComponentApp", function() {
        $Lightning.createComponent("c:SG_ProductComponent", {
        },
        "LightningCompContainer",
        function(component) {
           component.set("v.bookRecord.Id",'{!$CurrentPage.parameters.id}');
        });
    });

</script>
</apex:page>
Lightning App:
<aura:application access="GLOBAL" extends="ltng:outApp" >

 <aura:dependency resource="c:SG_ProductComponent"/>
</aura:application>

Lightning Component:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,force:appHostable" controller="SG_ProductComponentController" access="global">   

<!-- Attributes -->

<aura:attribute name="communityName" type="String"/>
<aura:attribute name="accessLevel" type="Integer"/>
<aura:attribute name="loading" type="Boolean" default="true"/>
<aura:attribute name="productRecord" type="Object"/>
    <aura:attribute name="bookRecord" type="Object"/>
<aura:attribute name="categories" type="Array"/>
<aura:attribute name="allLines" type="List"/>
<aura:attribute name="versions" type="List"/>
<aura:attribute name="releaseDates" type="Map"/>
<aura:attribute name="selectedVersion" type="Integer"/>
<aura:attribute name="selectedVersionIsDraft" type="Boolean" default="false"/>
<aura:attribute name="showVersionButton" type="Boolean" default="false"/>
<aura:attribute name="selectedVersionStatus" type="String" default="Release"/>
<aura:attribute name="AccIDFromVfPage" type="string"/>

<lightning:button label="Check ID from Vf" onclick="{!c.doAction}"/>

<!-- Handlers and declared events -->    
<aura:handler name="init" value="{! this }" action="{! c.onInit }"/>
<aura:handler name="change" value="{! v.selectedVersion }" action="{! c.onChangeSelectedVersion }"/>

<!-- Libraries -->
<lightning:overlayLibrary aura:id="overlayLib"/>
<lightning:notificationsLibrary aura:id="notifLib"/>

<!-- Display a lightning card with details about the record -->
<div class="Record Details"> 
    <aura:renderIf isTrue="{! v.loading }">
        <lightning:spinner alternativeText="Loading" variant="brand"/>
    </aura:renderIf>
    <div class="slds-grid slds-grid_align-space slds-gutters slds-wrap slds-grid_vertical-align-center">
        <div class="slds-col">
            <aura:renderIf isTrue="{! !v.selectedVersionIsDraft || v.accessLevel >= 1 }"><lightning:button label="PDF Export" iconName="utility:print" onclick="{! c.handlePrint }"/></aura:renderIf>
            <lightning:button label="Compare" iconName="utility:replace" onclick="{! c.handleCompare }"/>
            <aura:renderIf isTrue="{! v.selectedVersionIsDraft &amp;&amp; v.accessLevel >= 1 }"><lightning:button label="Edit Properties" iconName="utility:edit" onclick="{! c.handleEdit }"/></aura:renderIf>
            <aura:renderIf isTrue="{! v.accessLevel >= 1 }"><lightning:button label="Clone" iconName="utility:copy" onclick="{! c.handleClone }"/></aura:renderIf>
        </div>
        <div class="slds-col slds-col_bump-left">                
            <div class="slds-grid slds-grid_vertical">
                <div class="slds-col slds-align_absolute-center" style="margin-bottom: 5px">
                    <span class="{! 'slds-badge '+v.selectedVersionStatus }">{! v.selectedVersionStatus }</span>
                </div>
                <div class="slds-col">
                    <aura:renderIf isTrue="{! v.showVersionButton }">
                        <lightning:button label="{! v.selectedVersionIsDraft ? 'Release version' : 'New Version' }" iconName="{! v.selectedVersionIsDraft ? 'utility:check' : 'utility:new' }" onclick="{! c.handleVersionButton }"/>
                    </aura:renderIf>
                </div>
            </div>                                  
        </div>
        <aura:renderIf isTrue="{! !(v.accessLevel == 0 &amp;&amp; v.bookRecord.SG_HistoryVersionNumber__c == 0) }">
            <div class="slds-col">
                <lightning:select name="select" label="Select a Version" value="{! v.selectedVersion }">
                    <aura:iteration items="{! v.versions }" var="ver">
                        <option text="{! ver.label }" value="{! ver.id }" selected="{! ver.selected }"/>
                    </aura:iteration>
                </lightning:select>
            </div>
        </aura:renderIf>
    </div> 
    <lightning:card>
        <c:SG_ProductComponent_Card bookRecord="{! v.bookRecord }"/> 
        <aura:iteration items="{! v.categories }" var="aCategory" >
            <c:SG_ProductComponent_Category category="{! aCategory.SG_ProductProperty__r.SG_Category__c }" productBookId="{! v.bookRecord.Id }" selectedVersion="{! v.selectedVersion }" lines="{! v.allLines }"/>
        </aura:iteration>
        <c:SG_ProductComponent_CalculatedFields productBookId="{! v.bookRecord.Id }" lines="{! v.allLines }"/>
    </lightning:card>
</div> 
</aura:component>
Controller:
({
/*
 *  Component initialization 
 *  Launches a different function depending on what type of page the component is displayed
 */
onInit : function(component, event, helper) {
    helper.getAccessLevel(component, event, helper);               
},

/*
 *  On selection of a version, requests the property values for said version
 */    
onChangeSelectedVersion : function(component, event, helper) {
    if(component.get('v.selectedVersion') != '' && component.get('v.bookRecord.Id') != null){      
        helper.setSelectedVersionStatus(component, event, helper);       
        helper.setShowButtons(component, event, helper); 
        helper.getProductPropertyValues(component, event, helper);       
    }       
}, 

/*
 *  Handles opening a new window previewing the product book as pdf
 */
handlePrint : function(component, event, helper) {        
    var url;
    if(component.get('v.communityName') != null) url = location.origin + '/' + component.get('v.communityName') + '/apex/SG_PrintBook?Id=' + component.get("v.bookRecord.Id") + '&version=' + component.get("v.selectedVersion");   
    else url = location.origin + '/apex/SG_PrintBook?Id=' + component.get("v.bookRecord.Id") + '&version=' + component.get("v.selectedVersion");         
    window.open(url, '', '');     
},    

/*
 *  Handles opening a modal for selecting the compare target
 */    
handleCompare : function(component, event, helper) {
    var modalBody;
    $A.createComponent("c:SG_ProductComponent_CompareModal", {"bookRecord": component.get("v.bookRecord"), "accessLevel": component.get("v.accessLevel")},
        function(content, status) {
            if (status === "SUCCESS") {
                modalBody = content;
                component.find('overlayLib').showCustomModal({
                    header: "Select a Product book to compare to",
                    body: modalBody, 
                    showCloseButton: true,
                    cssClass: "slds-modal_large"
                })
            }                               
        });
},

/*
 *  Handles opening a modal for selecting a new name for cloning
 */    
handleClone : function(component, event, helper) {
    var modalBody;
    $A.createComponent("c:SG_ProductComponent_Clone", {"bookRecord": component.get("v.bookRecord"), "accessLevel": component.get("v.accessLevel"), "version": component.get("v.selectedVersion")},
        function(content, status) {
            if (status === "SUCCESS") {
                modalBody = content;
                component.find('overlayLib').showCustomModal({
                    header: "Select a name for the new Product book",
                    body: modalBody, 
                    showCloseButton: true,
                    cssClass: "slds-modal_small"
                })
            }                               
        });
},

/*
 *  Handles opening a modal for editing values
 */    
handleEdit : function(component, event, helper) {
    var modalBody;
    $A.createComponent("c:SG_ProductComponent_EditModal", {"bookRecord": component.get("v.bookRecord"), "properties": component.get("v.allLines")},
        function(content, status) {
            if (status === "SUCCESS") {
                modalBody = content;
                component.find('overlayLib').showCustomModal({
                    header: "Edit "+component.get("v.bookRecord.Name"),
                    body: modalBody, 
                    showCloseButton: true,
                    cssClass: "slds-modal_large",
                    closeCallback: function() {
                       helper.getProductPropertyValues(component, event, helper);
                   }
                })
            }                               
        });
},
        
/*
 *  Handles operations to increment the release version number
 */      
handleVersionButton : function(component, event, helper) {
    if(component.get('v.selectedVersion') == component.get('v.bookRecord.SG_ReleaseVersionNumber__c')+1) helper.releaseVersion(component, event, helper);
    else helper.createNewVersion(component, event, helper);        
}, 
 
doAction : function(component, event, helper) {

    var accIdFromVf=component.get("v.bookRecord.Id");
    alert('Id of record from Vf page'+accIdFromVf);
} })

Please Advice.
Hi,

-> We have developed 3 lightning components and added that to lightning Record pages.
Even though the form factor is desktop and phone for all these components and pages, it doesn't show up on the iPad.
 
-> Similarly In the apps section, these components don't come up as tabs/apps.
 
-> Is there any Specific reason, for these components to not show up on the iPad?
Note: This is visible on iPhone
 
-> Apparently we have created  App pages that show up on iPad but not the record details page.
 
-> Is there any workaround for this issue? , else I am missing any configuration stuff that needs to be done to make components visible in IPad.

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?
Hi,

I was finding this issue so annyoed that I am starting to hate developing code in the Developer Console.
I don't know if this was an issue to everyone OR only to me OR only with Macbook(OS: 10.11.6) OR for whatever the reason.

Issue:
On the Developer conole, when I am trying to using two finger scroll gesture on the trackpad of my Macbook Pro (15" Late 2015) model, the cursor jumps way back to the some 10-15 lines above/below based on which direction I am scrolling.

Developer API Version: 39.0 (Latest at this very moment)

Can someone shed some light on the issue and fix, I would love developing using Developer Console.

Thanks 

 
Hi there!

I'm looking for a way to automatically close a record tab in Salesforce Service Console when I create a new record.

I'm using a custom object called Configuration Resource(s), these are added to the parent record (Configuration object), from a related list on the Configuration object page layout.
Ideally, I need to be able to have the tab that opens when the new configuration resource is created, close after saving, is this possible?
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;
    }
}



 

 
How does one test loading an opportunity record page?

There is an action that fires when the opportunity page is loaded (via a visualforce page).  I know the controller extension and action work because its been proven via the UI.  Just not sure to how properly write a unit test to load the page, and thus trigger the action to run.
  • August 11, 2016
  • Like
  • 0
Process Builder seems to be causing issues with Test Classes. They have all failed after we have activated a few new processes in Process Builder. When deactivating the processes and resorting to workflow rules, the test classes do not fail.

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;
                }          
            }                   
        }
        
     }
    
    
}