• Ajinkya Dhas
  • NEWBIE
  • 0 Points
  • Member since 2018
  • SalesforceKid


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 22
    Replies
Hello, I am trying to iterate over a list of SObjects, but I'm not sure how to get it to display.

Here is the controller
public with sharing class RandomRecordAudit {
    @AuraEnabled(cacheable=true)
    public static map<string, string> getAllObjects(){
        map<string, string> objectList = new map<string, string>();
        for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
        {
            Schema.DescribeSObjectResult objResult = o.getDescribe();
            objectList.put(objResult.getName(), objResult.getLabel());
        }
        return objectList;
    } 
}

Here is the JS file
import { LightningElement, track } from 'lwc';
import getAllObjects from '@salesforce/apex/RandomRecordAudit.getAllObjects';
export default class SObjectList extends LightningElement {
    
        @track objects;
        @track error;
    
        handleLoad() {
            getAllObjects()
                .then(result => {
                    this.objects = result;
                })
                .catch(error => {
                    this.error = error;
                });
        
    }
}

and here is the HTML
<template>
    <lightning-card title="ApexImperativeMethod" icon-name="custom:custom63">
        <div class="slds-m-around_medium">
            <template if:true={objects}>
                <template for:each={objects} for:item="object">
                    <p key={object.Id}>{object.Name}</p>
                </template>
            </template>
            <template if:true={error}>
                <p>Error</p>
                <c-error-panel errors={error}></c-error-panel>
            </template>
        </div>
    </lightning-card>
</template>

Any help is greatly appreciated, thanks!​​​​​​​
Hi All,

I am new to lightning development and am trying to accomplish the following :
1.)Display a list of pictures stored in attachment object.
2.)Select a pic and save it as dp.

Below is my implementation of the same. But i am not able to display them on the screen.
<!-- Component -->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" 
                controller="displayAttchmentList" access="global">
    <!--force:LightningQuickAction,force:hasRecordId,-->
    <aura:handler name="init" action="{!c.returnAttList}" value="{!this}" />
    <aura:attribute name="atlist" type="String"/>
   <!-- <aura:attribute name="contactId" type="String" default="0032800001EXXan"/>
    <aura:attribute name="Pic" type="String"/> -->
    <div>
    	<table class="slds-table slds-table--bordered slds-table--cell-buffer">
                <thead>
                    <tr class="slds-text-title--caps" style="background: rgb(159, 170, 181);">
                        <th scope="col">
                            <div class="slds-truncate" title="Id">Id</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Body">Attachment body</div>
                        </th>
                       
                        
                    </tr>
                </thead>
                <tbody>
                    
                   
                
                    <aura:iteration items="{!v.atlist}" var="acc">
                        <tr>
                            <td>
                                <div class="slds-truncate">{!acc.Id}</div>
                            </td>
                            <td>
                                <div class="slds-truncate"><img src="https://resttestdomain-dev-ed.lightning.force.com/one/one.app#/sObject/0032800001EXXanAAH"/></div>
                            </td>
                            
                          <!--  <td>
                                <div class="slds-truncate"><ui:outputRichText value="{!acc.body}"/>
</div>
                            </td> -->
                            
                        </tr>
                        
                        
                            
                    </aura:iteration>
                </tbody>
            </table>
    
    
    
    </div>
    
    
    
    
</aura:component>
 
//Controller
({
returnAttList : function(component, event, helper) {

    var actionImage = component.get("c.getImage");
   /* actionImage.setParams({
        parentId : component.get("v.actId")
    });*/

    actionImage.setCallback(this, function(a){
        var lsa=a.getState();
        
        if(lsa==="SUCCESS"){
        component.set("v.atlist",a.getReturnValue());
            console.log('Peace');
            console.log('LSA1 >>>>'+lsa);
      
        }
        else if(lsa==="ERROR"){
            var error=response.getError();
            console.log('LSA2 >>>>'+lsa);
            if(errors){
                if(errors[0] && errors[0].message){
                    console.log(errors[0].message);
                    
                }
            }
            
        }
        
       /* var attach = a.getReturnValue();
        component.set("v.imageSrc", "/servlet/servlet.FileDownload?file=" + attach.Id);
        console.log('>>>>>>>>>'+attach); */
    });

    $A.enqueueAction(actionImage);
}

})
 
