• Vikash Goyal
  • NEWBIE
  • 395 Points
  • Member since 2015


  • Chatter
    Feed
  • 13
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 33
    Replies
Hi All,
I created the below formula field which displays the bar code based on the code.
IMAGE("//www.barcodesinc.com/generator/image.php?code="&Promo_Code__c&"&style=325&type=C128B&width=200&height=50&xres=1&font=3",Promo_Code__c)

The Bar code is getting displayed for Internal users. But, the same is not working for Customer Community Users.
I tried with the below formula, but still I'm seeing broken image
IMAGE(LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260))+"//www.barcodesinc.com/generator/image.php?code="&Promo_Code__c&"&style=325&type=C128B&width=200&height=50&xres=1&font=3",Promo_Code__c)

Could you please help me with this. I need to see the barcodes in Customer Community

Thanks in Advance!

This is the trigger written to add the users to the opportunity team member related list


trigger oppTeammember2 on Opportunity (before insert) {
    
 
    list<opportunityteamMember> opp=new list<opportunityteamMember>();
user u=[select id from user where alias='cgowd' limit 1];
    for(opportunity o:trigger.new)
    {
        if(o.Amount>5000000)
        {
         opportunityteamMember o1=new opportunityteamMember();
           
             o1.TeamMemberRole='Account Manager';
            o1.userId=u.id;
            o1.OpportunityAccessLevel = 'All';
            o1.OpportunityId=o.id;
           
            opp.add(o1);
            
        }
         
        }
   insert opp;
            
    }

I am getting the error as:
oppTeammember2: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [OpportunityId]: [OpportunityId] Trigger.oppTeammember2: line 21, column 1
 Any help is appreciable 
Thank you
 
I am trying to display 100 locations address from cutom object to Lightning:map tag, its showing only first 11 addresses plotting on the map.  Is there any limitation for this lightning:map tag ?

Please help to solve this. 

I have followed this link to create component. 
http://sfdcmonkey.com/2018/09/16/mark-locations-google-map-salesforce-lightning/User-added image
now following code displaying like a,b,c,d
But I want to display like a,b,c and d

Code is : 

String dear = 'Hello';
        
        boolean first = true;
        
        for(Account a : accs)
        {
            if(first)
            {
                dear += a.Salutation+ ' ' + a.lastname;
                first = false;
                continue;
            }
        
           // dear += ' and ' +  a.Salutation+ ' ' + a.lastname;
            dear += ' , ' +  a.Salutation+ ' ' + a.lastname;
        }
        dear += ',';
        
        Opp.customer__c = dear; 
        update opp;        
Hi all,

I am trying to pass the Aura Components Basics trail --> Connect Components with Events.
Following code has been implemented but at the end I can not pass this trail step because I am getting the message
 
"Challenge not yet complete in My Trailhead Playground 6
The campingList component appears to be using UI Components instead of Base Lightning Components in the form. You should be using only Base Lightning Component

Following is the code:

campingList.cmp
 
<aura:component controller="CampingListController">
	
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
    <aura:handler name="addItem" event="c:addItemEvent"
   	action="{!c.handleAddItem }"/>
    

    
    <aura:attribute name="items" type="Camping_Item__c[]"/>
    
    <ol>
    <li>Bug Spray</li>
    <li>Bear Repellant</li>
    <li>Goat Food</li>
    </ol>
    
       <!-- NEW ITEM FORM -->
    <div class="slds-col slds-col--padded slds-p-top--large">

        <c:campingListForm />

    </div>
    <!-- / NEW ITEM FORM -->    
   

    <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Items</h3>
        </header>
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="items">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
            </div>
        </section>
    </div>

</aura:component>

campingListController
({
    // Load items from Salesforce
	doInit: function(component, event, helper) {

    // Create the action
    var action = component.get("c.getItems");

    // Add callback behavior for when response is received
    action.setCallback(this, function(response) {
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            component.set("v.items", response.getReturnValue());
        }
        else {
            console.log("Failed with state: " + state);
        }
    });

    // Send action off to be executed
    $A.enqueueAction(action);
},

    
    handleAddItem: function(component, event, helper) {
    //   var newItem = event.getParam("item");
    //helper.addItem(component, newItem);
    var action = component.get("c.saveItem");
    		action.setParams({"item": newItem});
    		action.setCallback(this, function(response){
        		var state = response.getState();
        		if (component.isValid() && state === "SUCCESS") {
            		// all good, nothing to do.
            var items = component.get("v.items");
            items.push(response.getReturnValue());
            component.set("v.items", items);
        		}
    		});
    		$A.enqueueAction(action);
        		}
    
              
})

campingList Helper
({
   addItem: function(component, item) {
    this.saveItem(component, item, function(response){
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            // all good, nothing to do.
         /*   var items = component.get("v.items");
            items.push(response.getReturnValue());
            component.set("v.items", items);*/
        }
    });
},
})

