• Govindaraj
  • SMARTIE
  • 1140 Points
  • Member since 2015

  • Chatter
    Feed
  • 37
    Best Answers
  • 0
    Likes Received
  • 6
    Likes Given
  • 3
    Questions
  • 174
    Replies
Dears,

I am facing following scenario

1. Need to display a User departmet in lead (Custom) new new page.

2. Owner field is always displaying while creating.

3. Formula filed is not displaying in the new page, It's only available in the detail page.

4. I would like to display a User departmnet (Custom field) as same as owner field.

5. Is that possible ?

Regards,
Soundar.  
Hi I am trying to write a Apex class to create an account and return the record name and i am getting the below error:
Static method cannot be referenced from a non static context: String
Here is my Code:
public class AccountHandler {
      public static String insertNewAccount(String strNames)
      {
          try
          {
          Account acct = new Account();
            acct.Name = strNames;
            acct.Phone = '(415)555-1212';
            acct.NumberOfEmployees = 100;
        insert acct;
        ID acctID = acct.Id;
// Display this ID in the debug log
System.debug('ID = ' + acctID);
              return strNames;
          }
          catch(Exception ex)
          {
              return 'NULL';
          }
      }

}
BeerSearchData.cmp
____________________
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="recordList" type="List"/>
    <aura:attribute name="iden" type="String"/>
     <lightning:overlayLibrary aura:id="overlayLib"/>
    <div class="c-container">
        <lightning:layout horizontalAlign="spread" multipleRows="true">
            <aura:iteration items="{!v.recordList}" var="con">
                <lightning:layoutItem size="4" padding="around-small">
                    <div class="custom-box">
                        <lightning:card title="{!con.Beer_Name__c}"  iconName="custom:custom56" >
                            Alcohol % : {!con.Alcohol__c}&nbsp;
                            Price : {!con.Price__c}
                            <div class="slds-col slds-size_4-of-8">
                                <img src="{!$Resource.BeerImage}"/>
                            </div>
<aura:set attribute="actions">
<lightning:button name="{!con.Id}" label="View Details" onclick="{!c.detailspage}" variant="brand"/>
</aura:set>
                        </lightning:card>
                    </div>
                </lightning:layoutItem>
            </aura:iteration>
        </lightning:layout>
    </div>
    <div>
    </div>
</aura:component>

BeerSearchDataController.js
________________________

({
    detailspage : function(component, event, helper) {
    var eventSource = event.getSource();
       var beerObj = eventSource.get('v.name');
        component.set('v.iden',beerObj);
        component.set('v.truthy',true);
         $A.createComponent(
             "c:BeerDetails",
            {
                "v.iden": "beerObj",
            },
            function(BeerDetails, status, errorMessage){
               if (status === "SUCCESS") {
                   component.find('overlayLib').showCustomModal({
                       header: "Beer Details",
                       body: BeerDetails,
                       showCloseButton: true,
                       closeCallback: function() {
                           alert('You closed the alert!');
                       }
                   })
               }
           });
               
                     
}
});This is the Error.


BeerDetails.cmp
_______________
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
    <lightning:overlayLibrary aura:id="overlayLib"/>
    <aura:attribute name="beerId" type="String"/>
    <lightning:recordForm
        recordId="{!v.beerId}"
        objectApiName="Beer__c"
        layoutType="Full"
        columns="2"
        mode="view" />
  <div>
<lightning:button label="Order Now!" onclick="{!doOrder}" variant="brand"/>
</div>
</aura:component>
 
Hey guys,

could anybody tell me or send me a link to documentation where it says what fires first?

In my org I have Apex triggers, processes, validation rules, workflow rules. What does fire first and what last? Is there some kind of system?

Thank you
I created a lookup relationship between leads and campaigns. When I go to add a campaign to the related list in leads the "New" button does not show up. How do I get this button to display?User-added imageUser-added image
Hi Team,

Need a Apex class for following:

     Create an Apex class called “SalesUtility”. Methods in this class must be accessible without creating an instance of it.
     And a utility method in “SalesUtility” which will return sum of “Expected Revenue” from Opportunity for current fiscal quarter. And 
     Write a utility method in “SalesUtility” class which will return all the Opportunity records having the same name as Lead Company field on Lead records. 
     Write a test class to verify all the above scenarios.

Thanks,
Aj
/*Write a trigger that creates two identical Contacts whenever an Account is created. Make sure both Contacts are associated with the Account. Use any values for the fields on the Contacts - just make sure to use variables when populating the fields of each Contact to make sure they are identical.*/

