• {!Piyush_soni__c}
  • ALL STAR
  • 11257 Points
  • Member since 2016
  • Salesforce Developer
  • ACS


  • Chatter
    Feed
  • 362
    Best Answers
  • 20
    Likes Received
  • 25
    Likes Given
  • 2
    Questions
  • 1349
    Replies
Hi,

Is salesforce ligthtning is ruling now ? Is it necessary to learn lightning as developer? what will be used in lightning development and what are prerequisites to learn it.?

Thank you
apex class:
public class myAccount {
    private final contact con;
    public string filename{set;get;}
    public string contenttype {set;get;}
    public string Conlastname{get;set;}
    public string conphone{get;set;}
    public string conemail{get;set;}
    public string Conmobilephone{get;set;}
    public string Accid='';
    public blob Photo{get;set;}
    public string photoname{get;set;}
    public string photourl{get;set;}
    //Contstructor 
   public myAccount(ApexPages.StandardController controller) {
     con=(Contact)controller.getRecord();
    }
   
    //this method updates the Contact with photourl and insert The Attachment Record
    public void UploadPhoto(){
        try{
            con.lastname = conlastname;  
            con.email = conemail;
            con.phone = conphone;
            con.mobilephone = conmobilephone;
            insert con;
           // Accid = ApexPages.currentPage().getParameters().get('id');  
           // inserting attachement with Attached photo      
            Attachment objA=new Attachment();
            objA.body = photo;
            objA.name = filename;
            objA.parentid= con.id;
            objA.ContentType = contenttype;
            insert objA;
           
            string Attid= objA.id;
            string attachmentid=Attid.substring(0,15);
             system.debug(Attid);
             con.imageUrl__c = '<img src="https://hyundaycars-dev-ed--c.ap5.content.force.com/servlet/servlet.FileDownload?file='+attachmentid+'"></img>';
           con.urlToImage__c = 'https://hyundaycars-dev-ed--c.ap5.content.force.com/servlet/servlet.FileDownload?file='+attachmentid;
            update con;
            photourl = con.urlToImage__c ;        
        }catch(Exception e){
            system.debug('Exception message'+e);
        }
     } 
     public List<SelectOption> getTypes(){
            Schema.sObjectType sobject_type = Contact.getSObjectType();
            Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
            Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
            List<Schema.PicklistEntry> pick_list_values = field_map.get('Level__c').getDescribe().getPickListValues();
            List<selectOption> options = new List<selectOption>();
           for (Schema.PicklistEntry a : pick_list_values) {
                      options.add(new selectOption(a.getLabel(), a.getValue()));
          }
      return options;
}
 public List<SelectOption> getTypes1(){
            Schema.sObjectType sobject_type = Contact.getSObjectType();
            Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
            Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
            List<Schema.PicklistEntry> pick_list_values = field_map.get('select_multipl__c').getDescribe().getPickListValues();
            List<selectOption> options = new List<selectOption>();
           for (Schema.PicklistEntry a : pick_list_values) {
                      options.add(new selectOption(a.getLabel(), a.getValue()));
          }
      return options;
}
}
Test class:
@isTest
public class TestmyAccount {
    @isTest static void myAccountTest(){
        Contact c = new Contact(LastName='lastName1');
            insert c;
        Attachment objA=new Attachment();
            objA.body = Blob.valueOf('photourl');
            objA.Name = 'filename';
            objA.parentid= c.id;
            objA.ContentType = 'Applications';
            insert objA;
        string ids = objA.Id;
            c.imageUrl__c = 'imageurl';
            c.urlToImage__c = 'photourl';
            update c;
        Test.startTest();
            myAccount acc =new myAccount(new ApexPages.StandardController(c));
       /* ApexPages.StandardController sc = new ApexPages.StandardController(c);
        myAccount acc = new myAccount(sc);*/
        acc.UploadPhoto();
        List<Attachment> attachments=[select id, name from Attachment where parent.id=:c.id];
        System.assertEquals(1, attachments.size());

        acc.Photo=Blob.valueOf('photourl');
        acc.filename='filename';
        acc.contenttype='Applications';
        acc.photoname='photoname';
        acc.photourl='photourl';
        
        List<SelectOption> sel = acc.getTypes();
        List<SelectOption> selist = acc.getTypes1();
        Test.stopTest();
    }
}
select id,createddate from someObject

and my query is returing list of sObjects with its data and Createddate
and then i am assigning this list of sobject to my attribute of lightning component like this
var action = component.get("c.getResponseHistory");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {  
                component.set("v.responseObject",response.getReturnValue());
                             
            }
         });
        $A.enqueueAction(action);
for each record i dont want to assign full datetime as createddate return datetime i want createddate to be converted to only date for each record

Please help me to do this 
Thanks
 
Hi Team,

I haveuploaded a ppt document in static resources.
I want to create formula field and display the link which we have uploaded in static resources.

please let me know how can we do this?


Thanks
Lakshmi.
 
I'm new to slaesforce.I want to create test class for my below code:

public class AccountContOpptCheckBoxController {
    
    public List<Account> acctList{get;set;}
    public List<Contact> conList{get;set;}
    public List<Opportunity> oppList{get;set;}
    public List<ContactWrapper> conWrList{get;set;}
    public List<OpportunityWrapper> opportList{get;set;}
    public List<Contact> selectedContacts{get;set;}
    public List<Opportunity> selectedOpportunities{get;set;}
    //public List<StoreAccountData__c> storeList{get;set;}
    public List<StoreAccountData__c> storedList= new List<StoreAccountData__c>();
     
    Set<ID> acctIds = new Set<ID>();
    