campingListForm component
<aura:component >
	
        <aura:attribute name="newItem" type="Camping_Item__c"
     default="{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Quantity__c': 0,
                    'Price__c': 0,
                    'Packed__c': false }"/>
    <aura:registerEvent name="addItem" type="c:addItemEvent"/>
        <!-- CREATE NEW ITEM FORM -->
    <form class="slds-form--stacked">

      <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="itemname" label="Name"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Name}"
                  required="true"/>

          </div>
     </div>

     <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputNumber aura:id="quantity" label="Quantity"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Quantity__c}"
                  required="true"/>

          </div>
      </div>

      <div class="slds-form-element">
          <div class="slds-form-element__control">
              <ui:inputCurrency aura:id="price" label="Price"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Price__c}"
                  />
          </div>
      </div>

      <div class="slds-form-element">
          <ui:inputCheckbox aura:id="packed" label="Packed?"
              class="slds-checkbox"
              labelClass="slds-form-element__label"
              value="{!v.newItem.Packed__c}"/>
      </div>

      <div class="slds-form-element">
          <ui:button label="Create Camping Item"
              class="slds-button slds-button--brand"
              press="{!c.submitForm}"/>
      </div>

    </form>
    <!-- / CREATE NEW ITEM FORM -->
</aura:component>