I am not able to associate contacts with Account , this is my code

trigger IdenticalContact on Account (before insert) {          for (Account a : trigger.new)     {         List<contact> cont = new List<contact> ();         for (integer i=0 ; i<2; i++)         {             contact newContact            = new contact();             newContact.AccountId          = a.id;             newContact.LastName           = 'kritpa';             newContact.FirstName          = 'ptName';             cont.add(newContact);         }      insert cont;     }



 
Hi Everyone,

I need to change the object-level permissions on the user profile. When clicking on the Edit button (which present left side of profile name) the view is looking as similar to Permission set view. I am not sure why it is looking like that.
Can anyone please help me with this reg.

Thanks in advance.
 
I want to create a new user which license is salesforce. But the license was all used.  Also can`t see the salesforce license user in Setup>Users page.How to find it?
public class clsShowCarousel {
    @AuraEnabled
    public static list<string> fetchPropertyImages(string RecordId){
        list<string> formulaFieldURL = new list<string>();
		//list<string> imageUrl = new list<string>();
		//list<string> lstAltText = new list<string>(); 
		list<WrapperClass> lstWrap = new list<WrapperClass>(); 
		
        list<Property__c> lstOfformulaFields = new list<Property__c>();
        
        lstOfformulaFields = [select id,ImageFormula1__c,ImageFormula2__c,ImageFormula3__c,ImageFormula4__c,ImageFormula5__c,ImageFormula6__c,ImageFormula7__c,ImageFormula8__c,ImageFormula9__c,ImageFormula10__c,ImageFormula11__c,ImageFormula12__c,ImageFormula13__c,ImageFormula14__c,ImageFormula15__c,ImageFormula16__c,ImageFormula17__c,ImageFormula18__c,ImageFormula19__c,ImageFormula20__c,Front_Image__c,Side_Image__c,Rear_Image__c,Near_Image__c from Property__c where id =: RecordId];
        
        if(lstOfformulaFields.size()>0){
			
			if(lstOfformulaFields[0].Front_Image__c != null && lstOfformulaFields[0].Front_Image__c != '')
				formulaFieldURL.add(lstOfformulaFields[0].Front_Image__c);
			if(lstOfformulaFields[0].Side_Image__c != null && lstOfformulaFields[0].Side_Image__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].Side_Image__c);
			if(lstOfformulaFields[0].Rear_Image__c != null && lstOfformulaFields[0].Rear_Image__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].Rear_Image__c);
			if(lstOfformulaFields[0].Near_Image__c != null && lstOfformulaFields[0].Near_Image__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].Near_Image__c);
            if(lstOfformulaFields[0].ImageFormula1__c != null && lstOfformulaFields[0].ImageFormula1__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula1__c);
            if(lstOfformulaFields[0].ImageFormula2__c != null && lstOfformulaFields[0].ImageFormula2__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula2__c);
            if(lstOfformulaFields[0].ImageFormula3__c != null && lstOfformulaFields[0].ImageFormula3__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula3__c);
            if(lstOfformulaFields[0].ImageFormula4__c != null && lstOfformulaFields[0].ImageFormula4__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula4__c);
            if(lstOfformulaFields[0].ImageFormula5__c != null && lstOfformulaFields[0].ImageFormula5__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula5__c);
            if(lstOfformulaFields[0].ImageFormula6__c != null && lstOfformulaFields[0].ImageFormula6__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula6__c);
            if(lstOfformulaFields[0].ImageFormula7__c != null && lstOfformulaFields[0].ImageFormula7__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula7__c);
            if(lstOfformulaFields[0].ImageFormula8__c != null && lstOfformulaFields[0].ImageFormula8__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula8__c);
            if(lstOfformulaFields[0].ImageFormula9__c != null && lstOfformulaFields[0].ImageFormula9__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula9__c);
            if(lstOfformulaFields[0].ImageFormula10__c != null && lstOfformulaFields[0].ImageFormula10__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula10__c);
            if(lstOfformulaFields[0].ImageFormula11__c != null && lstOfformulaFields[0].ImageFormula11__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula11__c);
            if(lstOfformulaFields[0].ImageFormula12__c != null && lstOfformulaFields[0].ImageFormula12__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula12__c);
            if(lstOfformulaFields[0].ImageFormula13__c != null && lstOfformulaFields[0].ImageFormula13__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula13__c);
            if(lstOfformulaFields[0].ImageFormula14__c != null && lstOfformulaFields[0].ImageFormula14__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula14__c);
            if(lstOfformulaFields[0].ImageFormula15__c != null && lstOfformulaFields[0].ImageFormula15__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula15__c);
            if(lstOfformulaFields[0].ImageFormula16__c != null && lstOfformulaFields[0].ImageFormula16__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula16__c);
            if(lstOfformulaFields[0].ImageFormula17__c != null && lstOfformulaFields[0].ImageFormula17__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula17__c);
            if(lstOfformulaFields[0].ImageFormula18__c != null && lstOfformulaFields[0].ImageFormula18__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula18__c);
            if(lstOfformulaFields[0].ImageFormula19__c != null && lstOfformulaFields[0].ImageFormula19__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula19__c);
            if(lstOfformulaFields[0].ImageFormula20__c != null && lstOfformulaFields[0].ImageFormula20__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula20__c);
			
        }
		string altText = '';
		for(string strFieldValue :formulaFieldURL){
			if(strFieldValue!=null && strFieldValue!=''){
				WrapperClass objWrap = new WrapperClass();
				altText = strFieldValue.substringBetween('alt=','border');
				altText = altText.remove('"');
				
				strFieldValue = strFieldValue.substringBetween('src=', 'alt');
				strFieldValue = strFieldValue.remove('"');
				objWrap.alternativeText = altText;
				objWrap.url = strFieldValue;
					lstWrap.add(objWrap);
			}
		}
		return lstWrap;
    }
	public class WrapperClass{
		@AuraEnabled
		public string url {get;set;}
		@AuraEnabled
		public string alternativeText {get;set;}
	}
}

 
Please help me with simple code...
A trigger that will prevent a user from creating a lead that already exists as a contact. We will use the lead /contact email address to detect duplicates.
Lead is created or updated.
Lead has an email address.
2. Try to find a matching contact based on email address.(Using SOQL)
If a match is found give an error
 If a match is not found do nothing
Hi All,
I would like to display the Contact First Name and Last Name in a trailhead task.

In the Contact Object Manager, Fields & Relationship I am not able to find the First Name and Last Name fields. Seems both are concatenated and updated in Name field.

But how could I know that there is a concatenate happening at the background and why the First and Last Name fields are not displayed in the List.

Thanks
Vijay
  • April 13, 2019
  • Like
  • 0
Hello ,
I have created two lookup relationship on Contact object with Account Object. 
But i am unable to use SOQL query with one of the relationship. Can you please help me on this.
 Relationship Working with CustomAccount FieldRelationship not working with CustomContacts RelationshipUser-added imageUser-added image
Could you please help me to understand, as both the relationship from contact to account are same, why SOQL is working with other relationship and not with other one
To make a test class pass, our developer consultant has given "modify all" permission.  Is this really acceptable?  I am a sys admin - so I have a lot to learn here!
Please comment, or suggest resources for me to read.
I am having an issue with detecting lightning in our Production environment.

We have a redirect VF page that is overriding the edit action of one of our custom objects. The controller for this VF page does a check for lightning by checking UserInfo.getUiThemeDisplayed(). However, for some reason, the org is only returning Theme3 at the moment. I tested in a dev console, and typing in
System.debug( 'UI Theme displayed: ' + UserInfo.getUiThemeDisplayed() );
results in Theme3, regardless of whether I am running that anonymous code in Classic or LEX. I assume this is due to a weird quirk with the developer console. But the VF page is giving me the same response.

I am aware of a current bug with the UserInfo.getUiTheme[Displayed] functions that cannot detect the actual page the User is viewing. It only looks at the setting. For example, if the user clicks the link to switch back to Classic, but then opens a link that is specifically for lightning (eg hostname.my.salesforce.com/lightning/r/Account/[id]/view), it will open that link in the LEX context. But getUiTheme and getUiThemeDisplayed will still think that the page is in Classic since the User's setting is set to Classic. However, that bug is not what is happening here for me.

In my current situation, even if I click the "switch to lightning experience" link, it still continues to show Theme3 for getUiThemeDisplayed. I know we can detect lightning by checking the URL, but I'd rather avoid that hacky and unstable workaround.

Has anyone else experienced this kind of behavior and could give me some insights as to what is happening?

Somthing else that may be important to know is that I am currently unable to reproduce this in my dev org or any of our Sandboxes at the moment.
Hi,

I'm working on this trigger but I get an error at this line:

Contact contacts = Trigger.new;

Illegal assignment from List<Contact> to Contact ​​​​​​​

Do you know why?
How should it be done correctly?

​​​​​​​Thanks.
trigger TriggerAmbassadorUpdateCall on Contact (before insert, after insert, before update, after update) {
 
        system.debug('trigger new ***' + Trigger.new);
        system.debug('trigger new ***' + Trigger.old);
        
        //define variable data
        Contact contacts = Trigger.new;
        
        //create a set of contact Ids
        
       List<Id> contactIds = new List<Id>();
       // Map<Id, String> contactMaps = new Map<Id, String>();
        
        //loop through data
        for ( Contact contact : contacts ) {
           if( contact.Teacher_recuritment_status__c == 'Active' && contact.Ambassador__Short_Code__c!=null) {
           
            contactIds.add(contact.Id);
            }
        }
        
        if( Trigger.isUpdate) {
          //instantiate the class or create an object 
           
          //fire method
          ambassador.fireCall(contactIds);  
        }
        
        return;
  
}

 
I just started using lightning today.  Sorry for the simple question.  I am creating a lightning component where I need to display some fields from the Account on the lightning page and then pass the Account.Id to a controller to get some calculated data.

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >

What goes here?

<span>{!v.Name}</span>
</aura:component>
Assign the fields of one object to another. and  update data of Project_c
like this
I am System Administrator, and the following view has filter that all users having System Administrator profile, I see that some admins have Login link, so I can by click the Login to impersonate them, but some admins don't have the Login link, what causes the difference, they all have the same System Administrator profile.

Thanks.

User-added image
Hi,
Can anyone explain me the differene between Platform cache and @Auraenabled(cacheable=true)

I could see both are used for caching. Is there any specific use case to use them ?

Thanks,
Govindaraj.S
Hi,
Could anyone help me with below requirement,

I need to log the event messages and ReplayId's of the all the platform events iinto a custom object.

Please don't suggest me to go for another platform event.

Thanks,
Govindaraj.S
Hi,
I'm getting empty list when trying to populate using server call.

Component:
<aura:component controller="Picklistcontroller" implements="force:appHostable" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <!-- <aura:attribute name="listOfAccount" type="string[]" default="Account1, Account2" />  -->
    <aura:attribute name="listOfAccount" type="string[]" />
    <aura:attribute name="selectedAccount" type="string" />
    <lightning:select name="accountList" label="List Of Accounts:" value="{!v.selectedAccount}" onchange="{!c.onChangeEvent}">
        <aura:iteration items="{!v.listOfAccount}" var="varAccount" >
            <option label="{!varAccount.label}" value="{!varAccount.value}"></option>   
        </aura:iteration>
    </lightning:select>
</aura:component>
Controller:
({
    doInit : function(component, event, helper) {
		var action = component.get("c.getAccountValues");
        var opts = [];
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state == 'SUCCESS') {
                var lstAccount = response.getReturnValue();
                console.log('lstAccount-->' +JSON.stringify(lstAccount));                 
                for (var i = 0; i < lstAccount.length; i++) {
                    opts.push({ 
                        label: lstAccount[i].Name,
                        value: lstAccount[i].Id
                    });
                }
                component.set('v.listOfAccount', opts);
                console.log('listOfAccount-->' +JSON.stringify(opts));
            }
        });
        $A.enqueueAction(action);
	},
    
	onChangeEvent : function(component, event, helper) {
		alert(component.get('v.selectedAccount'));
	}
})
Apex class:
public class Picklistcontroller {
    @AuraEnabled
    public static list<string> getAccountValues(){
        list<String> lstStringAccount = new list<String>();
        for(Account accObj : [SELECT Id, Name FROM Account Limit 10]) {
            lstStringAccount.add(string.valueOf(accObj));
        }
        return lstStringAccount;
    }
}
Screenshot:
User-added image

Can anyone pls assist on this ?
Hi All
I keep getting the following compile error: Class Update_Currency must implement the method: void Database.Batchable<SObject>.execute(Database.BatchableContext, List<SObject>)
and global methods do not support parameter type of List<Opportunity>

FYI, here is my class code
global class Update_Currency implements Database.Batchable<Sobject>{
        global String apiKey;
    global Update_Currency(string apiKey){
        this.apiKey=apiKey;
    }   
      global Database.QueryLocator start(Database.BatchableContext bc){
       String query = 'select Id, Amount, INRValue__c from Opportunity';
       return Database.getQueryLocator(query);
      }
        global void execute(Database.BatchableContext bc, List<Opportunity> optyList){
        Http p = new Http();
        HttpREquest request = new HttpRequest();
        string endPoint = 'http://api.currencylayer.com/live';
        endPoint=endpoint+'access_key='+apiKey;
        endPoint=endPoint+'&currencies=INR&source=USD&format=1';
        request.setEndpoint(endpoint);
        request.setMethod('GET');
        HttpREsponse responce = p.send(request);
        String jsonString= response.getBody();
        System.JSONParser jp=JSON.createParser(jsonString);
        Decimal inrValue;
        while(jp.getText()!=null){
            if(jp.getText()=='USDINR'){
                jp.nextToken();
                inrValue=(Decimal)jp.getDecimalValue();
            }
        }
        for(Opporttunity op:optyList){
            op.INRValue__c = 'Rs'+(op.amount*inrValue);
        }
            update optyList;}
    global void finish(Database.BatchableContext bc){
        AsyncApexJob job =[select id,Status from AsyncApexjJob where Id =:bc.getJobId()];
        Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
        string[] toadd=new string []{'hariom.sfdc@gmail.com'};
        msg.setToAddresses(toAdd);
        msg.setSubject('Intergration First Programm');
        msg.setPlainTextBody('Batch operation Processed :'+job.status);
        Messaging.Email[] emails = new Messaging.Email[]{msg};
        Messaging.sendEmail(emails);    
    }               

}


Please assist. Thanks

 
We have Account & its child object CSP Passport (master - detail relationship). 
If child passport already exists (one or many), show the user the message to go and clone existing record. 
If there is no child object - the button on Account shall go to standard creation of this child record. The only field I would like to get prepopulated is Account ID (being master-detail relat.).
Now I am getting error "Account is not defined".
Button is created on Account.
{!REQUIRESCRIPT("/soap/ajax/43.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/43.0/apex.js")}
if(Account.CSP_Passport_Count__c>= 1) {
    alert("Please clone the latest created CSP Passport form");} 
else {
      window.open('a4e/e?CSP_Passport_Count__c.AccountId ={!Account.Id}');
}

Thanks in advance for all the suggestions
 
Dears,

I am facing following scenario

1. Need to display a User departmet in lead (Custom) new new page.

2. Owner field is always displaying while creating.

3. Formula filed is not displaying in the new page, It's only available in the detail page.

4. I would like to display a User departmnet (Custom field) as same as owner field.

5. Is that possible ?

Regards,
Soundar.  
i have objects Patient__c, Doctor__c, Appointment__c, Medications__c.
Appointment__c has field patient__c(lookup), doctor__c(lookup), AppointMentDate__c(Date)
Medications__c has field patient__c(lookup), doctor__c(lookup), description__c, NextVisit__c(date).
Patient__c has an Email__c field.
if medication record is created with NextVisit != Null, 
it should send email before 2 days To get Appointment.
if appointment is made before NextVisit__c date, email should not get sent.

Hi, i try to make a post API call.
On Postman with the wrapper and the token of my method, my api call work. The endpoint is good too. But on apex i have 401 error.

I think my SetHeader is bad :

request.setHeader('Authorization', 'oAuth 2.0 ' + accToken);
request.setHeader('Content-Type', 'application/json');
request.setHeader('Accept','*/*');
request.setBody(JSON.serialize(resWrap));
request.setMethod('POST');
request.setEndpoint(endPoint);
HttpResponse hresponse = htt.send(request);
system.debug(hresponse);

i have this response, ty for helping :
System.HttpResponse[Status=Non-Autorisé, StatusCode=401]

Hi everyone, 

Has someone managed to include a QR scanner in an salesforce app before? I want to use QRs that include a task's unique ID so i can complete a task by scanning a QR code. Some links to projects that I can use as inspiration are very welcome. 

Kind regards, 
 

Bart 

Hi I am trying to write a Apex class to create an account and return the record name and i am getting the below error:
Static method cannot be referenced from a non static context: String
Here is my Code:
public class AccountHandler {
      public static String insertNewAccount(String strNames)
      {
          try
          {
          Account acct = new Account();
            acct.Name = strNames;
            acct.Phone = '(415)555-1212';
            acct.NumberOfEmployees = 100;
        insert acct;
        ID acctID = acct.Id;
// Display this ID in the debug log
System.debug('ID = ' + acctID);
              return strNames;
          }
          catch(Exception ex)
          {
              return 'NULL';
          }
      }

}
public with sharing class LeaveTriggerHelper {
    public static void createTotalLeave(List<Employee_Detail__c> EmpList){
     
      List<Leaves__c> LeaveList = new List<Leaves__c>();
      for (Leaves__c obj: EmpList) {
         
         if (obj.Approval_Status__c == 'Approved')
            {
             // condition to check the old value and new value
            Leaves__c objLeave = new Leaves__c();   //To get the total leave value is separating from(EmpList) No.of.available.Leave and LeaveTaken(Leaves)
            obj.Total_Leave__c=EmpList.No_of_available_Leave__c - obj.Leave_Taken__c;        
            LeaveList.add(objLeave);
         }
      }
     
      insert LeaveList;  // DML to insert the Invoice List in SFDC
   }
}
BeerSearchData.cmp
____________________
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="recordList" type="List"/>
    <aura:attribute name="iden" type="String"/>
     <lightning:overlayLibrary aura:id="overlayLib"/>
    <div class="c-container">
        <lightning:layout horizontalAlign="spread" multipleRows="true">
            <aura:iteration items="{!v.recordList}" var="con">
                <lightning:layoutItem size="4" padding="around-small">
                    <div class="custom-box">
                        <lightning:card title="{!con.Beer_Name__c}"  iconName="custom:custom56" >
                            Alcohol % : {!con.Alcohol__c}&nbsp;
                            Price : {!con.Price__c}
                            <div class="slds-col slds-size_4-of-8">
                                <img src="{!$Resource.BeerImage}"/>
                            </div>
<aura:set attribute="actions">
<lightning:button name="{!con.Id}" label="View Details" onclick="{!c.detailspage}" variant="brand"/>
</aura:set>
                        </lightning:card>
                    </div>
                </lightning:layoutItem>
            </aura:iteration>
        </lightning:layout>
    </div>
    <div>
    </div>
</aura:component>

BeerSearchDataController.js
________________________

({
    detailspage : function(component, event, helper) {
    var eventSource = event.getSource();
       var beerObj = eventSource.get('v.name');
        component.set('v.iden',beerObj);
        component.set('v.truthy',true);
         $A.createComponent(
             "c:BeerDetails",
            {
                "v.iden": "beerObj",
            },
            function(BeerDetails, status, errorMessage){
               if (status === "SUCCESS") {
                   component.find('overlayLib').showCustomModal({
                       header: "Beer Details",
                       body: BeerDetails,
                       showCloseButton: true,
                       closeCallback: function() {
                           alert('You closed the alert!');
                       }
                   })
               }
           });
               
                     
}
});This is the Error.


BeerDetails.cmp
_______________
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
    <lightning:overlayLibrary aura:id="overlayLib"/>
    <aura:attribute name="beerId" type="String"/>
    <lightning:recordForm
        recordId="{!v.beerId}"
        objectApiName="Beer__c"
        layoutType="Full"
        columns="2"
        mode="view" />
  <div>
<lightning:button label="Order Now!" onclick="{!doOrder}" variant="brand"/>
</div>
</aura:component>
 
Hello Everyone,

Can someone please help me in creating a Lightning Component for showing the weather report?
Hey guys,

could anybody tell me or send me a link to documentation where it says what fires first?

In my org I have Apex triggers, processes, validation rules, workflow rules. What does fire first and what last? Is there some kind of system?

Thank you
Hi. 
I'm new in apex and I need help :).
I have an value field in Contact Object and I need to set primary contact for Account whose value is bigger than another contacts value fields;

For Example
Contact1 has value field = 1;
Contact 2 has value field = 2;

i need to make Contact 2 as a primary contact for account;

Thanks for help.

 
I created a lookup relationship between leads and campaigns. When I go to add a campaign to the related list in leads the "New" button does not show up. How do I get this button to display?User-added imageUser-added image
Hi,

Is there an easy way to confirm that my Salesforce org has access to an external endpoint? Just needing to simulate a call coming in from a Salesforce IP.

I have added the endpoint to the remote site settings also, and I've tried executing the below
 
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://www.yourendpoint.com');
req.setMethod('POST'); // you could also set this to 'GET' and remove the next line
req.setBody('body of the request');

HttpResponse response = http.send(req);
System.debug('BODY: ' + response.getBody());
System.debug('STATUS: ' + response.getStatusCode());
(replacing the placeholder endpoint url in the code with that of the external system - same one in the remote site setting)

However I'm getting an error message:

System.CalloutException: Read timed out

Any ideas?
I have a custom button within a custom object that was coded/made by Salesforce labs. The button works in classic, but it's not working as intended in Lightning. We need to make minor customization to the visual force codes in order to make this compatible with Lightning. Can anyone help with this? Or direct me to the right contact? Thanks!
Hi, 

  In below code I am hard coding RW: and FW: in the loop to compare and replace please suggest me how to  user keywords. 
public static void processUpdate(list<Case> cseLst) {
        String FWSubject;
        String RWSubject;
        String CaseSubject;
        list<Case> caseLst = new list<Case>();
       
        for (Case c : cseLst) {       
            if(c.subject <> null){     
                // Remove FW and RW from case subject to get exact string
                if(c.subject.Contains('FW:')){
                    FWSubject = c.subject.replaceAll('FW:','');
                    System.debug('FQ Trim String :' + FWSubject);
                    CaseSubject = FWSubject;     
                } else if(c.subject.Contains('RW:')){ 
                    RWSubject = c.subject.replaceAll('RW:','');
                    System.debug('RW Trim String :' + RWSubject);   
                    CaseSubject = RWSubject;

   }
}

Thanks
GMASJ
  • February 28, 2019
  • Like
  • 2
I have a simple Contact trigger in a sandbox org that is exhibiting some serious performance issues. After doing some debugging it looks like the issue boils down to accessing the items inside Trigger.new list. I mean literally just doing this:
Contact c = Trigger.new[i]
is really slow.

For example, this code runs reasonably quickly (processing 1000 updates in about 30 seconds):
trigger MyTrigger on Contact (after insert, after update, before delete) {
    if (Trigger.isUpdate) {
        for (Integer i = 0; i < Trigger.new.size(); i++) {
            Integer dummy = 0;
        }
    }
}

Results from bulk data load (coming from the bulk job details page):
Total Processing Time (ms): 29370
API Active Processing Time (ms): 27229
Apex Processing Time (ms): 28852

However, this code takes about six minutes to run:
trigger MyTrigger on Contact (after insert, after update, before delete) {
    if (Trigger.isUpdate) {
        for (Integer i = 0; i < Trigger.new.size(); i++) {
            SObject o = Trigger.new[i];
        }
    }
}

Results from bulk data load:
Total Processing Time (ms): 321264
API Active Processing Time (ms): 319187
Apex Processing Time (ms): 893650

If I record the time required to access individual list items like this:
trigger MyTrigger on Contact (after insert, after update, before delete) {
    if (Trigger.isUpdate) {
        for (Integer i = 0; i < Trigger.new.size(); i++) {
            Long e = System.currentTimeMillis();
            SObject o = Trigger.new[i];
            Long s = System.currentTimeMillis();
            System.debug('time: ' + (e - s));
        }
    }
}

I see a lot of times around 400 milliseconds.

What's going on here? Does it really take that long to access an element in a list? Is there any way around this?
 
I'm trying to create an Apex Class that checks all Account records on a daily basis and sends an email to the email field on ones that have a review due on that date.

For example:
Vendor ABC Pty Ltd has opted in for reviews (Vendor Review: Reminders = true), has an annual review date set in their record (Vendor Review: Date = 17/02/2019), and an email address set in their record (Vendor Review: Email = abc@test.com).

Here is my code:
global class VendorReviewCronJob implements Schedulable{ 
    
        global void execute(SchedulableContext SC) {
            sendmail();
        }

        public List<Id> getVendorReviewEmailAddresses(Integer Month, Integer Day) 
        { 
            List<Id> mailToIds = new List<Id>();
             
            Account[] a = [SELECT Id, Vendor_Review_Email__c, Vendor_Review_Date__c, Vendor_Review_Reminders__c
                            FROM Account 
                            WHERE DAY_IN_MONTH(Vendor_Review_Date__c) = : Day 
                            AND CALENDAR_MONTH(Vendor_Review_Date__c) = : Month   
                            ];
        
            for(Account recipient : a) {
                    
                    System.Debug('\n*******Found VendorReview Recipient');
                                        
                    if (recipient.Vendor_Review_Reminders__c == true)
                    {
                        mailToIds.add(recipient.Id);
                        System.Debug('\n*******Recipient: '+ recipient.Vendor_Review_Email__c);
                         
                    } else {
                        System.Debug('\n*******NO Recipient');
                    }
                
            }

            return mailToIds;
        }




        public void sendMail() 
        {
      
            String debugAddress = 'eyewell@salesforce.com';
            String VendorReviewEmailTemplateName = 'User_Vendor_Review_Required';       
            String debugMessage;
            String[] toAddresses;

            Integer DayOfEvent   = date.today().day();
            Integer MonthOfEvent = date.today().month();

            List<Id> VendorReviewIdsList = getVendorReviewEmailAddresses(MonthOfEvent,DayOfEvent);

            EmailTemplate VendorReviewTemplate = [select Id,Name,Subject,body from EmailTemplate where DeveloperName = :VendorReviewEmailTemplateName];
 
            if(VendorReviewTemplate != null && VendorReviewIdsList.isEmpty() == false)
            {

                Messaging.MassEmailMessage VendorReviewMail = new Messaging.MassEmailMessage();
    
                VendorReviewMail.setTargetObjectIds(VendorReviewIdsList);
                VendorReviewMail.setTemplateId(VendorReviewTemplate.Id);
                VendorReviewMail.setUseSignature(false);
                VendorReviewMail.setSaveAsActivity(true);

                try {
                    Messaging.sendEmail(new Messaging.MassEmailMessage[] { VendorReviewMail });
                }catch(Exception e)
                {
                    System.Debug(e);
                }
           
            }
            else
            {
                System.Debug('VendorReviewCronJob:sendMail(): Either an email template could not be found, or no Account has a Vendor Review today');
            }

                
        }

    
}
I've scheduled the apex class to run daily, but although it's showing that it has run, the emails for the reviews due that day haven't sent, and I also haven't received the confirmation email of how many were sent.

Admittedly, I got the base of the code from a mailer that was checking for birthdays on a Contact object, but I felt the same principles still applied.

Can anybody see where I've gone wrong?
public class Lookup {

    
    @AuraEnabled 
    public static String searchDB(String objectName, String fld_API_Text, String fld_API_Val, 
                                  Integer lim,String fld_API_Search,String searchText ){
        
        searchText='\'%' + String.escapeSingleQuotes(searchText.trim()) + '%\'';

        
        String query = 'SELECT '+fld_API_Text+' ,'+fld_API_Val+
                        ' FROM '+objectName+
                            ' WHERE '+fld_API_Search+' LIKE '+searchText+ 
                        ' LIMIT '+lim;
        
        List<sObject> sobjList = Database.query(query);
        List<ResultWrapper> lstRet = new List<ResultWrapper>();
        
        for(SObject s : sobjList){
            ResultWrapper obj = new ResultWrapper();
            obj.objName = objectName;
            obj.text = String.valueOf(s.get(fld_API_Text)) ;
            obj.val = String.valueOf(s.get(fld_API_Val))  ;
            lstRet.add(obj);
        } 
         return JSON.serialize(lstRet) ;
    }
    
    public class ResultWrapper{
        public String objName {get;set;}
        public String text{get;set;}
        public String val{get;set;}
    }
}
  • February 04, 2019
  • Like
  • 1

I followed this tutorial, http://www.wadewegner.com/2013/03/creating-anonymous-rest-apis-with-salesforce-com/ , to create a public rest service in a developer sandbox. If I run any of the following:

curl GET http://sitedomainname.cs1.force.com/services/apexrest/Widgets/
curl POST http://sitedomainname.cs1.force.com/services/apexrest/Widgets/
curl PUT http://sitedomainname.cs1.force.com/services/apexrest/Widgets/
curl DELETE http://sitedomainname.cs1.force.com/services/apexrest/Widgets/

I get an HTTP 301 response.

But strangely, if I run that URL through POSTMAN, any request calls my GET method. And if I run it through SOAP UI, it calls my POST and GET methods correctly.

Finally, if I call the same url, but HTTPS, I get a HTTP 503 error.

Here is my class:
 
@RestResource(urlMapping='/Widgets/*')
global class WidgetController {

    @HttpGet
    global static String getWidgets() {
        return 'GET';
    }

    @HttpPost 
    global static String createNewWidget() {
        return 'POST';
    }

    @HttpDelete
    global static String deleteWidgetById() {
        return 'DELETE';
    }

    @HttpPut
    global static String updateWidget() {
        return 'PUT';
    }
}



I should also add that all of these methods work correctly when authenticated through workbench