    public AccountContOpptCheckBoxController(ApexPages.standardController controller){  
        getAccountDetails();
        for(Account ac: acctList){ 
            if(ac.Id != null){
                acctIds.add(ac.Id);
            } 
        }
    }
    
    public List<Account> getAccountDetails() {    
           acctList = Database.query('SELECT Name FROM Account LIMIT 1');
        return acctList;
 }
    
    public PageReference reset() {
        
       PageReference newpage = new PageReference(System.currentPageReference().getURL());   
   newpage.getParameters().clear();
   newpage.setRedirect(true);
   return newpage;
        
    }
    
    public class ContactWrapper {
     public boolean cb {get;set;}
     public Contact contct {get;set;}

     public ContactWrapper(Contact contct){
          cb=false;
          this.contct = contct;
     }
}
    
    public class OpportunityWrapper {
     public boolean cbOp {get;set;}
     public Opportunity oppornty {get;set;}

     public OpportunityWrapper(Opportunity oppornty){
          cbOp=false;
          this.oppornty = oppornty;
     }
}
    
    public Pagereference getContacts() {
        if(conWrList == null) {
            conWrList = new List<ContactWrapper>();
            for(Contact c : [select id,name,phone,accountId from contact where accountid in : acctIds]) {
                conWrList.add(new ContactWrapper(c));
            }
        }
        return NULL;
    }
    
        public Pagereference getOpportunitiess() {
        if(opportList == null) {
            opportList = new List<OpportunityWrapper>();
            for(Opportunity p : [select id,name,StageName,AccountId from Opportunity where accountid in : acctIds]) {
                opportList.add(new OpportunityWrapper(p));
            }
        }
        return NULL;
    }
    
    public List<Contact> getSelectContactDetails()
    {
        selectedContacts = new List<Contact>();
        if(conWrList!=null){
            for(ContactWrapper cCon : conWrList) {
                if(cCon.cb == true) {
                    selectedContacts.add(cCon.contct);
                }
            }
        }
        return selectedContacts;
    }
    
    public List<Opportunity> getSelectOpporDetails()
    {
        selectedOpportunities = new List<Opportunity>();
        if(opportList!=NULL){
            for(OpportunityWrapper Opt : opportList) {
                if(Opt.cbOp == true) {
                    selectedOpportunities.add(Opt.oppornty);
                }
            }
        }
        return selectedOpportunities;
    }
    
    public PageReference submit() {
        PageReference np = new PageReference('/apex/FetchAcctContactOpprCheckboxPage');
        np.setRedirect(false);
        return np;
    }
     public PageReference back() {
        PageReference bp = new PageReference('/apex/AccountContOpptCheckboxPage');
        bp.setRedirect(false);
        return bp;
    }
    
    public PageReference confirm() {
        
        List<StoreAccountData__c> storeList= new List<StoreAccountData__c>();
        
        if(selectedContacts!=null){
            for(Contact ct:selectedContacts){
                StoreAccountData__c sd= new StoreAccountData__c();
                //ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.INFO,'Select Name--'+ct.AccountId));
                sd.AccountStore__c=ct.AccountId;
                sd.Name=ct.Name;
                sd.Phone__c=ct.Phone;
                storeList.add(sd);
            }
        }
        
        if(selectedOpportunities!=null){
             for(Opportunity op:selectedOpportunities){
                StoreAccountData__c sd1= new StoreAccountData__c();
                sd1.AccountStore__c=op.AccountId;
                sd1.OppName__c=op.Name;
                sd1.StageName__c=op.StageName;
                storeList.add(sd1);
            }
        }
        insert storeList;     
        ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.INFO,'Records added successfully'));
        return NULL;
    }
}
I have Used jQuery DataTable Plugin In Salesforce Lightning Component . Now i want to remove unwanted sorting symbols in my table  from the loaded scripts.
So any one help me on this. Thanks in advance...

Ref Image:

User-added image
User-added image

Thanks
Venkat

 
I have Used jQuery DataTable Plugin In Salesforce Lightning Component . Now i want to remove unwanted css clases from the loaded scripts.
So any one help me on this. Thanks in advance...

User-added image

I Want to remove the highlighted css classes from the loaded scripts.
================================================================

Code Snippet:

.This  .dataTables_length {
    color: white!important;
}


User-added image

But in select option also i am getting white color, due to that i am unable to see the size of the paze like 10, 25, 50, 100. So i want to give another background color for select option only.This is all because of my page background color is black but it is mandatory.

Thanks 
Venkat


 
Hi Gurus, 

I have writen a very short apex code to be able redirect from one Visualforce page to another however, I now have to write a test class, which i am awful at :D 

So it would be great if someone could please assist me :)  

This is my short apex code for the redirection:
 
public with sharing class CustomerSatisfaction
 { public String currentRecordId {get;set;}

  public CustomerSatisfaction (ApexPages.StandardController controller)
    { this.currentRecordId = ApexPages.CurrentPage().getparameters().get('id');}
  
  public PageReference UK_Flag () {                   
           PageReference pageref = new 
                     PageReference('/apex/CustomerSatisfaction_EN?Id='+currentRecordId); 
                     pageref.setRedirect(true);
                     return pageref;}
 
      public PageReference France_Flag () {                   
           PageReference pageref = new 
                     PageReference('/apex/CustomerSatisfaction_FR?Id='+currentRecordId); 
                     pageref.setRedirect(true);
                     return pageref;}
 
}

If someone know how I could write the test then please let me know! Thanks!!
User-added image

i want display lightning:helpText along with lable of lighting:input field.
<aura:component>
    <lightning:helptext content="Your Name will be your login name" />
	<lightning:input label="Name" name="myname" required="true"/>
</aura:component>