//ApexMethod
@AuraEnabled
	public static list<Attachment> getImage(){
        //Id parentId
    

    return [select Id, Name,Body, ContentType from Attachment 
            where parentid='0032800001EXXanAAH' and ContentType in ('image/png', 'image/jpeg', 'image/gif')];
}

Can someone tell me where i am going wrong because i am not able to display the list of attachments on the screen which is the primary step.
However, when i change it to any other sobject i am able todisplay those records on the screen.
 
I created a Web To Lead and modified a couple of extra elements such as header, font size as well as adding the tags to make fields such as name, email - required.
Once I test the html code in the browser works fine.
However, once I intersed in our website page template, the functionality for the required fields is lost.
Any guess what is stopping it from working?
I inserted the form-html  code in a page field which has an html editor. Our org web is a CMS based website.
(btw, I'm not a developer, just a curious html interest)
I am new to salesforce, how to write a test class in apex and what are the things that have to be considered while writing a test class.
What is a recursive trigger? What are the best ways to avoid recursive triggers can somebody explain with a simple example.Please help me to understand the concept of recursive triggers.

Thanks
Suppose I've a list of fruits like 
List<string> fruits = new List<string> {'mango','papaya','orange','mango'};

then how can I assign this values to set?

for(integer i =0; i<fruits.size(); i++)

set<string> fruits1 = fruits[i];
}

The above code declaration is correct?
Hello All,
   i have gone through list and map, would any one share same example using LIST and MAP using 2 object. i am still confused when do i use list and when do i use map? please give me one common example , how MAP reduces code over LIST ?

Thanks,
 
we handle recursive via static boolean variable.but my question is why should we use static boolean variable.instead of object variable(as i understand static is a class variable.we can call directly by class name no object is require) 
Hello,

I am trying to create web to lead form and integrate into my website and send an email. I have followed the following steps:


Step I: Create a new lead custom field to capture the new information

1. Click on:

Setup | App Setup | Customize | Lead | Fields.

2. Scroll down and click on the "New" button next to Lead Custom Fields.

3. Enter the Data type for the field and the appropriate label for the field. Depending on the data type, you may need to fill out the other sections.

4. Click "Save".

