• sfdcMonkey.com
  • ALL STAR
  • 12238 Points
  • Member since 2016
  • Salesforce Developer
  • ACS


  • Chatter
    Feed
  • 374
    Best Answers
  • 20
    Likes Received
  • 25
    Likes Given
  • 2
    Questions
  • 1385
    Replies
calculate next working day excluding weekend (sat-sun) and public holidays in lightning web component [lwc]
i am not able to debug my lightning web component javaScript code. am using console.log / window.alert() statements. but it's showing following error :
Unexpected console statement. eslint(no-console)
Unexpected console statement. eslint(no-alert)

any help will be appreciated
Hi

I am having a piece of code that will open an external URL.

whhen I click the button it will open the URL in a web tab on the browser.

here's the code
 <a href="javascript:void(0);" onclick="{!c.openMyProviderPage}">Find provider</a>  

In the controller of the component

 openProviderPage : function(component, event, helper) {
        debugger;
         var pageUrl = component.get("v.findMyProviderURL");
        var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({"url": pageUrl });
        urlEvent.fire();
       
I do not want the new URL to open in a separate browser window i.e the new URL should open as a subTab inline.

I hope my requirement is clear.

Please help me out at earliest.


 
Hi,

Can someone help me with a test class for the below code?
It's a list view with a cloned functionality.

public with sharing class cloneCaseApplication {
@AuraEnabled
public static List < Case > cloneCaseApp() {
//Create variables
String currentuser = UserInfo.getUserId();
String emailAddress = UserInfo.getUserEmail();
Id userContactId = [Select contactid from User where id =: Userinfo.getUserid()].contactId;
List < String > caseRecordtype = new List <String> ();
List < Case > casListCommunity = new List <case>();
List < Case > casListInternal = new List <case>();
system.debug('currentuser' + currentuser);
system.debug('userContactId' + userContactId);
// Add recordtype to list
caseRecordtype.add('Produksjonstilskudd');
caseRecordtype.add('Produksjonstilskudd_ny');
// Create list of all accounts which current user is linked to
List < Account > userAccounts = [SELECT Id,
name
FROM Account
WHERE Id IN(SELECT accountId FROM AccountContactRelation WHERE contactId =: userContactId)];
System.debug('userAccounts' + userAccounts);
// List all cases for accounts linked to user
if (userContactId != null) {
List < Case > cas = [SELECT Id,
Casenumber,
FROM Case
WHERE AccountId IN: userAccounts
AND RecordTypeId IN: caseRecordtype];
return cas;
}
else {
List < Case > casempt = [SELECT Id,
CaseNumber,
Account.Name
FROM Case
//WHERE RecordTypeId IN : caseRecordtype
LIMIT 20];
System.debug('casempt' + casempt);
return casempt;
}
}
@AuraEnabled
public static Boolean cloneRecord(String recId) {
system.debug('RecordToClone' + recid);
List < Case > toBeCloned = new List < Case > ();
Case cloneThis = [SELECT Id, CaseCloned__c FROM Case WHERE ID =: recId];
system.debug('clonethis' + cloneThis);
system.debug('this fires');
if (clonethis != null && Clonethis.CaseCloned__c != true) {
Case CloneTest = cloneThis.clone();
cloneThis.CaseCloned__c = true;
insert clonetest;
update clonethis;
system.debug('clontest' + clonetest);
return true;
} else if (Clonethis.CaseCloned__c == true) {}
return false;
}
}
I tried but my code is not working
trigger AttachmentTrigger on Attachment (before insert) {
    Set<Id> attid = new Set<Id>();  
    for(Attachment att : Trigger.new){
        attid.add(att.parentId);
        
    }
    Map<Id,Account> acMap = new Map<Id,Account>([select id,(select id,parentId from attachments) from Account where Id IN : attid]);

    for(Attachment att : Trigger.New){
       
        if(acMap.get(att.parentId).attachments.size() > 4 ){
            
            att.adderror('You can not add more than 4 attachments!');
        }
    }
}

Can someone help me on this
How can I show the current user photo in the custom community lightning theme? I would like to add current user image on a custom component that I created.
Hi All,
I am trying to display the Account records on Visual Force Page where Phone and fax fields values are equal. 
I have written a Controller and design a VF page. But when I am clicking on "Display records" Button then I am getting below error.
Visualforce Error
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!display}' in component <apex:commandButton> in page displayrecords: Class.DispalyMatchingRecords.display: line 9, column 1
Class.DispalyMatchingRecords.display: line 9, column 1
I tried to debug this, Actually while adding the value in "acc" list its throwing the error.
Could anyone help me out here. Actually I am not having much knowledge of VF pages so not sure where I am doing wrong.