Thanks in advance
Hi Team,

I am accessing the image in to my component  from the static resource. Now i want to implement the onMouseover event on that image.
When onMouseover on that image the background color should change to some other color.
Please help me on this. 
                                     Thanks in advance...
Code Snippet:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <lightning:layout >

                                    <lightning:layoutItem size="3" padding="around-small">
                                        <div >
                                            <img style="height: 500px;" src="/resource/Mouseover/" /></div>
                                            
                                        
                                    </lightning:layoutItem>
    </lightning:layout>
</aura:component>
===================================
Reference Image:

User-added image
ChildComponent
--------------
<aura:component >
    <ui:button label="click me" press="{!c.hanldeClick}"/>
    <aura:registerEvent name="componentevent" type="c:SimpleComponentEvent"/>
</aura:component>

SimpleComponentEvent.evt
------------------------
<aura:event type="component" description="component" >
 <aura:attribute name="message" type="string"/>
    </aura:event>
    
    controller
    ------------
    ({
    hanldeClick : function(component, event, helper) {
        var v1=component.get("componentevent");
        v1.setParams({
            "message":'Welcome to sfdcscenarios.blogspot.com'
        });
        v1.fire();
        
        
    }
})


ParentComponent
---------------
<aura:component >
    <aura:attribute name="EventMessage" type="String"/>
    <aura:handler name="componentevent" event="c:SimpleComponentEvent" action="{!c.hanldeParent}"/>
    <c:ChildComponent/>
    {!v.EventMessage}
</aura:component>




Controller
-----------
({
    handleParent: function(component, event, helper) {
        var message = event.getParam("message"); 
        cmp.set("v.EventMessage", message + 'brahmanaidu');         
    } 
    
    
})

Hi All, 

I was wondering if there is any way of updating an account field in APEX if i have the account ID in the Triggered Object. Right now i am running into the issue that I can not do the following (Trigger is on the Opportunity).

List <Account> AccountsInHierarchy = [SELECT Field_A, Field_B, Field_C
                                      FROM     Account
                                      WHERE  Ultimate_Parent_ID__c = Trigger.new.Account.Ultimate_Parent_Id__c
                                     ];

Whenever I do this I get the following error: 
System.LimitException: Too many query rows: 50001
 

I have already tried limiting the numbers returned by my SOQL Query but the error persisted. Any help would be much appreciated. 

Best, 

FD


 

what is the advantages of querying data withing the for loop itself like below

for(Account a:[select name from Account])
{
***logic***
}
Hi Guys,

I have created a data table for custom sobject(test__c) list view.
I used SOQL query to get all the required fields (some are standard fields - Account and contact name) related to test__C.

But the issue here is, when the user clicks the standard fields, they should be able to navigate the Account and contact name pages respectively. For that, I need to make these as hyperlink fileds.

I am not sure how to proceed for this. Any help is appreciated.

Thanks!!
 
  • April 25, 2018
  • Like
  • 0
Hello All,
                 I am new to salesforce. I dont have any idea about soap api, REST api. but i have to learn it. 
Anybody please suggest,where i can learn api and how??
I have a lightning component and it has an apex controller. I would like to call a @InvocableMethod of an another class from the ligtning component conroller @auraenble method. Is this possible? If so could you please provide an example

Thanks 
Gopinath
Hello,

i have made only 5 tabs as Default on.All other tabs have been made as Tab hidden.

Haing said that,all the 5 tabs are visible.Apart from that + button is also visible.My client does not need + button after the 5 tabs.

Is there any way I can hide the + button in Salesforce classic.

Any help is highly appreciated.

Thanks & Regards,
Harsha BR

Thanks & Regards,
Harsha BR
public class Map_Opportunities {
    public Map<string,List<Opportunity>> oppMap        {set;get;}    
    public List<Account> accList                    {set;get;}
    
    public Map_Opportunities(){
        oppMap = new Map<string,List<Opportunity>>();  
        accList=new List<Account>();
        
        accList = [SELECT name,(SELECT Name,stageName FROM Opportunities)FROM Account];
        for (Account a :accList){
            oppMap.put(a.Name, a.Opportunities);
        }                    
    }
}
-------------------------------------------
Test Class
--------------------------------------------
@isTest
    static void mapOpportunits(){
        Map_Opportunities mp = new Map_Opportunities();
        List<Opportunity> optyList = new List<Opportunity>();
        account acc = new Account();
        acc.name = 'Ravi';
        insert acc;
        
        opportunity op = new Opportunity();
        op.Name = 'Xyz';
        op.AccountId = acc.id;
        op.CloseDate = system.today();
        op.StageName ='Closed Won';    
        optyList.add(op);
        insert optyList;
        mp.oppMap.put(acc.Name, optyList);
    }
85% code is covered and Displaying Error : oppMap.put(a.Name, a.Opportunities);
public class Map_Accounts {   
    public Map<Id,Account> accMap        {set;get;}
    public List<Account> accList         {set;get;}
    public Account a                    {set;get;}    
    // Constructor
    public Map_Accounts(){
        accMap = new Map<id,Account>();         
        accList=[Select Id, Name from Account limit 5];
        accMap.putAll(accList);
              
        for (Id idKeys : accMap.keySet()){
            a = accMap.get(idKeys);
        }        
    }  
}
Best Practice : When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.

User-added image


      That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it. 

Thanks #Copy_Steve Molis
Best Practice : When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.

User-added image


      That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it. 

Thanks #Copy_Steve Molis
Hi,

Is salesforce ligthtning is ruling now ? Is it necessary to learn lightning as developer? what will be used in lightning development and what are prerequisites to learn it.?

