+ Start a Discussion
User SethUser Seth 
Please provide any video that will fit into this requirement
Best Answer chosen by User Seth
SwethaSwetha (Salesforce Developers) 
HI Seth,
Check this blog https://www.learnexperiencecloud.com/s/article/How-To-Personalize-The-Shared-Regions-of-Your-Experience-Builder-Site

I've found this related video: https://www.youtube.com/watch?v=37xrVqSJ7p4

If this information helps, please mark the answer as best. Thank you
PRASENJIT BANERJEE 24PRASENJIT BANERJEE 24 
public with sharing class  AccountTeamMemberController 
{
    @AuraEnabled
    public static list<Account_Team_Member__c> getRelatedList(Id recordId)
        {
            Apttus__APTS_Agreement__c objAgreement = [Select id , Apttus__Account__c from Apttus__APTS_Agreement__c where id =: recordId ];
            List<Account_Team_Member__c> atmlist = [Select Name, Role__c, Active__c,Email__c from Account_Team_Member__c 
                                                    where Account__c =: objAgreement.Apttus__Account__c AND Role__c ='Relationship Manager'];
             return atmlist;
           
        }
}
Best Answer chosen by PRASENJIT BANERJEE 24
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Prasenjit,

The test class can be something as below. You should give all the mandotaty fields in all the respective objects while creating them.
 