VF Page:- 
<apex:page controller="DispalyMatchingRecords" >
    <apex:form>
    <apex:pageBlock>
        <apex:pageBlockTable value="{!acc}" var="a">
        <apex:column value= "{!a.Id}"/>
            <apex:column value= "{!a.Name}"/>
        </apex:pageBlockTable>
<apex:commandButton value="Display Records" action="{!display}"/>  
    </apex:pageBlock>
        </apex:form>
</apex:page>

Controller:-
public class DispalyMatchingRecords {

   public List<Account> acc {get;set;}
    public void display(){
        List<Account> ac =[Select Id, Name, Phone,Fax from Account];
        for(Account a: ac){
            if(a.Phone != null && a.Fax != null){
                if(a.Phone == a.Fax){
                    acc.add(a);
                }
            }
        }
    }
}
Hi All,

I want to use counter inside aura: iterator. Like below

<aura:attribute name="counter" type="integer" default="0"/>

<aura:iteration items="{!v.futureInteractions}" var="Interaction">
  <aura:if istrue="{!v.counter =0 && Interaction.isFutre}">
      Futre interaction
     <aura:set attribute="counter" value="1" />
  </aura:if>
</aura:iteration>

Can anyone help me how can i change counter value inside iterator???
<lightning:button class="slds-button" variant="base" value="{!usr.UserId}" label="{!usr.Username}" onclick="{!c.openuserqueue}" />
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
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.
 
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!!
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 All,
How to write test class for this controller class:-

public with sharing class DescribeHelper {
 
    public static List<SObjectFieldWrapper> getSortedFieldSetFields(String sObjectName, String fieldSetName) {
        List<SObjectFieldWrapper> objFields = new List<SObjectFieldWrapper>();
        //describe the provided sObject
        Schema.DescribeSObjectResult res = Schema.getGlobalDescribe().get(sObjectName).getDescribe();
        Map<String, Schema.FieldSet> fieldSetMap = res.fieldSets.getMap();
        Schema.FieldSet fs = fieldSetMap.get(fieldSetName);
        for(Schema.FieldSetMember fsm : fs.getFields()) {
            SObjectFieldWrapper sfw = new SObjectFieldWrapper();
            sfw.fieldName = fsm.getFieldPath();
            sfw.fieldType = fsm.getType().name();
            sfw.fieldLabel = fsm.getLabel();
            sfw.required = fsm.getRequired() || fsm.getDbRequired();
            objFields.add(sfw);
        }
        //objFields.sort();
        return objFields;
    }

    public class SObjectFieldWrapper implements Comparable {
        @AuraEnabled
        public String fieldName {get; public set;}
        @AuraEnabled
        public String fieldLabel {get; public set;}
        @AuraEnabled
        public String fieldType {get; public set;}
        @AuraEnabled
        public Boolean required {get; public set;}
        
        public Integer compareTo(Object withObj) {
            SObjectFieldWrapper compareTo = (SObjectFieldWrapper) withObj;
            return fieldLabel.compareTo(compareTo.fieldLabel);
        }
    }
}
Can anyone help me with test class of it?
Thanks
calculate next working day excluding weekend (sat-sun) and public holidays in lightning web component [lwc]
i am not able to debug my lightning web component javaScript code. am using console.log / window.alert() statements. but it's showing following error :
Unexpected console statement. eslint(no-console)
Unexpected console statement. eslint(no-alert)

any help will be appreciated
Hello,

When a lead is converted, how can i find out the lead whcih is associated with the Contact.
I want t find out the leadfrom the contact.

Wthank you for suggestion
  • May 03, 2019
  • Like
  • 0
Hi

I am having a piece of code that will open an external URL.

whhen I click the button it will open the URL in a web tab on the browser.

here's the code
 <a href="javascript:void(0);" onclick="{!c.openMyProviderPage}">Find provider</a>  