Thank you
Hi friends...
Am struggling to write Test class for below code for Getting Lead...please help me t's urgent..



public static Lead getLead(String recordId) {
  Lead lead = [Select id,Status,Status__c  from Lead where id=:recordId]; 
  return lead;
    } 



Thanks
Chandu
When we use Iframe for opening a report in Visualforce page, It is appearing with the "Rectangle line" as below. If we scroll down to bottom, the top data is disappearing. Can we remove the "Rectangle line" to make the data appear? or is there any tag to open the report(URL) through the getter methods in Visualforce page Itself. 

User-added image

Visualforce Code:

<div class="container">
                    <apex:iframe src="{!ReportsTabularUrl}" scrolling="false" id="theIframe" />
                    <script>document.getElementById('theIframe').height = window.innerHeight - 210;</script>
                </div>

Can anyone please help on this?. Thanks.




 
public class LightningDataTableController {
    /*
Method Name : getAccRecords
Purpose : To get the wrapper of Columns and Headers
*/
    @AuraEnabled
    public static DataTableResponse getAccRecords(String strObjectName, String strFieldSetName){                
      
        //Get the fields from FieldSet
        Schema.SObjectType SObjectTypeObj = Schema.getGlobalDescribe().get(strObjectName);
        Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();            
        Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get(strFieldSetName);
        
        //To hold the table hearders
        List<DataTableColumns> lstDataColumns = new List<DataTableColumns>();
        
        //Field to be queried - fetched from fieldset
        List<String> lstFieldsToQuery = new List<String>();
        
        //The final wrapper response to return to component
        DataTableResponse response = new DataTableResponse();
        
        for( Schema.FieldSetMember eachFieldSetMember : fieldSetObj.getFields() ){
            String dataType = String.valueOf(eachFieldSetMember.getType()).toLowerCase();
            //This way we can set the type of a column
            //We do not get the exact type from schema object which matches to lightning:datatable component structure
            if(dataType == 'datetime'){
                dataType = 'date';
            }
            //Create a wrapper instance and store label, fieldname and type.
            DataTableColumns datacolumns = new DataTableColumns( String.valueOf(eachFieldSetMember.getLabel()) ,
                                                                String.valueOf(eachFieldSetMember.getFieldPath()),
                                                                String.valueOf(eachFieldSetMember.getType()).toLowerCase() );
lstDataColumns.add(datacolumns);
            lstFieldsToQuery.add(String.valueOf(eachFieldSetMember.getFieldPath()));
        }
        
        //Form an SOQL to fetch the data - Set the wrapper instance and return as response
        if(! lstDataColumns.isEmpty()){            
            response.lstDataTableColumns = lstDataColumns;
            String query = 'SELECT Id, ' + String.join(lstFieldsToQuery, ',') + ' FROM Account';
            System.debug(query);
            response.lstDataTableData = Database.query(query);
        }
        
        return response;
    }
    
    //Wrapper class to hold Columns with headers
    public class DataTableColumns {
        @AuraEnabled
        public String label {get;set;}
        @AuraEnabled      
        public String fieldName {get;set;}
        @AuraEnabled
        public String type {get;set;}
        
        //Create and set three variables label, fieldname and type as required by the lightning:datatable
        public DataTableColumns(String label, String fieldName, String type){
            this.label = label;
            this.fieldName = fieldName;
            this.type = type;            
        }
    }
    
    //Wrapper calss to hold response - This response is used in the lightning:datatable component
    public class DataTableResponse {
        @AuraEnabled
        public List<DataTableColumns> lstDataTableColumns {get;set;}
        @AuraEnabled
        public List<sObject> lstDataTableData {get;set;}                
        
        public DataTableResponse(){
            lstDataTableColumns = new List<DataTableColumns>();
            lstDataTableData = new List<sObject>();
        }
    }
}
Hello,

In "Lightning Components Basics", post "Create and Edit Lightning Components", there is a paragraph as below:
Indeed, the Developer Console has a number of features for working with Lightning Components. There’s also File | Open | Lightning Resources, which lets you open a bunch of Lightning resources all at once. Useful!
But in Developer Console, I cannot find "Lightning Resources" under "Open", instead it is File | Open Lightning Resources. Please update the post.
 
HI All , 
can any one help me with this requirement ,
1)  where when i click on parent checkbox , need to select all child checkbox
2) when i unselect parent checkbox , need to unselect all childs 
3) let us suppose i click on parent checkbox that selects all child checkbox , when i unselect one checkbox in child , the parent checkbox has to get deselected.




User-added image


 
hi folks, 
could any one please explain me :
when we write the code in the constructor, once we create the object automatically consturctor called.
But what is the use if we use that class in Visualforce page as controller, we dont create any object there right?
 what if we write the code in constructor. Could anyone please explain me.
I see below code ,what happens when we write this.
 public     AccountAndContacts()
    {
        accs=new Account();
        cts=new list<Contact>();
        add();
    }

Thanks...
var action = component.get("c.fetchData");
   action.setCallback(this, function(response) {
                        var state = response.getState();
                        console.log("State " + state);
                        if (state === "SUCCESS") {
                            var storeResponse = response.getReturnValue();
                            component.set("v.Customer", storeResponse);
                            var Credit = storeResponse.field__c;
                            console.log("Credit  "+Credit);
                        } });
                    $A.enqueueAction(action);
                }

Not able to access "response.getReturnValue();" outside of setcallback, How to do that ?
apex class:
public class myAccount {
    private final contact con;
    public string filename{set;get;}
    public string contenttype {set;get;}
    public string Conlastname{get;set;}
    public string conphone{get;set;}
    public string conemail{get;set;}
    public string Conmobilephone{get;set;}
    public string Accid='';
    public blob Photo{get;set;}
    public string photoname{get;set;}
    public string photourl{get;set;}
    //Contstructor 
   public myAccount(ApexPages.StandardController controller) {
     con=(Contact)controller.getRecord();
    }
   
