+ Start a Discussion
Timothy SmithTimothy Smith 
Attempting to access the variables MIlestone1_Project__c has a Lookup relationship to Account with relationship name: `Projects__r'.
 
List<Account> accList = [SELECT Id, Name, EHR_Status__c, PM_Status__c,
                                    Project_Imp_Status__c, Other_Status__c,(select Client_Advisor_Email__c,
                                                                                 Resource_Coordinator_Email__c
                                                                                 from Projects__r) 

                             FROM Account
                             WHERE Id IN :AcctIds];
 
List<String> emailAdds = new List<String>();
                 for (Account al: accList) {
                    emailAdds.add(al.Projects__r.Client_Advisor_Email__c);
                    emailAdds.add(al.Projectss__r.Resource_Coordinator_Email__c); 
                 }



Any help is greatly appreciated.
 
Best Answer chosen by Timothy Smith
Boss CoffeeBoss Coffee
Projects__r will be a list for each Account, so it'll be something like the following.
for(Account al : accList) {
  for(Project__c proj : al.Projects__r) {
    emailAdds.add(proj.Client_Advisor_Email__c);
    // ...etc
  }
}
azhar khasimazhar khasim 
Hello guys,

Need help in these for writing a validation rule

When field: 'Candidate Final Status" is not blank, then field: "Interviewer" and field: "Comments" is mandatory Validation Rule

Please help me from thiss...

Regards,
Azar Khasim

 
Best Answer chosen by azhar khasim
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
try this formula
AND( NOT( ISPICKVAL( Candidate_Final_Status__c ,'' )) ,
(OR(ISBLANK(F2F_Interviewer__c ),ISBLANK( F2F_Comments__c ))))

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards
SandrineSandrine 
Hello,



User-added image

I wan to filter by date of current year, how can i do it ?
I can filter by date but do i have option to filter by YEar()

thank you in advance 
Best Answer chosen by Sandrine
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi sandrine,
It is not possible .With roll up summary we can calculate the count,sum, minimum value, or maximum value of a field in the detail records.We can only summarize data records using Rollup fields.You can use Reports to filter records.
Please refer below link which might help you further
https://help.salesforce.com/articleView?id=fields_about_roll_up_summary_fields.htm&type=5
https://help.salesforce.com/articleView?id=rd_reports_overview.htm&type=5

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards
Foram Rana RForam Rana R 
User-added image
While clicking on button called Visualforce page.
Best Answer chosen by Foram Rana R
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

1. From Setup, click Object Manager, then click Lead.
2. Click Buttons, Links, and Actions, then New Button or Link.
3. Name the button.
4. Select List Button.
5. Content Source: Visualforce
6. Select your visualforce page. The visualforce page should use the object's standard controller.
<apex:page standardController="Lead" recordSetVar="leads">
   <apex:form>
      <apex:pageBlock title="Edit Stage and Close Date" mode="edit">
         <apex:pageMessages />
         <apex:pageBlockTable value="{!leads}" var="opp">
            <apex:column value="{!opp.Name}"/>
            <apex:column headerValue="Email">
               <apex:inputField value="{!opp.Email}"/>
            </apex:column>
            <apex:column headerValue="Phone">
               <apex:inputField value="{!opp.Phone}"/>
            </apex:column>
         </apex:pageBlockTable>
      </apex:pageBlock>
   </apex:form>
</apex:page>
7. Add button to the layout:
Stay in the Lead object, click Search Layouts for Salesforce classic menu, then select Edit under ListView.
Add your button to the "Selected Buttons".
Save.

Note: Mass actions aren’t supported on the most recent records list. They are only available on list views.

Please refer to the below links which might help you further with the above requirement.

https://developer.salesforce.com/blogs/developer-relations/2016/09/take-the-first-steps-ways-you-can-replace-javascript-buttons.html

https://trailhead.salesforce.com/en/content/learn/modules/lex_customization/lex_customization_buttons_links

https://www.simplysfdc.com/2018/03/salesforce-list-view-mass-action-in.html

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Abhishek MallikAbhishek Mallik 
Hi,

I am trying to solve a  trail challeng on Visualforce standard list controller (Visualforce standard list controller trail (https://trailhead.salesforce.com/content/learn/modules/visualforce_fundamentals/visualforce_standard_list_controllers)). I have written the following code for the same:
 
<apex:page standardController="Account" recordSetVar="accounts"> 
<apex:pageBlock> 
<apex:repeat value="{! accounts }" var="a"> 
 <li><apex:outputLink value="{! a.id}"></apex:outputLink> </li> 
</apex:repeat> 
</apex:pageBlock> 
</apex:page>


Here while checking, I am getting following error:
 
The page does not bind to the record ID value (in order to link to the record detail page)
Best Answer chosen by Abhishek Mallik
Khan AnasKhan Anas (Salesforce Developers) 
Hi Abhishek,

Greetings to you!

For each record, the repeater uses the apex:outputLink component to link to the respective record detail page. Please try below code:
<apex:page standardController="Account" recordSetVar="accounts" >
    <apex:pageblock>
        <apex:repeat var="a" value="{!accounts}" rendered="true" >
            <li>
                <apex:outputLink value="/{!a.Id}" >
                    <apex:outputText value="{!a.Name}"/>
                </apex:outputLink>
            </li>
        </apex:repeat>
    </apex:pageblock>
</apex:page>

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Arpitha MArpitha M 
Apex Class:

public class createCorporate {
    public Account acc {get;set;}
    public List<Contact> conList {get;set;}
    public AccountWrapper.cls_billing cbilling {get;set;}
    public AccountWrapper.cls_personal personal {get;set;}
    public Id Id{get;set;}
    public String message{get;set;}
    public string updatedmessage{get;set;}
    CorporateResponse core = new CorporateResponse();

    
    public createCorporate(ApexPages.StandardController controller){
        acc = (Account) controller.getRecord();
        Id = acc.Id;
    }
    public void createCorporatedata(){
        HMACGenearatorHandler hg = new HMACGenearatorHandler();
        fromJSON obj = new fromJSON();
        HMACGenearatorHandler.Wrapper wr;
        wr = hg.createJson();
        if(wr.response != null){
            obj = obj.parse(wr.response);
            string accesssecret = obj.hotelogix.response.accesssecret;
            string accesskey = obj.hotelogix.response.accesskey;
        
        acc= new Account();
        Contact con = new Contact();
        AccountWrapper aw = new AccountWrapper();
        AccountWrapper.cls_personal personal = new AccountWrapper.cls_personal();
        AccountWrapper.cls_billing cbilling = new  AccountWrapper.cls_billing();
        acc= [Select id,Name,taxCode__c,Account_Address__c,Account_State__c,Account_City__c,Account_Pincode__c,
              BillingStreet,BillingCity,BillingCountry,BillingState,BillingPostalCode,(Select id,Title,name,Type__c,Contact_Designation__c,
              Birthdate,Email,Gender__c,Fax,FirstName,LastName,MobilePhone,Phone                                                                        
              from contacts where Type__c != 'Others' ORDER BY Type__c ASC LIMIT 2) from Account where id =:Id];
        conList= acc.contacts;
        system.debug('con+++'+conList);
        for(Contact c : conList){
            if(c.Type__c =='Personal'){
                personal.salutation= c.Title;
                personal.designation =c.Contact_Designation__c;
                personal.dob =string.valueOf(c.Birthdate);
                personal.email =c.Email;
                personal.faxNo = c.Fax;
                personal.fName = c.FirstName;
                personal.gender =c.Gender__c;
                personal.lName = c.LastName;
                personal.mobileNo =c.MobilePhone;
                personal.phoneExtension='';
                personal.phoneNo =c.Phone;
                personal.website ='';               
            }
            if(c.Type__c =='Billing'){
                cbilling.salutation= c.Title;
                cbilling.designation =c.Contact_Designation__c;
                cbilling.dob =string.valueOf(c.Birthdate);
                cbilling.email =c.Email;
                cbilling.faxNo = c.Fax;
                cbilling.fName = c.FirstName;
                cbilling.gender =c.Gender__c;
                cbilling.lName = c.LastName;
                cbilling.mobileNo =c.MobilePhone;
                cbilling.phoneExtension='';
                cbilling.phoneNo =c.Phone;
                cbilling.website ='';      
            }
        }
        AccountWrapper.cls_office office = new AccountWrapper.cls_office();
        office.address = acc.Account_Address__c;
        office.city = acc.Account_City__c;
        office.country ='India';
        office.state=acc.Account_State__c;
        office.zip = String.valueOf(acc.Account_Pincode__c);
        
        AccountWrapper.cls_billingAddress billingad = new AccountWrapper.cls_billingAddress();
        billingad.companyName = acc.Name;
        billingad.address = acc.BillingStreet;
        billingad.city = acc.BillingCity;
        billingad.country = acc.BillingCountry;
        billingad.state=acc.BillingState;
        billingad.zip = acc.BillingPostalCode;
               
        AccountWrapper.cls_addresses addresses = new AccountWrapper.cls_addresses();
        addresses.office = office;
        addresses.billingaddress = billingad;
 
        AccountWrapper.cls_contacts contacts = new AccountWrapper.cls_contacts();
        contacts.personal = personal;
        contacts.billing = cbilling;
        
        AccountWrapper.cls_creditCardDetail carddetails = new AccountWrapper.cls_creditCardDetail();
        carddetails.nameOnCard ='Puja';
        carddetails.cardType ='Visa';
        carddetails.cardNo ='4111111111111111';
        carddetails.cvc ='256';
        carddetails.city='Delhi';
        carddetails.expiryMonth ='05';
        carddetails.expiryYear ='2022';
        carddetails.zip ='256';
        carddetails.address ='noida';
        carddetails.state ='delhi';
        carddetails.country ='India';
        
        List<AccountWrapper.cls_hotels> hotels = new List<AccountWrapper.cls_hotels>();
        AccountWrapper.cls_hotels hotel = new AccountWrapper.cls_hotels();
        hotel.id ='51237';
        hotels.add(hotel);
        
        AccountWrapper.cls_data data = new AccountWrapper.cls_data();
        data.groupCode='';
        data.businessName=acc.Name;
        data.taxCode =acc.taxCode__c;
        data.addresses= addresses;
        data.contacts = contacts;
        data.creditCardDetail = carddetails;
        data.creditLimit='100';
        data.paymentTerms='5';
        data.discount='10';
        data.discountable=true;
        data.hotels = hotels;
        
        AccountWrapper.cls_request req = new AccountWrapper.cls_request();
        req.key =accesskey;
        req.method='createcorporate';
        req.data = data;
        
        AccountWrapper.cls_hotelogix hlogix = new AccountWrapper.cls_hotelogix();
        hlogix.version='1.0';
        hlogix.datetime_x =wr.myDate;
        hlogix.request = req;
        aw.hotelogix = hlogix;
        String corporateJSON = JSON.serialize(aw);
        corporateJSON = corporateJSON.replace('datetime_x', 'datetime');
        system.debug('corporateJSON: '+ corporateJSON); 
        String mac2=hg.generateHmacSHA1Signature(corporateJSON,accesssecret);
        sendcreateCorpRequest(corporateJSON,mac2);
        } 
    } 
    public static void sendcreateCorpRequest(String corporatejson,String mac2){
        System.debug('mac2+++  '+ mac2);
        HttpRequest req = new HttpRequest();
        req.setEndpoint(System.Label.createCorporate);
        req.setMethod('POST');
        req.setHeader('X-HAPI-Signature',mac2);
        req.setHeader('Content-Type', System.label.Content_Type); 
        req.setBody(corporatejson);
        Http http = new Http();
        HTTPResponse res = http.send(req);
           System.debug(res);
           System.debug('createcorp++++ '+res.getBody());
           System.debug('GET STATUS +++ '+res.getStatus());
           String response = res.getBody();
           CorporateResponse core = new CorporateResponse();
           core = core.parse(response);
           System.debug('core++'+core);
           String message = core.hotelogix.response.status.message;
           System.debug(message);
           String updatedmessage = core.hotelogix.response.hotels[0].updateStatus.message;
           System.debug(updatedmessage);
      }
    
}


Visualforce Page:

<apex:page standardController="Account" extensions="createCorporate" action="{!createCorporatedata}">
            {!message}
            {!updatedmessage}
</apex:page>
 
Best Answer chosen by Arpitha M
Arpitha MArpitha M
The static should be removed from sendcreateCorpRequest() method. 
PraveenchanduPraveenchandu 
Example select id from account where id iN:accList 
Best Answer chosen by Praveenchandu
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi praveen,
list<list<sobject>> acc = new list<list<sobject>>();
acc = [FIND 'test' RETURNING Account(id,name WHERE id in :ids),contact(id,name WHERE id in :ids)];
list<id> ids1 = new list<id>();
for(sobject a : acc[0]){
       ids1.add(a.id); 
    }
for(sobject c:acc[1]){
    ids1.add(c.id);
}
system.debug(ids1);
//you can use this way to get ids in seperate lists
Account [] accounts = ((List<Account>)acc[0]);
Contact [] contacts = ((List<Contact>)acc[1]);
system.debug(accounts);
system.debug(contacts);

https://salesforce.stackexchange.com/questions/7334/why-does-sosl-return-a-list-of-a-list-of-sobjects-in-apex/7336

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards
Vikram23Vikram23 
Hello All,
Implementing a basic navigation component. No error while pushing the code to the scratch org, but when i click on the navigation buttons no action. Below is the image of our component on Account Record page.

User-added image

NavigationinLWC1.html
<template>
    <lightning-card title="Navigation Service in Lightning Web Component">
        <lightning-card title="Navigation to Record Page">
            <lightning-button-group>
                <lightning-button label="New Record Page" onclick={navigateToNewRecordPage}></lightning-button>
                <lightning-button label="Edit Record Page" onclick={navigateToEditRecordPage}></lightning-button>
                <lightning-button label="View Record Page" onclick={navigateToViewRecordPage}></lightning-button>
            </lightning-button-group>
        </lightning-card>
    </lightning-card>    
</template>

NavigationinLWC1.js
import { LightningElement,api } from 'lwc';
import {NavigationMixin} from 'lightning/navigation'
export default class NavigationinLWC1 extends LightningElement {
    @api recordId;
    navigateToNewRecordPage(){
        this[NavigationMixin.Navigate]({
            type:'standard__recordPage',
            attribute:{
                "recordId":this.recordId,
                "objectApiName":"Account",
                "actionName": "new"
            }
        });
    }

    navigateToEditRecordPage(){
        this[NavigationMixin.Navigate]({
            type:'standard__recordPage',
            attribute:{
                "recordId":this.recordId,
                "objectApiName":"Account",
                "actionName": "edit"
            }
        });
    }

    navigateToViewRecordPage(){
        this[NavigationMixin.Navigate]({
            type:'standard__recordPage',
            attribute:{
                "recordId":this.recordId,
                "objectApiName":"Account",
                "actionName": "view"
            }
        });
    }
}

Kindly help me out.
Best Answer chosen by Vikram23
Maharajan CMaharajan C
HI Vikram,

Your JS File have lot of small mistakes:

Just copy the below JS File code then it will work:

I have also bolded the area's in below where you have done the mistakes:


HTML:

<template>
    <lightning-card title="Navigation Service in Lightning Web Component">
        <lightning-card title="Navigation to Record Page">
            <lightning-button-group>
                <lightning-button label="New Record Page" onclick={navigateToNewRecordPage}></lightning-button>
                <lightning-button label="Edit Record Page" onclick={navigateToEditRecordPage}></lightning-button>
                <lightning-button label="View Record Page" onclick={navigateToViewRecordPage}></lightning-button>
            </lightning-button-group>
        </lightning-card>
    </lightning-card>    
</template>


JS:

/* eslint-disable no-console */
/* eslint-disable no-alert */
import { LightningElement,api } from 'lwc';
import {NavigationMixin} from 'lightning/navigation';                             
export default class LightningNavSamples extends NavigationMixin(LightningElement) {
    @api recordId;
    navigateToNewRecordPage(){
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Account',
                actionName: 'new'
            }
        });
    }
    navigateToEditRecordPage(){
        console.log('Record Id ==> '+ this.recordId);
        this[NavigationMixin.Navigate]({
            type:'standard__recordPage',
            attributes:{
                "recordId":this.recordId,
                "objectApiName":"Account",
                "actionName": "edit"
            }
        });
    }
    navigateToViewRecordPage(){
        console.log('Record Id ==> '+ this.recordId);
        this[NavigationMixin.Navigate]({
            type:'standard__recordPage',
            attributes:{
                "recordId":this.recordId,
                "objectApiName":"Account",
                "actionName": "view"
            }
        });
    }
}


Meta-XML File:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="helloWorld">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
   <target>lightning__AppPage</target>
   <target>lightning__RecordPage</target>
    <target>lightning__HomePage</target>
  </targets>
</LightningComponentBundle>


Thanks,
Maharajan.C
Maze LinnMaze Linn 
I am trying to write test coverage for a method and receiving the error "Attempt to de-reference a null object" when I run the test.  Below is my test class, can anyone guide me in the right direction with this?

Test class:

static testmethod void getselectOptionsTest(){
        Id RecordTypeIdPropAccount = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Franchisee').getRecordTypeId();
        
        Account fAcct = new Account(Name = 'Test', RecordTypeId=RecordTypeIdPropAccount);
        insert fAcct;
        sObject objObject = [SELECT Id, Name FROM Account WHERE Name = 'Test' LIMIT 1];
        String fld = 'RetailerCategory';
        
        Test.startTest();
        multiPicklistCtrl.getselectOptions(objObject, fld);
        Test.stopTest();
        
    }

Original method:

@AuraEnabled
    public static List <String> getselectOptions(sObject objObject, string fld) {
          system.debug('objObject --->' + objObject);
          system.debug('fld --->' + fld);
          List < String > allCats = new list < String > ();
          // Get the object type of the SObject.
          Schema.sObjectType objType = objObject.getSObjectType();
        
        // Describe the SObject using its object type.
          Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
 
          // Get a map of fields for the SObject
          map < String, Schema.SObjectField > fieldMap = objDescribe.fields.getMap();

          // Get the list of picklist values for this field.
          list < Schema.PicklistEntry > values =
           fieldMap.get(fld).getDescribe().getPickListValues();

          // Add these values to the selectoption list.
          for (Schema.PicklistEntry a: values) {
           allCats.add(a.getValue());
          }
          system.debug('allCats ---->' + allCats);
          allCats.sort();
          return allCats;    
        }
Best Answer chosen by Maze Linn
Dushyant SonwarDushyant Sonwar
Also if RetailerCategory is custom field then it would be RetailerCategory__c in fld variable.
Dilushan De SilvaDilushan De Silva 
Hi Everyone, I am going to create a flow to create records in opportunity object. I am going to add a quick action button in the accounts  which calls this flow. I want the account ID and Name linked to the new opportunity record that will be created. Any ideas how to do this?
Best Answer chosen by Dilushan De Silva