In the controller of the component

 openProviderPage : function(component, event, helper) {
        debugger;
         var pageUrl = component.get("v.findMyProviderURL");
        var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({"url": pageUrl });
        urlEvent.fire();
       
I do not want the new URL to open in a separate browser window i.e the new URL should open as a subTab inline.

I hope my requirement is clear.

Please help me out at earliest.


 
I want to fetch (attachment) files id after inserting attachments under the Account record in lightning experince by using trigger.
Hi,

Can someone help me with a test class for the below code?
It's a list view with a cloned functionality.

public with sharing class cloneCaseApplication {
@AuraEnabled
public static List < Case > cloneCaseApp() {
//Create variables
String currentuser = UserInfo.getUserId();
String emailAddress = UserInfo.getUserEmail();
Id userContactId = [Select contactid from User where id =: Userinfo.getUserid()].contactId;
List < String > caseRecordtype = new List <String> ();
List < Case > casListCommunity = new List <case>();
List < Case > casListInternal = new List <case>();
system.debug('currentuser' + currentuser);
system.debug('userContactId' + userContactId);
// Add recordtype to list
caseRecordtype.add('Produksjonstilskudd');
caseRecordtype.add('Produksjonstilskudd_ny');
// Create list of all accounts which current user is linked to
List < Account > userAccounts = [SELECT Id,
name
FROM Account
WHERE Id IN(SELECT accountId FROM AccountContactRelation WHERE contactId =: userContactId)];
System.debug('userAccounts' + userAccounts);
// List all cases for accounts linked to user
if (userContactId != null) {
List < Case > cas = [SELECT Id,
Casenumber,
FROM Case
WHERE AccountId IN: userAccounts
AND RecordTypeId IN: caseRecordtype];
return cas;
}
else {
List < Case > casempt = [SELECT Id,
CaseNumber,
Account.Name
FROM Case
//WHERE RecordTypeId IN : caseRecordtype
LIMIT 20];
System.debug('casempt' + casempt);
return casempt;
}
}
@AuraEnabled
public static Boolean cloneRecord(String recId) {
system.debug('RecordToClone' + recid);
List < Case > toBeCloned = new List < Case > ();
Case cloneThis = [SELECT Id, CaseCloned__c FROM Case WHERE ID =: recId];
system.debug('clonethis' + cloneThis);
system.debug('this fires');
if (clonethis != null && Clonethis.CaseCloned__c != true) {
Case CloneTest = cloneThis.clone();
cloneThis.CaseCloned__c = true;
insert clonetest;
update clonethis;
system.debug('clontest' + clonetest);
return true;
} else if (Clonethis.CaseCloned__c == true) {}
return false;
}
}
Hi all, so I am getting the error "No base file for markup" while trying to do the LWC trailhead. I have seen that all LWC need to have the same name as the folder containing them, and named accordingly, but I am still getting the same error. I tried typing out the components and also copying/pasting the code from the trailhead, and still getting the same error. Here's the component code..
<template>
<div>
<div>Name: {name}</div>
<div>Description: {description}</div>
<lightning-badge label={material}></lightning-badge>
<lightning-badge label={category}></lightning-badge>
<div>Price: {price}</div>
<div><img src={pictureUrl}/></div>
</div>
</template>
 
The JS code...
import { LightningElement } from 'lwc';
export default class BikeCard extends LightningElement {
name = 'Electra X4';
description = 'A sweet bike built for comfort.';
category = 'Mountain';
material = 'Steel';
price = '$2,700';
pictureUrl = 'https://s3-us-west-1.amazonaws.com/sfdc-demo/ebikes/electrax4.jpg';
}
 
And the config code...
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
User-added image
I tried but my code is not working
trigger AttachmentTrigger on Attachment (before insert) {
    Set<Id> attid = new Set<Id>();  
    for(Attachment att : Trigger.new){
        attid.add(att.parentId);
        
    }
    Map<Id,Account> acMap = new Map<Id,Account>([select id,(select id,parentId from attachments) from Account where Id IN : attid]);

    for(Attachment att : Trigger.New){
       
        if(acMap.get(att.parentId).attachments.size() > 4 ){
            
            att.adderror('You can not add more than 4 attachments!');
        }
    }
}

Can someone help me on this
Hi All,

Here is the scenario : 
On the account object, create a new field to store the date and time stamp of the most recent change to the account name or the account address.

I have written th code but it's not working.. could any please help me out to correct it?? Is it possible to update date on changes without querying any account in class??

public class AccountHandler {
    public static void updateAccount(List<Account> accountList, Map<Id,Account> oldAccountMap)){
        
        Set<Id> accid = new Set<Id>();
               
        If(accid.size()>0){
            
            List<Account> accList = [SELECT Id, Name, Physical_Address__c from Account where Id in:accid);
            
            if(accList.size()>0){
                
                for(Account acc:accList) {
                    
                    if(Trigger.IsUpdate && !oldAccountMap.isEmpty() && oldAccountMap.containsKey(acc.Id) &&
                    ((oldAccountMap.get(acc.Id).Name != acc.Name || oldAccountMap.get(acc.Id).Physical_Address__c != acc.Physical_Address__c)){
                        acc.Address_Change_Date__c = System.now();
                    }                    
                }
            }        
            Update accList;
        }
    }
}


I am calling this method in after update.. from trigger controler...
Can we sort wrapper List by Date?
Hi, I'm using the below code in visualforce page, it is working fine when I have "Opportunity.Commerical_Value__c" value, but if Opportunity.Commerical_Value__c doesn't have any value, it always return null. What I want is to have something like this "Opportunity.amount - 0 when Commercial_Value__c is empty. 
Anyone could help me on this? THank you in advance. 

<apex:outputText value="{0, number, Currency}"> <apex:param value="{!Opportunity.amount - Opportunity.Commerical_Value__c}" /> </apex:outputText>
Hi,
Can you please help me with test class


public class OV_CustomerTierCtrl {
    //To get ultimate parent customer tier,Total leasearea for current account 
    @AuraEnabled public static OV_CustomerTierWrapper getCustomerTier(String id){
        OV_CustomerTierWrapper dbw = new OV_CustomerTierWrapper();
        Account acc = [Select Ultimate_Parent_Account_ID_t__c from Account where Id =:id];
        getLeaseArea(id,dbw,'Local');
        addCustomerTier(dbw.totalLeaseSQFT,'Local',dbw); 
        getLeaseArea(acc.Ultimate_Parent_Account_ID_t__c,dbw,'Global');
        addCustomerTier(dbw.totalUltimateLeaseSQFT,'Global',dbw);
        return dbw;        
    }
    //To get total lease area for entire hirarchy
    private static void getLeaseArea(String id , OV_CustomerTierWrapper dbw,String tierType){
        String acctIds =OV_BAUtility.getAcctIds(id);   
        String leaseSQFTQuery = 'select sum(Lease_Area_SF__c) from Lease__c where isActive__c= \'yes\' AND Account_Name__r.Id IN '+acctIds;
        Decimal leaseSQFT=0;
        try{   
            AggregateResult[] acct = database.query(leaseSQFTQuery);
            if(acct[0].get('expr0')!=null){
                leaseSQFT = (Decimal)acct[0].get('expr0');
            } 
            if(tierType=='Global'){
                dbw.totalUltimateLeaseSQFT=leaseSQFT;
            }else{
                dbw.totalLeaseSQFT=leaseSQFT;
            }    
        }catch(Exception e){
        }        
    }
    //To update ultimate parent customer tier based on total lease area 
    private static void addCustomerTier(Decimal leaseArea,String tierType,OV_CustomerTierWrapper dbw ){
        String customerTier='';
        CustomerTier__c tier =[SELECT Bronze_Level__c,Gold_Level__c,Platinum_Level__c,Silver_Level__c FROM CustomerTier__c];
        if(leaseArea < tier.Bronze_Level__c){
            customerTier='Bronze'; 
        }else if(leaseArea>=tier.Bronze_Level__c && leaseArea<tier.Silver_Level__c){
            customerTier='Silver'; 
        }else if(leaseArea>=tier.Silver_Level__c && leaseArea<tier.Gold_Level__c){
            customerTier='Gold'; 
        }else{
            customerTier='Platinum';  
        }
        if(tierType=='Global'){
            dbw.globalUltimateTier=customerTier;
        }else{
            dbw.customerTier=customerTier;
        }        
    }
    public class OV_CustomerTierWrapper{
        @AuraEnabled public Decimal totalLeaseSQFT{get;set;}
        @AuraEnabled public Decimal totalUltimateLeaseSQFT{get;set;}
        @AuraEnabled public String customerTier{get;set;}
        @AuraEnabled public String globalUltimateTier{get;set;}
    }
}
Error:Apex trigger TaskToCommunityTrigger caused an unexpected exception, contact your administrator: TaskToCommunityTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Class.TaskToCommunity.aftrupdate: line 27, column 1
=======================================================================
public class TaskToCommunity {

    public static void aftrupdate(Map<id,contact> oldmap,Map<id,Contact> newmap){

        list<Task> ta=new list<Task>();
        user u=[select id from user where alias='sree'];

        // profile p=[select id from profile where name='Partner Community User'];
        for(id key:oldmap.keyset()){
            Contact old=oldmap.get(key);
            Contact newmp=newmap.get(key);
            
            if(old.Phone!=newmp.Phone){
                Task t=new Task();
                t.OwnerId=u.id; 
               // t.OwnerId=p.id; 
                //t.OwnerId=userinfo.getUserId();
                t.Status='Pending';
                t.Priority='Normal';
                //t.WhatId=newmp.id;
                
                t.ActivityDate=system.today();
                t.Subject='Testing';
                ta.add(t);
            }
        }
        update ta;
    }
}
===============================================================================================
trigger TaskToCommunityTrigger on Contact (after update) {

    if(trigger.isafter && trigger.isupdate){
    TaskToCommunity.aftrupdate(Trigger.oldmap, Trigger.newmap);
}
}

 
How can I show the current user photo in the custom community lightning theme? I would like to add current user image on a custom component that I created.
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
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...
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.