    //this method updates the Contact with photourl and insert The Attachment Record
    public void UploadPhoto(){
        try{
            con.lastname = conlastname;  
            con.email = conemail;
            con.phone = conphone;
            con.mobilephone = conmobilephone;
            insert con;
           // Accid = ApexPages.currentPage().getParameters().get('id');  
           // inserting attachement with Attached photo      
            Attachment objA=new Attachment();
            objA.body = photo;
            objA.name = filename;
            objA.parentid= con.id;
            objA.ContentType = contenttype;
            insert objA;
           
            string Attid= objA.id;
            string attachmentid=Attid.substring(0,15);
             system.debug(Attid);
             con.imageUrl__c = '<img src="https://hyundaycars-dev-ed--c.ap5.content.force.com/servlet/servlet.FileDownload?file='+attachmentid+'"></img>';
           con.urlToImage__c = 'https://hyundaycars-dev-ed--c.ap5.content.force.com/servlet/servlet.FileDownload?file='+attachmentid;
            update con;
            photourl = con.urlToImage__c ;        
        }catch(Exception e){
            system.debug('Exception message'+e);
        }
     } 
     public List<SelectOption> getTypes(){
            Schema.sObjectType sobject_type = Contact.getSObjectType();
            Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
            Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
            List<Schema.PicklistEntry> pick_list_values = field_map.get('Level__c').getDescribe().getPickListValues();
            List<selectOption> options = new List<selectOption>();
           for (Schema.PicklistEntry a : pick_list_values) {
                      options.add(new selectOption(a.getLabel(), a.getValue()));
          }
      return options;
}
 public List<SelectOption> getTypes1(){
            Schema.sObjectType sobject_type = Contact.getSObjectType();
            Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
            Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
            List<Schema.PicklistEntry> pick_list_values = field_map.get('select_multipl__c').getDescribe().getPickListValues();
            List<selectOption> options = new List<selectOption>();
           for (Schema.PicklistEntry a : pick_list_values) {
                      options.add(new selectOption(a.getLabel(), a.getValue()));
          }
      return options;
}
}
Test class:
@isTest
public class TestmyAccount {
    @isTest static void myAccountTest(){
        Contact c = new Contact(LastName='lastName1');
            insert c;
        Attachment objA=new Attachment();
            objA.body = Blob.valueOf('photourl');
            objA.Name = 'filename';
            objA.parentid= c.id;
            objA.ContentType = 'Applications';
            insert objA;
        string ids = objA.Id;
            c.imageUrl__c = 'imageurl';
            c.urlToImage__c = 'photourl';
            update c;
        Test.startTest();
            myAccount acc =new myAccount(new ApexPages.StandardController(c));
       /* ApexPages.StandardController sc = new ApexPages.StandardController(c);
        myAccount acc = new myAccount(sc);*/
        acc.UploadPhoto();
        List<Attachment> attachments=[select id, name from Attachment where parent.id=:c.id];
        System.assertEquals(1, attachments.size());

        acc.Photo=Blob.valueOf('photourl');
        acc.filename='filename';
        acc.contenttype='Applications';
        acc.photoname='photoname';
        acc.photourl='photourl';
        
        List<SelectOption> sel = acc.getTypes();
        List<SelectOption> selist = acc.getTypes1();
        Test.stopTest();
    }
}
global class AccountContactCaseOpporBatch implements Database.Batchable<sObject> {
     global Database.QueryLocator start(Database.BatchableContext bc) {
        return Database.getQueryLocator(
            'SELECT ID, Name, Archival_Number_Of_Cases_Count__c, Archival_Number_Of_Contacts_Count__c, Archival_Number_Of_Oppt_Count__c,'+
            '(SELECT ID, Name, CreatedDate FROM Contacts Where CreatedDate <= LAST_N_DAYS:5),'+
            '(SELECT ID, Name, CreatedDate FROM Opportunities Where CreatedDate <= LAST_N_DAYS:5 ),'+
            '(SELECT ID, CaseNumber, CreatedDate FROM Cases Where CreatedDate <= LAST_N_DAYS:5) FROM Account'
        );
    }
    
    global void execute(Database.BatchableContext bc, List<Account> scope){
        List<Account> accounts = new List<Account>();
        List<Contact> contacts = new List<Contact>();
        List<Opportunity> opportunities = new List<Opportunity>();
        List<Case> cases = new List<Case>();
        List<ArchivalTable__c> archivTableList = new List<ArchivalTable__c>();
        
        for (Account accou : scope) {
             Integer contactProcessed = 0;
             Integer opportunityProcessed = 0;
             Integer caseProcessed = 0;

            for (Contact contct : accou.contacts) {
                //System.debug(' List of Contact Records ---'+contct);
                contacts.add(contct);
                contactProcessed = contactProcessed + 1;
            }
            for (Opportunity opport : accou.opportunities) {
                //System.debug(' List of Opportunity Records ---'+opport);
                opportunities.add(opport);
                opportunityProcessed = opportunityProcessed + 1;
            }
            for (Case cas : accou.cases) {
                //System.debug(' List of Case Records ---'+cas);
                cases.add(cas);
                caseProcessed = caseProcessed + 1;
            }
            
            if (accou.Archival_Number_Of_Cases_Count__c==null || accou.Archival_Number_Of_Cases_Count__c==0) {
                accou.Archival_Number_Of_Cases_Count__c = caseProcessed;
            }else {
                accou.Archival_Number_Of_Cases_Count__c = accou.Archival_Number_Of_Cases_Count__c + caseProcessed;
            }
            
            if (accou.Archival_Number_Of_Contacts_Count__c==null || accou.Archival_Number_Of_Contacts_Count__c==0) {
                accou.Archival_Number_Of_Contacts_Count__c = contactProcessed;
            }else {
                accou.Archival_Number_Of_Contacts_Count__c = accou.Archival_Number_Of_Contacts_Count__c + contactProcessed;
            }
            
            if (accou.Archival_Number_Of_Oppt_Count__c==null || accou.Archival_Number_Of_Oppt_Count__c==0) {
                accou.Archival_Number_Of_Oppt_Count__c = opportunityProcessed;
            }else {
                accou.Archival_Number_Of_Oppt_Count__c = accou.Archival_Number_Of_Oppt_Count__c + opportunityProcessed;
            }
            
            accounts.add(accou);
            
               //System.debug(' List of Accounts  Records ---'+accounts);
               System.debug('Account Name  '+accou.Name);
            
                ArchivalTable__c archieveData = new ArchivalTable__c();
                archieveData.ArchivalAccount__c = String.valueOf(accou.Id); 
                
                 System.debug('archieveData.ArchivalAccount__c--  '+archieveData.ArchivalAccount__c);
                    archieveData.Number_Of_Contacts_Count__c = contactProcessed;
           
                //System.debug('archieveData.Number_Of_Contacts_Count__c--  '+archieveData.Number_Of_Contacts_Count__c);

                    archieveData.Number_Of_Oppt_Count__c = opportunityProcessed;

                //System.debug('archieveData.Number_Of_Oppt_Count__c--  '+archieveData.Number_Of_Oppt_Count__c);

                    archieveData.Number_Of_Cases_Count__c = caseProcessed;

               //System.debug('archieveData.Number_Of_Cases_Count__c--  '+archieveData.Number_Of_Cases_Count__c);
                archieveData.Date__c = Date.today();
                
                archivTableList.add(archieveData);
            //System.debug('------archivTableList--  '+archivTableList);
         
        }
        
        if(cases.size()>0){
        delete cases;
        }
       
        if(contacts.size()>0){
        delete contacts;
        }
        if(opportunities.size()>0){
        delete opportunities;
        }
        
        if(archivTableList.size()>0){
        insert archivTableList;
        } 

        if(accounts.size()>0){
        update accounts;
        }
    } 

    global void finish(Database.BatchableContext bc){
        
        
        System.debug(' Records processed --- '+bc.getJobId());
        AsyncApexJob result = [SELECT Id, Status, NumberOfErrors, 
            JobItemsProcessed,
            TotalJobItems, CreatedBy.Email
            FROM AsyncApexJob
            WHERE Id = :bc.getJobId()];
        
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {result.CreatedBy.Email};
            mail.setToAddresses(toAddresses);
        mail.setSubject('Status of Contacts,opportunities and cases batch job -- ' + result.Status);
        mail.setPlainTextBody
            ('The batch Apex job processed ' + result.TotalJobItems +
             ' batches with '+ result.NumberOfErrors + ' failures.');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    } 
}