5. You can optionally map this lead field to Accounts, Contacts, and Opportunities if the lead is converted. (in order to do so, click on the link "Map Lead Fields" located next to "New." This will ensure that the information is retained when the lead is subsequently converted.

Step II: Generate the sample HTML code for this new field

1. Click on:

Setup | App Setup | Customize | Leads | Web-to-Lead.

2. Click on "Create Web-to-Lead Form".

3. Deselect all the check boxes by clicking on "select none". Then select only the lead field you just created.

4. Click "Generate".

5. Select all the text in the text box and copy it onto your clipboard by selecting the menu option Edit -> Copy (on your browser).

Step III: Incorporate the new HTML into your web site

1. Paste the HTML you copied into an email and send it to your webmaster.

2. Your webmaster will need to add the input elements in this sample HTML into your website. They will also likely want to customize the look and feel to match that of your web site.


There are some problem arises to map the fields that are mentioned on step1 no 5.

I have confused about the next step.
 
I have two custom objects Job_Application_c,review__c
I need to write child to parent relationship soql query.
Please help me
Thanks & Regards,
Sindhu Ambarkar.
I'm working through Expenses example in the Dev Guide and see "v." and "c." in several locations but they aren't things that are declare anywhere.

Are these well-known objects that have to be referenced via "v" and "c"?  Like mayb "v" is view and "c" is controller" or something like that?

I'm curious if the code could be altered and the "v." and "c." terms could be changed if they are declared somewhere or if I'm coding in this style, must I use objects referred to by the specific named "v" and "c".

How to write a test class for below class. The test class should work for  the bulk scenario also. Please help me.

 

public with sharing class CloneOpportunityUtil {

public static void cloneOpportunities(List<Opportunity> oppList) {

List<IBX_Lines__c> newIBXLines = new List<IBX_Lines__c>();
Set<Id> cloneOppIds = new Set<Id>();
Map<Id,Id> cloneOppToNewOppIdMap = new Map<Id,Id>();
Map<Id,List<IBX_Lines__c>> oppIdIBXListMap = new Map<Id,List<IBX_Lines__c>>();
List<IBX_Lines__c> listIBX = null;
for(Opportunity tempOpp : oppList) {
if(tempOpp.Clone_Opportunity_ID__c != null) {
cloneOppIds.add(tempOpp.Clone_Opportunity_ID__c);
cloneOppToNewOppIdMap.put(tempOpp.Clone_Opportunity_ID__c,tempOpp.Id);
}
}

if(cloneOppIds.size() > 0) {
List<IBX_Lines__c> listIBXLines = [Select IBX_Name__c,Adjustment_Type__c,Opportunity__c,Competitors__c,Forecast_MRR__c,Forecast_NRR__c,Forecast_Status__c,Lead_Source__c,Line_Type__c,Primary_Campaign_Source__c,Cross_Region_Lead_Source__c from IBX_Lines__c where Opportunity__c IN :cloneOppIds and Forecast_Status__c = 'Slipped'];
for(IBX_Lines__c tempIBX : listIBXLines) {
if(oppIdIBXListMap.keySet().contains(tempIBX.Opportunity__c)) {
oppIdIBXListMap.get(tempIBX.Opportunity__c).add(tempIBX);
} else {
listIBX = new List<IBX_Lines__c>();
listIBX.add(tempIBX);
oppIdIBXListMap.put(tempIBX.Opportunity__c,listIBX);
}
}

}
IBX_Lines__c insertIBX = null;
for(Id tempId : cloneOppToNewOppIdMap.keySet()) {
if(oppIdIBXListMap.get(tempId).size() > 0) {
for(IBX_Lines__c tempIBX : oppIdIBXListMap.get(tempId)) {
insertIBX = new IBX_Lines__c();
insertIBX.Opportunity__c = cloneOppToNewOppIdMap.get(tempId);
insertIBX.IBX_Name__c = tempIBX.IBX_Name__c;
insertIBX.Adjustment_Type__c =tempIBX.Adjustment_Type__c;
insertIBX.Competitors__c = tempIBX.Competitors__c;
insertIBX.Forecast_MRR__c = tempIBX.Forecast_MRR__c;
insertIBX.Forecast_NRR__c = tempIBX.Forecast_NRR__c;
insertIBX.Forecast_Status__c = 'New/Active';
insertIBX.Lead_Source__c = tempIBX.Lead_Source__c;
insertIBX.Line_Type__c = tempIBX.Line_Type__c;
insertIBX.Cross_Region_Lead_Source__c = tempIBX.Cross_Region_Lead_Source__c;
insertIBX.Primary_Campaign_Source__c = tempIBX.Primary_Campaign_Source__c;
newIBXLines.add(insertIBX);
}
}
}
if(newIBXLines.size() > 0)
insert newIBXLines;
}

}

Hi All,

 

 

Diff between Dynamic SOQL and Static SOQL queries?Is there any performance will increase while using stacic or dynamic  queries?

 

 

Thanks,

 

 

Vicky

what is a recursive trigger? how to handle it?

 

Thanks,

Munna.

  • January 20, 2013
  • Like
  • 0
difference between "Trigger.New" and "Trigger.old".

Pls explain me what is Recursive Trigger & how to avoid Recursive problem?