@istest
public class AccountTeamMemberControllerTest {
static testmethod void methTest(){
    Account Acc= new Account();
    Acc.Name='Sample';
    insert acc;
   Apttus__APTS_Agreement__c  agg= new Apttus__APTS_Agreement__c ();
    agg.name='sample agreement';
    agg.Apttus__Account__c = acc.id;
    insert agg;
    Account_Team_Member__c  acm= new Account_Team_Member__c ();
    acm.Name='samplemember';
    acm.Role__c='Relationship Manager';
    acm.Active=true;
    acm.Email__c='sample@gmail.com';
    acm.Account__c= acc.id;
    insert acm;
    AccountTeamMemberController.getRelatedList(agg.id);
}

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
Sudeep SinghSudeep Singh 
Done an integration with saleforce and SAP using Platform event.
Created a button so that when that button is clicked then the flow is triggered and Bi-directional integration happens. 
But problem is that in a single quote several quote line can be created and user can click that button in every addition of quote line group. that button will be activated if the quote status is "accepted". 
I want to prevent the user for clicking many times that button. 

how it is possible  ??

thnx
Best Answer chosen by Sudeep Singh
Sai PraveenSai Praveen (Salesforce Developers) 
HI Sudeep,

Can you edit your lightning page related to the object on which this button is present and enable dynamic form if it is not enabled and put the filter on the button such that checkbox field which you created should be false and then save it.

Now this button will be visible only when checkbox is false.

Please find the below article (https://help.salesforce.com/s/articleView?id=sf.dynamic_forms_overview.htm&language=en_US&r=https%3A%2F%2Fwww.google.com%2F&type=5#:~:text=With%20Dynamic%20Forms%2C%20you%20can,and%20sections%20that%20they%20want.) for the same.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
priyanka dashputrepriyanka dashputre 
Hello i m trying  to develope code  for "calculate loan amount from user input field and ifvalue is greater than 45 then create case and assign to u user in lwc , how to do it? Please help me 
Best Answer chosen by priyanka dashputre
VinayVinay (Salesforce Developers) 
Hi Priyanka,

Check below example to create case using LWC and make minor changes as per your requirement.

https://www.infallibletechie.com/2019/11/lightning-record-edit-form-and.html
https://salesforce.stackexchange.com/questions/365925/creating-a-case-with-createrecord-lwc-error-trouble

Thanks,
Aditya RautAditya Raut 
In the below class, how to put the List(oppList) in the value of Map(oppMap)?

public class class1{
    
    public static Map<Id, list<opportunity>> oppmethod(Set<Id> oppId){
        
    List<Opportunity> oppList = [SELECT Id, AccountId, Name FROM Opportunity where ID IN: oppId];

    Map<Id, list<opportunity>> oppmap = new Map<Id, list<opportunity>>();
    
    for(Opportunity op : oppList){
        oppmap.put(op.AccountId, op);
    }
    
    return oppmap;
    }
}
Best Answer chosen by Aditya Raut
AnkaiahAnkaiah (Salesforce Developers) 
Hi Aditya,

try with below code.
public class class1{
    
    public static Map<Id, list<opportunity>> oppmethod(Set<Id> oppId){
        
    List<Opportunity> oppList = [SELECT Id, AccountId, Name FROM Opportunity where ID IN: oppId];

    Map<Id, list<opportunity>> oppmap = new Map<Id, list<opportunity>>();
    
    for(Opportunity op : oppList){
        oppmap.put(op.AccountId, New List<opportunity>{op});
    }
    
    return oppmap;
    }

If this helps, Please mark it as best answer.

Thanks!!
 
rohan patel 30rohan patel 30 
i need a batch apex code or something to update contact onwer as same as account owner. there is more than 50,000 records.
Best Answer chosen by rohan patel 30
AnkaiahAnkaiah (Salesforce Developers) 
Hi Rohan,

try with below code.
global class updateContactOwner implements Database.Batchable<Contact>{

   global Database.QueryLocator start(Database.BatchableContext BC){
     String query = 'Select id, ownerId,Account.OwnerId from Contact'; 
     return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, List<Contact> scope){
     List<Contact> conList = new List<Contact>();
     for(Contact con : scope){
       con.ownerID = con.Account.OwnerId;
       conList.add(con);
     }
     update conList;
    }

   global void finish(Database.BatchableContext BC){
   }
}

open annoumus window and run the below code.
updateContactOwner  batch = new updateContactOwner ();

Database.executebatch(batch,200);


If this helps, Please mark it as best answer.

Thanks!!
suji srinivasansuji srinivasan 
Hi , I am able to fetch values for visualforce page . I need to filter my values by particular recordtype. when i mentioned recordtype , i got nullpointer exception .can anyone guide me?



Apex class :

public with sharing class SalaryRewards {
    
public String salaryId {
  
 
 
 public List<salaryInfo> lsalaryInfo{get;set;}
 public List<Salary_Detail__c> salarydetail{get;set;}
  
      
 public void SalaryRewards(ApexPages.StandardController controller) 
    {  
        
       
     lsalaryInfo = new list<salaryInfo>();
 Id tr=Schema.SObjectType.Milestone__c.getRecordTypeInfosByName().get('Transaction').getRecordTypeId();
     list<Salary_Detail__c> salarydetail =[SELECT Id, Professional_Tax__c,BasicAllowance__c,HouseRentAllowance__c,Skill_up_Allowance__c,Employee_Contributionto_PF_Monthly__c,Company_s_Contributionto_PF_Monthly__c,SpecialAllowance__c,TotalEarnings__c,TotalDeductions__c, NetPay__c,createdDate,TaxExempt__c FROM Salary_Detail__c WHERE createdDate = THIS_YEAR  AND RecordTypeId =:tr ];
  
            for(Salary_Detail__c sal: salarydetail)
        {
           salaryInfo  sinfo = new salaryInfo (sal.BasicAllowance__c,sal.CreatedDate,sal.Professional_Tax__c,sal.HouseRentAllowance__c,sal.Skill_up_Allowance__c,sal.SpecialAllowance__c,sal.Company_s_Contributionto_PF_Monthly__c,sal.Employee_Contributionto_PF_Monthly__c,sal.TotalEarnings__c,sal.TotalDeductions__c,sal.NetPay__c,sal.TaxExempt__c,sal);
           sinfo.month =sal.createdDate.format('MMMMM');
           sinfo.salaryDetail = sal;
           lsalaryInfo.add(sinfo);
           system.debug('salary-month===>'+lsalaryInfo);
        }    }  
         
public class salaryInfo  {
     public Datetime d {get;set;}
     public string month{get;set;}
     public Salary_Detail__c salaryDetail {get;set;}
     public Decimal Basic_Allowance {get;set;}
     public Decimal Professional_Tax{get;set;}
     public datetime createddate {get;set;}
     public Decimal House_Rent_Allowance {get;set;}
     public Decimal Skill_up_Allowance {get;set;}
     Public Decimal SpecialAllowance {get;set;}
     Public Decimal Company_s_Contributionto_PF_Monthly {get;set;}
     public Decimal Employee_Contributionto_PF_Monthly {get;set;}
     public Decimal Netpay {get;set;}
     public Decimal TotalEarnings {get;set;}
     Public Decimal TotalDeductions {get;set;}
     public Decimal TaxExempt {get;set;}
    
    
    
 public salaryInfo (Decimal Basic_Allowance ,datetime createdDate ,Decimal Professional_Tax,Decimal House_Rent_Allowance,Decimal Skill_up_Allowance ,Decimal SpecialAllowance,Decimal Company_s_Contributionto_PF_Monthly,Decimal Employee_Contributionto_PF_Monthly , Decimal Netpay,Decimal TotalEarnings,Decimal TotalDeductions ,Decimal TaxExempt,Salary_Detail__c sd ){
           this.Basic_Allowance = Basic_Allowance;
           this.salaryDetail= sd;
           this.createdDate = createdDate;
           this.Professional_Tax = Professional_Tax;
           this.House_Rent_Allowance = House_Rent_Allowance;
           this.Skill_up_Allowance = Skill_up_Allowance;
           this.SpecialAllowance = SpecialAllowance;
           this.Company_s_Contributionto_PF_Monthly = Company_s_Contributionto_PF_Monthly;
           this.Employee_Contributionto_PF_Monthly = Employee_Contributionto_PF_Monthly;
           this.Netpay = Netpay;
           this.TotalEarnings = TotalEarnings;
           this.TotalDeductions =TotalDeductions;
           this.TaxExempt = TaxExempt;
  }
     

       
}


Thanks in advance
Best Answer chosen by suji srinivasan
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Suji,

You are quering on Salary_Detail__c object but you are getting id on different object. Can you recheck this line again.
 
Id tr=Schema.SObjectType.Milestone__c.getRecordTypeInfosByName().get('Transaction').getRecordTypeId();

I hope this should be as below.
 
Id tr=Schema.SObjectType.Salary_Detail__c.getRecordTypeInfosByName().get('Transaction').getRecordTypeId();

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
Akshay Alandkar 8Akshay Alandkar 8 

Hi all , want to create vf page like below 
User-added image

 

 

For this i have written vf page code as
<apex:page id="FeedbackPage" controller="FeedbackClass"   standardStylesheets="false"  showHeader="false" sidebar="false">
    
    <c:ExternalLibrary />
    
    <apex:composition template="GNT__ModalTemplate">
        <apex:define name="ModalContent">
    
    
     <apex:form >
        <apex:pageBlock title="New feedback">
           
            <apex:pageBlockSection >
              
              
        &nbsp;&nbsp;&nbsp;     Type<apex:inputText value="{!Type}"/>   
        &nbsp;&nbsp;&nbsp;     Subject<apex:inputText value="{!Subject}"/>
        &nbsp;&nbsp;&nbsp;     Description<apex:inputTextArea richText="true" value="{!Description}"/>
        &nbsp;&nbsp;&nbsp;     URL<apex:inputText value="{!URL}"/>
              
              
               
            
                 
                <apex:commandButton value="Submit" onclick="alrt()" action="{!save}"/>
            </apex:pageBlockSection>
            
           
        
        
        </apex:pageBlock>
    </apex:form>
    
        </apex:define>
    </apex:composition> 
</apex:page>

 

and Controller is 

public without sharing class FeedbackClass{


public String Description{get;set;}
public String Subject{get;set;}
public String Type{get;set;}
public String URL{get;set;}
public PageReference save() {
Feedback__c ac = new Feedback__c();
ac.Description__c= Description;
ac.Subject__c= Subject;
ac.Type__c= Type;
ac.URL__c= URL;
insert ac;
this.Description = null;
this.Subject= null;
this.Type = null;
return null;
}

}

 

and got result 

User-added image so how to add Picklist field and attachment tab to this vf page please help 

Best Answer chosen by Akshay Alandkar 8
Sai PraveenSai Praveen (Salesforce Developers) 
HI,

Can you try the below code .

Vf page:
 
<apex:page  standardController="Feedback__c" extensions="Redirect_Main"  standardStylesheets="false"  showHeader="false" sidebar="false">
    

    
       
    
     <apex:form >
        <apex:pageBlock title="New feedback">
           
            <apex:pageBlockSection >
              
                 <apex:inputField value="{!accnt.Name}"/> <br/> 
                <apex:inputField value="{!accnt.Type__c}"/> <br/>  
         <apex:inputField value="{!accnt.Subject__c}"/> <br/> 
         <apex:inputField value="{!accnt.Description__c}"/> <br/>
                    <apex:inputFile value="{!file}" filename="{!fileName}"/>


               

            

               
            
                 
                <apex:commandButton value="Submit"  action="{!save}"/>
            </apex:pageBlockSection>
            
           
        
        
        </apex:pageBlock>
    </apex:form>
    

</apex:page>

Apx:
 
public class Redirect_Main {
  public Feedback__c accnt{get;set;}  
public Redirect_Main(ApexPages.StandardController sc) {
        this.accnt = (Feedback__c )sc.getRecord();
    }
  
 public String title{ get;set; }
    public ContentVersion cv { get; set; }
        public String fileName { get; set; }
    public transient  blob file { get; set; }

public PageReference save() {

insert accnt;
    ContentVersion cv = new ContentVersion();
            cv.versionData = file;
            cv.title = 'sample file';
            cv.pathOnClient = fileName;
            cv.FirstPublishLocationId = accnt.id; 
            try
            {
                Insert cv;
            }
            catch (DMLException e)
            {
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading Document in Library'));
                return null;
            }
            finally
            {
                cv = new ContentVersion();
            }
return null;
}
   
}

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
Best Answer chosen by Aditya Raut
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Aditya,

Can you try the below trigger on Account.
 
trigger DoNotDeleteAccountHavingRelatedContact on Account (before delete)  
{  
    List<Account> accList = new List<Account>();  
    Set<id> accIdSet = new Set<id>();  
    for(Account acc : Trigger.old)  
    {  
        accIdSet.add(acc.id);  
    }  

    Map<Id, Account> accts = new Map<Id, Account>([Select Id, (Select Id from contacts) from Account where id in :accIdSet]);

    for(Account acc : Trigger.old)
    {
        if(accts.get(acc.id).contacts.size()>0)
        {
            acc.adderror('Account cannot be deleted');
            }
        }                                       

}

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
Maksym MarshaliukMaksym Marshaliuk 
I have text field 'Score__c' which defines Score of footbal match. Like '1:2'. I need co create validation rule named 'Validate scores in Score__c cannot be negative numbers (even though represented as a string)'. I stuck on a problem because i dont know how can i extract first number and compare is with second. 
Best Answer chosen by Maksym Marshaliuk
PriyaPriya (Salesforce Developers) 
Hi Maksym,

One approach can be checking the '-' sign in validation rule. If the field value contain '-', then give the error message. 

so try like this :-
Error Condition Formula
	CONTAINS( Score__c ,'-')

Kindly mark it as the best answer if it works for you.

 

Thanks & Regards,

Priya Ranjan