Thanks in Advance
How to add the Javascript file in Lightning component?
Using custom button code in javascript :

{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
var rc = GetRelContentIDs("{!Case.Id }");
window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Case.Id}&rc="+rc;


Lightning component:
Hoe to add the below script to my lightning component
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
 
Hi gurus,

I have this aura component which populates fields to a page however, it populates the fields under each other unfortunately.

So is there a way to move the different fields side by side, therefore the related fields will be under the main field? For example, Account 1 will be to the left of account 2, then the related fields to account 1 will be under account 1. 

Please if you know how i can do this, please let me know!
Thanks!

My Code:
<aura:component >
    <aura:registerEvent name="accountSelected" type="c:AccountSelected"/>
	<aura:attribute name="account" type="Account"/>
    <li><a onclick="{!c.accountSelected}">{!v.account.Name}</a></li>
    <div class = "Industry">
        <li><a onclick="{!c.accountSelected}">{!v.account.Industry}</a></li>
    </div>    
</aura:component>

 
  Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Schema.SObjectType sobjSchema = schemaMap.get(objtype);
        Map<String, Schema.SObjectField> fieldMap = sobjSchema.getDescribe().fields.getMap();
        List<fieldMetaData> fmdList = new List<fieldMetaData>();
        for (String fieldName: fieldMap.keySet()) {  
            String fieldlabel;
            String fieldType;
            //It provides to get the object fields label.
            fieldlabel = fieldMap.get(fieldName).getDescribe().getLabel();
          
            Schema.DisplayType FldType = fieldMap.get(fieldName).getDescribe().getType();
            fieldType = string.valueOf(FldType);
            system.debug('fieldlabel>>>>>'+fieldlabel);
             system.debug('fieldAPI****>>>>>'+fieldName);
           
            fieldMetaData fmd = new fieldMetaData();
            fmd.fieldLabel = fieldlabel;
            fmd.fieldapi = fieldName;
            fmd.fieldType = fieldType;
            fmdList.add(fmd);
        }
        return fmdList;

here i am getting API  small letters like Test__c as a test__C
can you please suggest me anyone
Why Salesforce removed all of them? U are making links in this forum not working anymore. At least do something like redirect before you make such changes. Also now when I google a component it shows nothing. Please fix this by adding a redirect.

See : https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_input.htm
select id,createddate from someObject

and my query is returing list of sObjects with its data and Createddate
and then i am assigning this list of sobject to my attribute of lightning component like this
var action = component.get("c.getResponseHistory");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {  
                component.set("v.responseObject",response.getReturnValue());
                             
            }
         });
        $A.enqueueAction(action);