campingListForm Controller​​​​​​​
({
    
    submitForm: function(component, event, helper) {    
    if(helper.validateItemForm(component)){
        // Create the new item
        var newItem = component.get("v.newItem");
        helper.createItem(component, newItem);
    }
        
        }

})
campingListForm Helper​​​​​​​
({
 addItem: function(component, newItem) {
    var addItem = component.getItem("addItem");
    addItem.setParams({ "item": item });
    addItem.fire();
            component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Quantity__c': 0,
                    'Price__c': 0,
                    'Packed__c': false } />);
},
    

		validateItemForm: function(component) {
		
              // Simplistic error checking
        var validItem = true;

        // Name must not be blank
        var nameField = component.find("itemname");
        var itemname = nameField.get("v.value");
        if ($A.util.isEmpty(itemname)){
            validItem = false;
            nameField.set("v.errors", [{message:"Item name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
        
        // Quantity must not be blank
        var quantityField = component.find("quantity");
        var quantity = nameField.get("v.value");
        if ($A.util.isEmpty(quantity)){
            validItem = false;
            quantityField.set("v.errors", [{message:"Quantity can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }
		// Price must not be blank
        var priceField = component.find("price");
        var price = priceField.get("v.value");
        if ($A.util.isEmpty(price)){
            validItem = false;
            priceField.set("v.errors", [{message:"Price can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }
            return (validItem);

	}
})

addItemEvent.evt​​​​​​​
<aura:event type="COMPONENT">
    <aura:attribute name="item" type="Camping_Item__c"/>
</aura:event>

What I am doing wrong? I would appreciate any advice.​​​​​​​



​​​​​​​

Hello! 

I have a trigger that copies AccountTeam to OpportunityTeam After Insert

However, im getting a referencing null exception error when there are no AccountTeamMembers to copy

 

How do i change this to only run if there are AccountTeamMembers to copy over?



 

trigger AcctTeamtoOpp on Opportunity (after insert) {

    List<OpportunityTeamMember> oppTeamMembersList = new List<OpportunityTeamMember>();

Map< Id , Id > opportunityIdToAccountId = new Map< Id , Id >();
for(Opportunity o : Trigger.new)  {
   
        opportunityIdToAccountId.put(o.Id,  o.AccountId );
  
}


Map<id, List<AccountTeamMember > > accountIdToAccountTeamMembers = new    Map<id,  List<AccountTeamMember > > ();
for(AccountTeamMember accountTeamMember : [SELECT a.UserId,a.User.Name,a.TeamMemberRole, a.Id, a.AccountId
                        FROM AccountTeamMember a])   {

        List<AccountTeamMember > accountTeamMembers = ( accountIdToAccountTeamMembers.get(accountTeamMember.Accountid) == null) ?
                                                       new  List<AccountTeamMember >() :
                                                       accountIdToAccountTeamMembers.get(accountTeamMember.Accountid);

        accountTeamMembers.add(accountTeamMember);
        accountIdToAccountTeamMembers.put(accountTeamMember.Accountid, accountTeamMembers);

}



for(Opportunity o : Trigger.new) {
    
        Id accountId  = opportunityIdToAccountId.get(o.Id);
        for ( AccountTeamMember accountTeamMember : accountIdToAccountTeamMembers.get(accountId) )  {
            OpportunityTeamMember opportunityTeamMember  = new OpportunityTeamMember();
            opportunityTeamMember.UserId = accountTeamMember.UserId;
            opportunityTeamMember.TeamMemberRole = accountTeamMember.TeamMemberRole;
            opportunityTeamMember.OpportunityId = o.ID;
            oppTeamMembersList.add(opportunityTeamMember);
       
     }
}

insert oppTeamMembersList;
    
    
}

Just as the title states - when I use merge tag {!TODAY()} into email templates the format output is dd/mm/yyyy.

This creates confusion when dealing with international and well anyone as to whether the month or day first. 

I would like to the formated output to be ex. April 12, 2019 

How can I do this? 

Thanks!
vfpage controller


global class Search_Account_Controller {
   public Set<string> accountSet{get;set;}
   public string accName{get;set;}
   public Account accObj{get;set;}
   public List<Opportunity> oppList{get;set;}
   public boolean recTypeCheck{get;set;}
   public List<Service__c> serviceList{get;set;} 
   
    public Search_Account_Controller() {
         recTypeCheck=true;
        accountSet = new Set<String>();
        List<Account> accList = [Select id, Name, Account_Type__c from Account LIMIT 30000];
        if(accList!=null && accList.size()>0){
            for(Account acc :accList){
                accountSet.add(acc.Name);
            }
        }
    }
    
     public void getAccountDetails(){
        oppList = new List<Opportunity>();
        serviceList= new List<Service__c>();
         List<Account> accList= [Select Name, Id, Account_Type__c from Account where Name=:accName LIMIT 1];
         
         if(accList!=null && accList.size()>0)
         accObj=accList[0];
         
        if(accObj.Account_Type__c!='Client')  {
             recTypeCheck=false;
         }
         else{
            oppList=[Select Id, OppNumber__c, FC_Opportunity_Status__c, Name, StageName, CloseDate, CreationDateTime__c from Opportunity where AccountId=:accObj.Id];    
         }
     }
     
     public void getLineItemDetails()  {
         String oppIdval = apexpages.currentpage().getparameters().get('OppId');
         serviceList=[Select Id, Product__c, Produkt_ID__c , Product__r.Name, Name from Service__c where Opportunity__c=:oppIdval];    
         
     }
}
I am trying to learn Wrapper class in Salesforce development but I am getting the below error, could some one please help me te resolve this error.
Below are the error details, Apex code and VFPage code

Error:
Unknown property 'Wrapperclass.lstWrapperDisplay'

VFPage code:
<apex:page controller = "Wrapperclass">
    <apex:form>
        <apex:pageBlock >
            <apex:pageBlockSection>
                <apex:pageBlockTable value="{!lstWrapperDisplay}" var="w">
                    
                    <apex:column headerValue="Action">
                        <apex:inputCheckbox/>
                    </apex:column>
                    
                    <apex:column headerValue="Account Name">
                        {!w.accname}
                    </apex:column>
                    
                    <apex:column headervalue="Account Number">
                        {!w.accnum}
                    </apex:column>
                    
                    <apex:column headervalue="Industry">
                        {!w.accind}
                    </apex:column>
                    
                    <apex:column headervalue="Opportunity Name">
                        {!w.oppname}
                    </apex:column>
                    
                    <apex:column headervalue="Opportunity Amount">
                        {!w.oppamt}
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex class
public class Wrapperclass {
   public Wrapperclass(){
    lstAcc = new List<Account>();   
    lstOpp  = new List<Opportunity>();
   }

  //Name, accountnumber,Industry from Account
  //Name, ammount from opportunity
  //Instanitate List for Account, Opportunity
 
 public List<Account> lstAcc {get;set;}
 public List<Opportunity> lstOpp {get;set;}
    
  //List for Wrapper Class
 
 public List<Wrapper> lstw;
    
    public void lstWrapperDisplay(){
        lstAcc = [select name,accountnumber,Industry from Account];
        lstOpp = [select name,amount from Opportunity];
        
        for(integer i=0;i<lstOpp.size();i++){
            lstw.add(new Wrapper(lstAcc[i].name,lstAcc[i].accountnumber, lstAcc[i].Industry,lstOpp[i].name,lstOpp[i].amount));
                }
            //return lstw;
    }
 
    public class Wrapper{
        public String accname {set;get;}
        public String accnum {set;get;}
        public String accind {set;get;}
        public String oppname {set;get;}
        public Decimal oppamt {set;get;}

        
        public Wrapper(String accname, String accnum, String accind, String oppname, Decimal oppamt){
            this.accname = accname;
            this.accnum = accnum;
            this.accind = accind;
            this.oppname = oppname;
            this.oppamt = oppamt;
        }   
    }
}
with ref to the trails head 
Create a Visualforce page which shows a basic Contact record
Using the Contact standard controller, create a Visualforce page which displays a Contact's First Name, Last Name and the Email address of the Contact's Owner. 
Challenge Requirements
The page must be named ContactView
It must reference the Contact standard controller
It should include three bound variables that use the standard controller to display the following Contact record information:
First Name
Last Name
Owner Email

when i checked the contact's field i could see first name and last name is not at all available instead just name filed is there.

then how could the below code works ??

<apex:page standardController="Contact">
    
    <apex:pageBlock title="Contact Summary">
        <apex:pageBlockSection>
            
            {! Contact.firstName} <Br/>
             {! Contact.lasttName} <Br/>
           
            
            
        </apex:pageBlockSection>
    </apex:pageBlock>
I got this simple code 
 
public class AccountShipTo {

    public Account originalAccount{get; set;}
    public list<Account> accnt {get;set;}

    public AccountShipTo (ApexPages.StandardController controller) {
        originalAccount = [SELECT Id, ParentId FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
        
        accnt = new list<Account>();
        accnt = [SELECT Id, Name, ShippingStreet,ShippingCity,ShippingState,ShippingCountry,ShippingPostalCode FROM Account WHERE ParentId = :originalAccount.Id AND ShippingStreet<>''];
    }

}

and I want to make a test class
 
@isTest(seealldata=true)
public class AccountShipToTest {

    @isTest
    public static void testAccountShipTo(){
        
        Account originalAccount = [Select Id from Account limit 1];
        
        list<Account> accnt = [SELECT Id, Name, ShippingStreet,ShippingCity,ShippingState,ShippingCountry,ShippingPostalCode FROM Account WHERE ParentId = :originalAccount.Id AND ShippingStreet<>''];
    }
}


but I got 0% coverage... what do I miss?

 

Sorry, pretty new in this! :(

Hello, I built a test class and ran it receiving this error message: Required_Field_Missing on line 41 Column 1. GW_Volunteers__Volunter_Job__c

I created a new volunteer job, retrieved the Id of the volunteer job, and set the volunteer job field to the id when creating a new Volunteer Shift. I highlighted the sections in bold.

@isTest
public class createSoulAttendanceTest {

    public static String CRON_EXP = '0 0 0 3 7 ? 2019';
    static testmethod void testScheduledJob() {
        
        //Create Contact
        Contact con = new Contact(Lastname = 'Brown');
        
        insert con;
        
        //Grab contact Id
        Id conId = con.Id;
        
        //Create Campaign
        Campaign soulCam = new Campaign(Name = 'Soul Studio');
        
        insert soulCam;
        
        //Grab Campaign Id
        Id camId = soulCam.Id;
        
        //Create Volunteer Job
        GW_Volunteers__Volunteer_Job__c job = new GW_Volunteers__Volunteer_Job__c(GW_Volunteers__Campaign__c = camID, Name = 'Monday');
        //Grab Volunteer Job ID
        Id jobId = job.Id;

        
        //Set Date/Time for Volunteer Shifts
        DateTime dt = DateTime.now(); 
        
        //Create list to hold all the shifts
        List<Id> allShiftList = new List<Id>();
        
        //Create 7 Volunteer Shifts
        for(Integer i = 0; i < 6; i++) {
            GW_Volunteers__Volunteer_Shift__c shift = new GW_Volunteers__Volunteer_Shift__c(Program__c = camID,                 GW_Volunteers__Volunteer_Job__c = jobId,                                         GW_Volunteers__Start_Date_Time__c = dt.addDays(i),                                                               GW_Volunteers__Duration__c = 5);
            insert shift;
            
            allShiftList.add(shift.Id);
            
        }
        
        //Create New Program Enrollment
        Program_Enrollment__c proEnroll = new Program_Enrollment__c(Campaign__c = camId,
                                                                   Attendee__c = conId,
                                                                   Volunteer_Job__c = jobId,
                                                                   Status__c = 'Confirmed',
                                                                   Role__c = 'Participant',
                                                                   For_All_Sessions__c = FALSE);
        //Retrieve Program Enrollment Id
        Id proId = proEnroll.Id;
        
       Test.startTest();
       String apexJobId = System.schedule('ScheduleApexTest', CRON_EXP, new createSoulAttendance());
       Test.stopTest();
        
       List<Attendance__c> att = [SELECT Id FROM Attendance__c
                                 WHERE Program_Enrollment__c =: proId
                                 AND Date__c >= TODAY 
                                 AND Date__c = NEXT_n_DAYS:7];
        
       System.assertEquals(allShiftList.size(), att.size());
    }
}

Any help in why this error is happening is greatly appreciated!
I wrote the following code for Lead conversion, but I know that it is not properly bulkified. I have tried to bulkify it, but facing some issues.  Please guide me on how to bulkify this code, so that I can use it as reference in the future.
 
public class LeadInsertTriggerHandler {

public static void AfterInsert(List<Lead> lstLeads)
{
    LeadStatus convertStatus = [select MasterLabel from LeadStatus where IsConverted = true limit 1];
    List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();

    for (Lead lead: lstLeads) {
        if (!lead.isConverted) {
            Database.LeadConvert lc = new Database.LeadConvert();

            lc.setLeadId(lead.Id);
            lc.setConvertedStatus(convertStatus.MasterLabel);
            lc.setDoNotCreateOpportunity(TRUE);

            List<account> obj_account = [select id from account where 
                                         Email_and_SiteID__c= :lead.Email_and_SiteID__c];
            if(obj_account.size()>0)
            {
                lc.setAccountId(obj_account[0].id);
            }
                leadConverts.add(lc);
            }
            }

            if (!leadConverts.isEmpty()) {
            List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
        }
    }

}

 
Hi,
From this below code i am getting list of accounts with search bar. when i search for  particular account, the below code is not working.
what should i add  to filter records from list of records which i got. please help me out from this issue.

Thank you :)


Component:
<aura:component  controller="AccountRecord">
   <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> 
    <aura:attribute name="namevalue" type="string"/>
    <aura:attribute name="Account" type="Account"/>
    
    <lightning:input label='' value="{!v.namevalue}" /> 
    <br></br>
   <div><lightning:button label="Search" onclick="{!c.handleClick}"/><br/></div>
    
   <!-- <lightning:button variant="destructive" label="search" onclick="{! c.handleClick }"/> -->
    
    <table class="slds-table slds-table_cell-buffer slds-table_bordered ">
        <thead>
            <tr class="slds-line-height_reset">
                <th scope="col">
                    <div class="slds-truncate">ACCOUNT ID</div>
                </th> 
                <th scope="col">
                    <div class="slds-truncate">ACCOUNT NAME</div>
                </th> 
                <th scope="col">
                    <div class="slds-truncate">STATUS</div>
                </th> 
                
            </tr>
             </thead>
        
         <aura:iteration items="{!v.Account}" var="account">
            <tbody>
                
                <tr class="slds-hint-parent">
                    <td scope="row" data-label="Account Id">
                        <div class="slds-truncate"> {!account.Id}</div>
                    </td>
                    <td scope="row" data-label="Account Name">
                        <div class="slds-truncate"> {!account.Name}</div>
                    </td>
                    <td scope="row" data-label="Account Status">
                        <div class="slds-truncate"> {!account.Status__c}</div>
                    </td>     
                </tr>
                
            </tbody>
              </aura:iteration>       
       
    </table>
    
    
</aura:component>

Controller
({
        handleClick : function(component, event, helper) {
        var acc1=component.get("v.namevalue");
         var action = component.get("c.accountInfo");
        action.setParams({
            acc: acc1
        });
        action.setCallback(this, function(response){
            var similarProperties = response.getReturnValue();
            component.set("v.Account", similarProperties);
        });
        $A.enqueueAction(action);
                }, 
    doInit: function(component, event, helper){
    var action = component.get("c.accountInfo1");
        action.setCallback(this, function(response){
            debugger;
            var similarProperties1 = response.getReturnValue();
            console.log(similarProperties1);
            //var myJSON = JSON.stringify(similarProperties1);
            //alert(myJSON);
            component.set("v.Account", similarProperties1);
        });
        $A.enqueueAction(action);
    }
})

Apex class:
public class AccountRecord {
    @AuraEnabled
    public static String accountInfo(String acc){
        Account ac=[select id,name,status__c from account where name=:acc limit 1];
        String acc1=ac.id+' '+ac.name+' '+ac.status__c;
        return acc1;
       
    }
     @AuraEnabled
    public static List<Account> accountInfo1(){
          list <Account> Ac1=[select id,name,status__c from account];
        return Ac1;
       
    } 
}




 
Scenario:
When the owner of an Account is changed, check to see the Division of the new owner of the Account. If it is "Regional Sales", perform the following changes 
Fo the Account, check the Open Opportunities that are owned by the previous owner of the Account, for each Open Opportunity set the owner to be the new owner of the Account 
For the Account, check each Contact that is owned by the previous owner of the Account and set the owner to be the new owner of the Account


Apex Class:
public class AccountHandler (){
    public static void updateOwner(List<Account> newAccountList, Map<Id, Account> oldMap){
        Set<Id> accountIds = new Set<Id>();
        List<opportunity> oppList = new List<opportunity>();
        List<contact> conList = new List<contact>();
        List<Account> AccountList = new List<Account>();
        
        User usr = [Select Id, Division from User where isActive = true and Division = 'Regional Sales'];
        
        for(Account acc : newAccountList) {
            if(trigger.IsUpdate && oldMap!=null && oldMap.get(acc.Id).OwnerId != acc.OwnerId && acc.OwnerId == usr.Id){
                accountIds.add(acc.Id);
            }                               
        }
        
        if(!accountIds.IsEmpty()){
            AccountList = [Select Id, OwnerId, Owner.Division from Account where Id =: accountIds];
            for(Account acc : AccountList){
                Opportunity opp = new Opportunity();
                opp.AccountId = acc.Id;
                opp.OwnerId = acc.OwnerId; 
                oppList.add(opp);
                
                Contact con = new Contact();
                con.AccountId = acc.Id;
                con.OwnerId = acc.OwnerId;
                conList.add(con);
            } 
        }
        if(oppList.size() > 0){
            update oppList;
        }
        if(conList.size() > 0){
            update conList;
        }
    }
}

Apex Trigger:
trigger AccountTrigger on Account (after insert, after update, before delete) {
    if(Trigger.isUpdate && Trigger.isAfter){
        AccountHandler.updateOwner(Trigger.New, Trigger.OldMap);
    }
}
  • December 21, 2019
  • Like
  • 0
Hi All,
I created the below formula field which displays the bar code based on the code.
IMAGE("//www.barcodesinc.com/generator/image.php?code="&Promo_Code__c&"&style=325&type=C128B&width=200&height=50&xres=1&font=3",Promo_Code__c)

The Bar code is getting displayed for Internal users. But, the same is not working for Customer Community Users.
I tried with the below formula, but still I'm seeing broken image
IMAGE(LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260))+"//www.barcodesinc.com/generator/image.php?code="&Promo_Code__c&"&style=325&type=C128B&width=200&height=50&xres=1&font=3",Promo_Code__c)

Could you please help me with this. I need to see the barcodes in Customer Community

Thanks in Advance!

This is the trigger written to add the users to the opportunity team member related list


trigger oppTeammember2 on Opportunity (before insert) {
    
 
    list<opportunityteamMember> opp=new list<opportunityteamMember>();
user u=[select id from user where alias='cgowd' limit 1];
    for(opportunity o:trigger.new)
    {
        if(o.Amount>5000000)
        {
         opportunityteamMember o1=new opportunityteamMember();
           
             o1.TeamMemberRole='Account Manager';
            o1.userId=u.id;
            o1.OpportunityAccessLevel = 'All';
            o1.OpportunityId=o.id;
           
            opp.add(o1);
            
        }
         
        }
   insert opp;
            
    }

I am getting the error as:
oppTeammember2: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [OpportunityId]: [OpportunityId] Trigger.oppTeammember2: line 21, column 1
 Any help is appreciable 
Thank you
 
I am trying to display 100 locations address from cutom object to Lightning:map tag, its showing only first 11 addresses plotting on the map.  Is there any limitation for this lightning:map tag ?

Please help to solve this. 

I have followed this link to create component. 
http://sfdcmonkey.com/2018/09/16/mark-locations-google-map-salesforce-lightning/User-added image
I am using a lightning:formatteddatetime inside lightning component

 <lightning:formattedDateTime value="{!v.claimDetails.effectiveDate}" year="numeric" month="numeric" day="2-digit"/>

It is displaying date as 05/15/2019

How to make the date display as   05/15/2019 instead of     5/15/2019

Thanks
Meghna
now following code displaying like a,b,c,d
But I want to display like a,b,c and d

Code is : 

String dear = 'Hello';
        
        boolean first = true;
        
        for(Account a : accs)
        {
            if(first)
            {
                dear += a.Salutation+ ' ' + a.lastname;
                first = false;
                continue;
            }
        
           // dear += ' and ' +  a.Salutation+ ' ' + a.lastname;
            dear += ' , ' +  a.Salutation+ ' ' + a.lastname;
        }
        dear += ',';
        
        Opp.customer__c = dear; 
        update opp;        
Hi all,

I am trying to pass the Aura Components Basics trail --> Connect Components with Events.
Following code has been implemented but at the end I can not pass this trail step because I am getting the message
 
"Challenge not yet complete in My Trailhead Playground 6
The campingList component appears to be using UI Components instead of Base Lightning Components in the form. You should be using only Base Lightning Component

Following is the code:

campingList.cmp
 
<aura:component controller="CampingListController">
	
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
    <aura:handler name="addItem" event="c:addItemEvent"
   	action="{!c.handleAddItem }"/>
    

    
    <aura:attribute name="items" type="Camping_Item__c[]"/>
    
    <ol>
    <li>Bug Spray</li>
    <li>Bear Repellant</li>
    <li>Goat Food</li>
    </ol>
    
       <!-- NEW ITEM FORM -->
    <div class="slds-col slds-col--padded slds-p-top--large">

        <c:campingListForm />

    </div>
    <!-- / NEW ITEM FORM -->    
   

    <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Items</h3>
        </header>
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="items">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
            </div>
        </section>
    </div>

</aura:component>

campingListController
({
    // Load items from Salesforce
	doInit: function(component, event, helper) {

    // Create the action
    var action = component.get("c.getItems");

    // Add callback behavior for when response is received
    action.setCallback(this, function(response) {
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            component.set("v.items", response.getReturnValue());
        }
        else {
            console.log("Failed with state: " + state);
        }
    });

    // Send action off to be executed
    $A.enqueueAction(action);
},

    
    handleAddItem: function(component, event, helper) {
    //   var newItem = event.getParam("item");
    //helper.addItem(component, newItem);
    var action = component.get("c.saveItem");
    		action.setParams({"item": newItem});
    		action.setCallback(this, function(response){
        		var state = response.getState();
        		if (component.isValid() && state === "SUCCESS") {
            		// all good, nothing to do.
            var items = component.get("v.items");
            items.push(response.getReturnValue());
            component.set("v.items", items);
        		}
    		});
    		$A.enqueueAction(action);
        		}
    
              
})

campingList Helper
({
   addItem: function(component, item) {
    this.saveItem(component, item, function(response){
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            // all good, nothing to do.
         /*   var items = component.get("v.items");
            items.push(response.getReturnValue());
            component.set("v.items", items);*/
        }
    });
},
})

campingListForm component
<aura:component >
	
        <aura:attribute name="newItem" type="Camping_Item__c"
     default="{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Quantity__c': 0,
                    'Price__c': 0,
                    'Packed__c': false }"/>
    <aura:registerEvent name="addItem" type="c:addItemEvent"/>
        <!-- CREATE NEW ITEM FORM -->
    <form class="slds-form--stacked">

      <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="itemname" label="Name"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Name}"
                  required="true"/>

          </div>
     </div>

     <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputNumber aura:id="quantity" label="Quantity"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Quantity__c}"
                  required="true"/>

          </div>
      </div>

      <div class="slds-form-element">
          <div class="slds-form-element__control">
              <ui:inputCurrency aura:id="price" label="Price"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Price__c}"
                  />
          </div>
      </div>

      <div class="slds-form-element">
          <ui:inputCheckbox aura:id="packed" label="Packed?"
              class="slds-checkbox"
              labelClass="slds-form-element__label"
              value="{!v.newItem.Packed__c}"/>
      </div>

      <div class="slds-form-element">
          <ui:button label="Create Camping Item"
              class="slds-button slds-button--brand"
              press="{!c.submitForm}"/>
      </div>

    </form>
    <!-- / CREATE NEW ITEM FORM -->
</aura:component>

campingListForm Controller​​​​​​​
({
    
    submitForm: function(component, event, helper) {    
    if(helper.validateItemForm(component)){
        // Create the new item
        var newItem = component.get("v.newItem");
        helper.createItem(component, newItem);
    }
        
        }

})
campingListForm Helper​​​​​​​
({
 addItem: function(component, newItem) {
    var addItem = component.getItem("addItem");
    addItem.setParams({ "item": item });
    addItem.fire();
            component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Quantity__c': 0,
                    'Price__c': 0,
                    'Packed__c': false } />);
},
    

		validateItemForm: function(component) {
		
              // Simplistic error checking
        var validItem = true;

        // Name must not be blank
        var nameField = component.find("itemname");
        var itemname = nameField.get("v.value");
        if ($A.util.isEmpty(itemname)){
            validItem = false;
            nameField.set("v.errors", [{message:"Item name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
        
        // Quantity must not be blank
        var quantityField = component.find("quantity");
        var quantity = nameField.get("v.value");
        if ($A.util.isEmpty(quantity)){
            validItem = false;
            quantityField.set("v.errors", [{message:"Quantity can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }
		// Price must not be blank
        var priceField = component.find("price");
        var price = priceField.get("v.value");
        if ($A.util.isEmpty(price)){
            validItem = false;
            priceField.set("v.errors", [{message:"Price can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }
            return (validItem);

	}
})

addItemEvent.evt​​​​​​​
<aura:event type="COMPONENT">
    <aura:attribute name="item" type="Camping_Item__c"/>
</aura:event>

What I am doing wrong? I would appreciate any advice.​​​​​​​



​​​​​​​
I came across few statements which are not very clear to me and looks conflicting. Correct me if I am wrong –

1. Too many SOQL queries – 101 exception –
Reason - If there are more than 100 DML statements in one transaction/context. What does 1 transaction/context mean?
Does it mean within one class if I am trying to query 100+ DML statements? Is this is the only meaning or there is something else.

2. I tried to insert 160 records using lists to avoid the 101 exception. This code ran fine and records were created.
List<Account> listAccounts = new List<Account>();
For (Integer x = 1; x <=160 ; x++) 
{
   Account newAccount = new Account (Name='Loop MyAccount' + x);
   listAccounts.add(newAccount);
   System.debug('Account added ' + x);
}
insert listAccounts;

But I came through this URL - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples.htm

This URL mentions "If the list contains more than 150 items, the 151st update returns an exception that can’t be caught."
So now, I ran into confusion because the code had list of 160 records which is 150+ and it created 160 records for me.

Please let me know what part I am missing.

Thanks in advance.
 

Hello! 

I have a trigger that copies AccountTeam to OpportunityTeam After Insert

However, im getting a referencing null exception error when there are no AccountTeamMembers to copy

 

How do i change this to only run if there are AccountTeamMembers to copy over?



 

trigger AcctTeamtoOpp on Opportunity (after insert) {

    List<OpportunityTeamMember> oppTeamMembersList = new List<OpportunityTeamMember>();

Map< Id , Id > opportunityIdToAccountId = new Map< Id , Id >();
for(Opportunity o : Trigger.new)  {
   
        opportunityIdToAccountId.put(o.Id,  o.AccountId );
  
}


Map<id, List<AccountTeamMember > > accountIdToAccountTeamMembers = new    Map<id,  List<AccountTeamMember > > ();
for(AccountTeamMember accountTeamMember : [SELECT a.UserId,a.User.Name,a.TeamMemberRole, a.Id, a.AccountId
                        FROM AccountTeamMember a])   {

        List<AccountTeamMember > accountTeamMembers = ( accountIdToAccountTeamMembers.get(accountTeamMember.Accountid) == null) ?
                                                       new  List<AccountTeamMember >() :
                                                       accountIdToAccountTeamMembers.get(accountTeamMember.Accountid);

        accountTeamMembers.add(accountTeamMember);
        accountIdToAccountTeamMembers.put(accountTeamMember.Accountid, accountTeamMembers);

}



for(Opportunity o : Trigger.new) {
    
        Id accountId  = opportunityIdToAccountId.get(o.Id);
        for ( AccountTeamMember accountTeamMember : accountIdToAccountTeamMembers.get(accountId) )  {
            OpportunityTeamMember opportunityTeamMember  = new OpportunityTeamMember();
            opportunityTeamMember.UserId = accountTeamMember.UserId;
            opportunityTeamMember.TeamMemberRole = accountTeamMember.TeamMemberRole;
            opportunityTeamMember.OpportunityId = o.ID;
            oppTeamMembersList.add(opportunityTeamMember);
       
     }
}

insert oppTeamMembersList;
    
    
}

Hi Team,

In lightning "Account" object i want to create a checkbox field IsSameAsBillingAddress?.

If the checkbox is selected then "ShippingAddress" should be populated as 'BillingAddress'.
If unchecked then the "ShippingAddress" should be blank.

Out of current process builder and flow builder which one is an efficient way to do it?

Many Thanks in advance!
Component:
<aura:component controller="RemovefromDNCcontroller"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
    <ltng:require styles="{!$Resource.quickActionStyle}"/>
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="Preval" type="RemovefromDNCcontroller" />
    <aura:attribute name="Preaccount" type="Id"/>
    <aura:attribute name="Precontact" type="Id"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:if isTrue = "{!v.Preval.messageDisplay}">
        <div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_info" role="alert">
            {!v.Preval.message}
        </div>
    </aura:if>
</aura:component>

Controller.js

({
    doInit : function(component, event,helper) {
        var action = component.get("c.Oppdetails");
        action.setParams({"OppId": component.get("v.recordId")});
        action.setCallback(this, function(response) {
            var responsedata = response.getReturnValue();
            var accid = response.getReturnValue().caseaccId;
            var conid = response.getReturnValue().caseContactId;
            var state = response.getState();
            console.log('accid==='+accid);
            console.log('conid==='+conid);
            helper.fetchAccdetail(component,event,helper,accid);
            helper.fetchCondetails(component, event, helper,conid);
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.Preval", response.getReturnValue());
                helper.createCasDetails(component,event,helper,responsedata);
            }
        });
        $A.enqueueAction(action);
    },
})

Helper.js
({
    fetchAccdetail : function(component, event, helper,accid) {
        console.log('accid helper==='+accid);
        var action = component.get("c.accountPreCheck");
        action.setParams({
            "AccountcheckId" : accid
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            console.log('response acc===='+response.getReturnValue());            
            if (state === "SUCCESS") {
                component.set("v.Preaccount", response.getReturnValue());
                //var Acc = component.get("v.Preaccount");
                //console.log("Acc---"+Acc);
            }
        });
        $A.enqueueAction(action);
    },
    fetchCondetails : function(component, event, helper,conid) {
        console.log('conid helper==='+conid);
        var action = component.get("c.contactPreCheck");
        action.setParams({
            "ContactcheckId" : conid
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            console.log('response con==='+response.getReturnValue());            
            if (state === "SUCCESS") {
                component.set("v.Precontact", response.getReturnValue());
                //var con = component.get("v.Precontact");
                //console.log("con---"+con);
            }
        });
        $A.enqueueAction(action);
    },
    createCasDetails: function(component,event,helper,responsedata){
        console.log("responsedata---"+responsedata.messageDisplay);
        if(responsedata.messageDisplay == false){
            var Acc = component.get("v.Preaccount");
            var con = component.get("v.Precontact");
            console.log("Acccase---"+Acc);
            console.log("concase---"+con);
            var createCaseEvent = $A.get("e.force:createRecord");
            createCaseEvent.setParams({
                "entityApiName": "Case",
                "defaultFieldValues": {
                    'Case_Type__c'     : 'Do Not Call List Request',
                    'Account'        : Acc,
                    'Contact'        : con,
                    'Opportunity__c': responsedata.caseOppId
                }
            });
            createCaseEvent.fire();
        }
    },
})

Apex Class:

public with sharing class RemovefromDNCcontroller {

    @AuraEnabled public string caseaccId{get;set;}
    @AuraEnabled public string caseContactId{get;set;}
    @AuraEnabled public string caseOppId{get;set;}
    @AuraEnabled public string message{get;set;}
    @AuraEnabled public boolean messageDisplay{get;set;}
    
    @AuraEnabled 
    public static RemovefromDNCcontroller Oppdetails (Id OppId){
        RemovefromDNCcontroller rfd = new RemovefromDNCcontroller();
         rfd.messageDisplay = false;
        Opportunity o = [select id, Name,ownerId, AccountId, Account.PersonContactId, Do_Not_Call__c from Opportunity where Id =: OppId];
        system.debug('o----'+o);
        if(o.Do_Not_Call__c == true){
            system.debug('rfd 24'+ rfd.message);
            rfd.caseOppId = o.Id;
            rfd.caseContactId = o.Account.PersonContactId;
            rfd.caseaccId = o.AccountId;
            system.debug('caseContactId ==='+rfd.caseContactId);
            system.debug('caseaccId ==='+rfd.caseaccId);
            return rfd;
        }else{
            rfd.message = system.Label.Remove_from_DNC_Alert;
            rfd.messageDisplay = true;
            system.debug('rfd 32'+ rfd.message);
            return rfd;
            
        }
        
    }
    @AuraEnabled 
    public static Id accountPreCheck (Id AccountcheckId){
        system.debug('AccountcheckId--'+AccountcheckId);
        return AccountcheckId;
    }
    @AuraEnabled 
    public static Id contactPreCheck (Id ContactcheckId){
        system.debug('ContactcheckId--'+ContactcheckId);
        return ContactcheckId;
    }
}

In Helper, method createCasDetails, values in 
console.log("Acccase---"+Acc);
console.log("concase---"+con);
are not coming due to which values in Account and Contact are not pre-populating.
Please help.
Just as the title states - when I use merge tag {!TODAY()} into email templates the format output is dd/mm/yyyy.

This creates confusion when dealing with international and well anyone as to whether the month or day first. 

I would like to the formated output to be ex. April 12, 2019 

How can I do this? 

Thanks!
vfpage controller


global class Search_Account_Controller {
   public Set<string> accountSet{get;set;}
   public string accName{get;set;}
   public Account accObj{get;set;}
   public List<Opportunity> oppList{get;set;}
   public boolean recTypeCheck{get;set;}
   public List<Service__c> serviceList{get;set;} 
   
    public Search_Account_Controller() {
         recTypeCheck=true;
        accountSet = new Set<String>();
        List<Account> accList = [Select id, Name, Account_Type__c from Account LIMIT 30000];
        if(accList!=null && accList.size()>0){
            for(Account acc :accList){
                accountSet.add(acc.Name);
            }
        }
    }
    
     public void getAccountDetails(){
        oppList = new List<Opportunity>();
        serviceList= new List<Service__c>();
         List<Account> accList= [Select Name, Id, Account_Type__c from Account where Name=:accName LIMIT 1];
         
         if(accList!=null && accList.size()>0)
         accObj=accList[0];
         
        if(accObj.Account_Type__c!='Client')  {
             recTypeCheck=false;
         }
         else{
            oppList=[Select Id, OppNumber__c, FC_Opportunity_Status__c, Name, StageName, CloseDate, CreationDateTime__c from Opportunity where AccountId=:accObj.Id];    
         }
     }
     
     public void getLineItemDetails()  {
         String oppIdval = apexpages.currentpage().getparameters().get('OppId');
         serviceList=[Select Id, Product__c, Produkt_ID__c , Product__r.Name, Name from Service__c where Opportunity__c=:oppIdval];    
         
     }
}
Hi
for list view code in docs reference,

<lightning:listView aura:id="listViewAccounts" objectApiName="CustomObj__c" listName="My_Accounts" rows="5" showActionBar="false" enableInlineEdit="true" showRowLevelActions="false" />

I need some info regarding :listName="My_Accounts"

where does this listNames appear in the setup and how can I create custom ones to reuse in lightning?

Could you please explain in detail.

 
please help me guysUser-added imageError
Error: AccountDemoController1 Compile Error: Constructor not defined: [PageReference].<Constructor>(String) at line 11 column 26
Hi Friends, 
I have a strange problem in our org that one of the active picklist value is not working. 
There is a  field called Nationality__c in contact, and updates are being receved from integration api. 
for example : If I get contact updates in which Nationality is "Turkey", contact gets updated correctly without any error. 
But with the same contact update api, whenever I get updates for "Libya", I get "bad value for Restricted picklist field" with status code=INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST. 

When I check the picklist values of this field, both of these values are Active, not getting any idea why its failing for Libya but not for Turkey. 
FYI, this picklist values are created from Global value set.