for each record i dont want to assign full datetime as createddate return datetime i want createddate to be converted to only date for each record

Please help me to do this 
Thanks
 
Hi Team,

I haveuploaded a ppt document in static resources.
I want to create formula field and display the link which we have uploaded in static resources.

please let me know how can we do this?


Thanks
Lakshmi.
 
Hello everyone,
I have created a trigger which will update Contact Object field(Most_recent_Opportunity_Stage__c) whenever opportunity status gets changed.
My trigger is working fine but associated Test class is not making 75% code coverage of Trigger. I am new to salesforce and not having much experince to build test class so please help me.

Here is my Trigger and associated test class :

Trigger :

trigger UpdateMostRecentOpportunityStageOfContact on Opportunity (after update) {
  Set<String> ContactIds = new Set<String>();
     Set<String> oppIds = new Set<String>();
     if(UpdateStageOnContactHandler.isFirstTime){
             UpdateStageOnContactHandler.isFirstTime=false;
    List<OpportunityContactRole> conList = new List<OpportunityContactRole>([select ContactId from OpportunityContactRole where IsPrimary = true and OpportunityId IN :Trigger.newMap.keySet() limit 1]);
     for(OpportunityContactRole c :conList)
       {
           ContactIds.add(c.ContactId);
       }    
    List<OpportunityContactRole> oppList =  new List<OpportunityContactRole>([select ContactId,opportunityId,CreatedDate from OpportunityContactRole where IsPrimary = true and ContactId =: ContactIds order by CreatedDate desc  limit 1]);
    for(OpportunityContactRole cr :oppList)
       {
           oppIds.add(cr.opportunityId);
       } 
    if(!oppIds.isEmpty()){
    Opportunity op = [select StageName from opportunity where Id =:oppIds limit 1]; 
    List<Contact> contactToUpdate = new List<Contact>();
    for(Opportunity opp : trigger.new){
           for(OpportunityContactRole c :oppList){ 
                if(opp.AccountId != null){
                 contactToUpdate.add(new Contact(Id = c.ContactId, Most_recent_Opportunity_Stage__c=op.StageName)); 
               }
           }    
       }
       if (contactToUpdate != null && !contactToUpdate.isEmpty())
        {
            Update contactToUpdate;
        } 
     }
   }      
 }


TEST Class :

@isTest
public class TestUpdateMostRecentopportunityStage {
   static testMethod void TestUpdateStageOnContactTest()
    {   
        Account a = new Account(Name = 'TestUpdateStageOnContactTest');
        a.Type = 'Prospect';
        insert a;

        Contact newContact1 = new Contact(Lastname='TestUpdateStageOnContactTest1', AccountId = a.Id ,Email='mayanks+test1@webgility.com' );
        insert newContact1;
        
        Contact newContact2 = new Contact(Lastname='TestUpdateStageOnContactTest2', AccountId = a.Id ,Email='mayanks+test2@webgility.com' );
        insert newContact2;
    
      
        Opportunity o1 = new Opportunity(AccountId=a.Id, name='OPP test1', StageName='Demo', CloseDate = Date.today() );
       insert o1;
        OpportunityContactRole ocr1 = new OpportunityContactRole(OpportunityId = o1.Id, ContactId = newContact1.Id, Role='Decision Maker',Isprimary=true );
        insert ocr1;
        
          Opportunity o2 = new Opportunity(AccountId=a.Id, name='OPP test2', StageName='Open', CloseDate = Date.today() );
       insert o2;
        OpportunityContactRole ocr2 = new OpportunityContactRole(OpportunityId = o2.Id, ContactId = newContact2.Id, Role='Decision Maker',Isprimary=true );
        insert ocr2;
        
          Test.StartTest();
        o1.stageName='Demo';
        update o1;
        newContact1.Most_recent_Opportunity_Stage__c='Demo';
        update newContact1;
        
         o2.stageName='Open';
        update o2;
        newContact2.Most_recent_Opportunity_Stage__c='Open';
        update newContact2;
        
        Test.StopTest();
         
      }   
}


Thanks,
Mayank
User-added image

i want display lightning:helpText along with lable of lighting:input field.
<aura:component>
    <lightning:helptext content="Your Name will be your login name" />
	<lightning:input label="Name" name="myname" required="true"/>
</aura:component>



Thanks in advance
My apex controller method takes enum as paramer, that method will be called from lightning component java script controller,How Can I access Enum in lightning component?
<aura:iteration items="{! v.fields }" var="field">
           
            <div class="slds-size_5-of-12">
                <lightning:input aura:id="idName"   label="{!field.Label}"  required="{!field.DBRequired}"  type="{!field.Type}" class="slds-p-top_small slds-m-top_medium" />
            </div>
             <div class="slds-size_1-of-12"></div>
            </aura:iteration>
and i want  ,whatever i type in input box of firstname,lastname or whatever  the value of that field should be store in attribute of type Contact otherwise i want all the data as Json in lightning component  Js controller  Please help me to solve this...
  • April 25, 2018
  • Like
  • 1
Challenge Not yet complete... here's what's wrong: 
Could not find a custom field on the Account object with the API Name 'Support_Plan_Start_Date__c'.User-added image
I am pretty new at this and trying to create a lightning component so that community users that can't remember their username are able to enter an email address to retrieve their username. If the email they enter matches an existing user account's listed email address it will kick an email to that address with the username of the account. Anyone have anything or knowledge of an open source resource that might have something similar? Thank you!
Hi ,
I have implemented Digital signature using Visualforce pages and java script. It's working good in desktop and Ipad. I am facing problems in android devices. Can some one suggest the possible solution for this OR share thoughts/implementation using Lightning components please ? 

Regards,
Chethan.S.N
Hi ,

I am getting an issue when uploading jquery script file  to get pagination in lightning component.
Issue is  
Uncaught TypeError: Cannot read property 'expando' of undefined throw

 
I am using a lightning:datatable to display various fields, including a URL field which links to a printable PDF.

In the Spring 18 release, the URL field in the datatable now points to "javascript:void(0)" in the href attribute and the title attribute now contains the url which I am trying to set in the href field. 

Can someone please provide me a code example on how to get the href refrecne to work correctly?
Hi All,  

Just had a query, how can I create a custom tab on accounts page like news, related list, details in lightning? Also, how can that be brought in salesforce1 app?  We had creted such custom tabs in the account page b ut those are  visible only in desktop but not in mobile. What am I missing?

Thanks for the response
Hi 

I have scnerio where I need to capture IP address of current User in Lightning Community, is any way standard way  where I can capture IP address inside Lightning Components.
I have seen third party tools like - https://www.ipify.org/ to get Ip address 
Any recommendations are appreciated 

Thanks 
Hi all,

Im currently facing an issue with the "e.force:createRecord" when trying to pre populate some fields from an object to another one. Im using the "defaultFieldValues" and almost every field is populated correctly (Lookup, text,etc) except Currency and Master-Detail.

For your understanding of the issue, when i query the data and show it on the console its shows completly fine ("234" currency field), but at the moment to pre populate it just dont, it keeps the field blank. Also ive tried to: ParseInt, Integer the value, and nothing.
Also, the fuctionallity on Classic mode it working fine, so its not a permision issue (Profile, FLS,etc).

Do you know why is this happenening? Happens to 2 different currency field and also to the master-detail (havent reasearch or even tried anything on this but if you can help also i will appreciate it).

Thanks!!
Hi All,

Getting the below error when i click on quick action containing a lightning component. 
Action failed: forceChatter:lightningComponent$controller$doInit (undefined is not an object (evaluating 'fn-apply')]

quickActionHandlerHelper.js failed to create component - forceChatter:lightningComponent

Let me know what the issue could be.
<aura:component controller="SOWManager_CTL" implements="flexipage:availableForAllPageTypes">

      <aura:attribute name="theaters" type="String[]"/>
      <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
      <form>      
           <div class="header">
               <div style="margin-left:15%;float: left; margin-top:0.5%;" >
                 SOW ID : <ui:outputText aura:id="sowID"  value="{!v.Name}" />
             </div>
             <div style="margin-left:50%;float: left;margin-top:0.5%;">
                 SOW Status : <ui:outputText aura:id="sowStatus"   value="{!v.SOW_Status__c}" />
             </div>
         </div>     
        <lightning:tabset >
        <lightning:tab label="General Info">
             <fieldset class="slds-form--compound" style="margin-left:15%;margin-right:15%">
               <div class="slds-form-element__group">
                <div class="slds-form-element__row">
                  <div class="slds-form-element slds-size--1-of-2">
                      <lightning:select  name="theaterGeo"  label="Theater/Geography" required="true">
                          <option value="" text="Select Theater/Org"></option>
                          <aura:iteration items="{!v.theaters}" var="theater">
                            <option value="{!theater}" text="{!theater}"></option>
                        </aura:iteration>
                    </lightning:select>
                  </div>
                  <div class="slds-form-element slds-size--1-of-2">
    
                   </div>
                </div>
              </div>
            </fieldset>
        </lightning:tab>
 
    </lightning:tabset>

        
       
    </form>
</aura:component>
HI,
I am working on lightning component where I need progress indicator. I am using slds progress indicator but it is not showing css same as shown in the slds guide.
I have used the same code mentioned in the guide.https://www.lightningdesignsystem.com/components/progress-indicator/#flavor-base-default
But still it is not showing connecting line of two button. please find screenshot of issue.User-added image
According to guide image bar should look likeUser-added image

Please help me on the same

Thanks
Shikha
One approach we have tried is having a Lightning Component with a button and adding the component to the specific record page, however this approach makes the UI inconsistent.
Is there a way for one component to reference the functions in another without embedding?

If I have to embed the component, how do I reference there parent function from a  child component and vice versa?
Hi folks, 

I try to complete the "Build a Battle Station App" -> Modify the User Experience. Trail to complete. I checked everything and did it 3 times but every time I get the error:

Challenge Not yet complete... here's what's wrong: 
The 'Resources' related list was not found on the Page Layout 
Note: you may run into errors if you've skipped previous steps.

The Resources Column is in the Page Layout and I add the needed objects. 

Anybody an Idea?
Hi All,
Is there a way to bookmark a question from this forum?
Suppose a come across a question and I want to bookmark that question for future refrence. Can I do that?
Currently I am commenting on the already answered questions as a way to bookmark it.

Thanks,
Sathwick
Hi,
I was going through practice session about constructors but my program keeps on failing

I used the code:
public class TestObject2{
    private static final Integer DEFAULT_SIZE = 10;

    Integer size;

   //Constructor with no arguments
   public TestObject2() {
       this(DEFAULT_SIZE); // Using this(...) calls the one argument constructor    
   }

   // Constructor with one argument 
   public TestObject2(Integer ObjectSize) {
     size = ObjectSize;  
   }
}


and At Execute Anonymous Window Giving:

TestObject2 myObject1 = new TestObject2(42);
TestObject2 myObject2 = new TestObject2();

I am getting an error:

Line: 1, Column: 25
Constructor not defined: [TestObject2].<Constructor>(Integer)

What is wrong here?

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.