• shaker shaikh
  • NEWBIE
  • 20 Points
  • Member since 2017
  • salesforce developer
  • eClerx

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 20
    Replies
Hello All,
I was given a scenario like - I have two different org A and B, and want merge them into C. where in i want my all profile and permitions, record created date, and created by would be shown as it is in A and B, also workflow, and data duplication, and want al data and security as it is in C,
 parent and child record relations and opportunity value and all etc stuff,
  I only want if i merge A and B into C everything shold be applied as it is dealing with  A and B.
  Request you to metion like point wize/activity wize having number like 1) action should be take 2) and more.......
also things which can be done by configuratiuon and customization
 Thanks in advance 
Hi experts,
i want update account field from opportunity and have written below code block a class for account and a trigger which will invoke while inserting 
i have 

public class Account_opp_update_DAO {
    public static account opportunityInsert(id accountId, decimal newAmount){
        system.debug('called Account_opp_update_DAO.opportunityInsert of account id :'+accountId);
        system.debug('called Account_opp_update_DAO.opportunityInsert of newAmount id :'+newAmount);
        account act=[SELECT All_Opportunity_Revenue__c,Total_opportunity__c FROM Account where id=:accountId LIMIT 1];
        act.Total_opportunity__c= act.Total_opportunity__c+1;
        act.All_Opportunity_Revenue__c=act.All_Opportunity_Revenue__c+newAmount;
        return act;
    }
}

trigger

trigger Opportunity_detail on Opportunity (after insert,after update, after delete, after undelete) {
    list <Opportunity> lstopp = new list<opportunity>();
    list <Account> lstAccount = new list<Account>();
    if (trigger.isInsert){
        for(opportunity op: lstopp){
            system.debug(op);
            system.debug(op.AccountId);
            Account act = Account_opp_update_DAO.opportunityInsert(op.accountID, op.amount);
            lstAccount.add(act);
       }    
            insert lstAccount;
            update lstopp;
    }
}
code doesn't give any error but i unable to update account field

My Requirment
On account field there are two field Total_opportunity__C and Total_revenue_from_all_opp__C
 when ever new opportunity is created want that should be appear on account page and if there are multiple opportunity connected with account
so that total summary should show in Total_revenue_from_all_opp__C.

im going by creating DAO class on account. i have searched other way that we can directly creat trigger on opportunity, but didnot understand

please help to get this solved

Thanks.
Hi developers,
i have designed a page and its code looks of for and got saved successfully. still i unable to find bug or where i am making mistake
it throws error  -  System.NullPointerException: Attempt to de-reference a null object - on line 28 column 1
  request you to look into this code and help me please :

public class TravelPortalSearchController {
  public String searchTerm{get;set;}
    public String fromPrice{get;set;}
    public String toPrice{get;set;}
    public List<Travel_Packages__c> travelPackages{get;set;}
    public List<TravelPackageWraper> travelPackageWrapper{get;set;}
    public Contact loggedInUser{get;set;}
    public List<User_Favorites__c> userFavList{get;set;}
    public String loggedInUserName{get;set;}
    public Integer favoriteCount{get;set;}
    public Set<Id> favoriteIds = new Set<Id>();
    
    public TravelPortalSearchController(){
        travelPackages = new List<Travel_Packages__c>();
        travelPackageWrapper = new List<TravelPackageWraper>();
        loggedInUser=(Contact)Cache.Session.get('LoggedInUser');
        userFavList=(List<User_Favorites__c>)Cache.Session.get('UserFavorites');
        if(loggedInUser!=null){
            loggedInUserName=loggedInUser.firstName+' '+loggedInUser.lastName;
        }else{
            loggedInUserName='';
        }
        if(userFavList!=null){
            favoriteCount=userFavList.size();
        }else{
            favoriteCount=0;
        }
        for(User_Favorites__c favObj: userFavList){
            favoriteIds.add(favObj.Travel_Packages__c);
        }
    }
    
    public PageReference searchTravelPackages(){
        travelPackageWrapper = new List<TravelPackageWraper>();
        Decimal fromPriceNum = 0;
        Decimal toPriceNum = 0;
        if(fromPrice!=null && fromPrice.isNumeric()){
            fromPriceNum=Decimal.valueOf(fromPrice);
        }
        if(toPrice!=null && toPrice.isNumeric()){
            toPriceNum=Decimal.valueOf(toPrice);
        }
        travelPackages = TravelPackageDAO.fetchTravelPackages(searchTerm, fromPriceNum, toPriceNum);
        for(Travel_Packages__c tPackage : travelPackages){
           Boolean isFavorites = favoriteIds.contains(tPackage.id);
           travelPackageWrapper.add(new TravelPackageWraper(tPackage,isFavorites));
        }
        return null;
    }
    
    public PageReference addOrRemoveFavorite(){
        System.debug('addToFavorite');
        System.debug('loggedInUser: '+loggedInUser);
        String packageId =  ApexPages.currentPage().getParameters().get('packageId');
        System.debug('packageId');
        if(!favoriteIds.contains(packageId)){
            UserFavoriteDAO.insertUserFavorite(loggedInUser.id, packageId);
            favoriteCount+=1;
        }else{
            UserFavoriteDAO.removetUserFavorite(loggedInUser.id, packageId);
            favoriteCount-=1;
        }
        userFavList = UserFavoriteDAO.fetchFavorites(loggedInUser);
        favoriteIds=new Set<Id>();
        for(User_Favorites__c favObj: userFavList){
            favoriteIds.add(favObj.Travel_Packages__c);
        }
        travelPackageWrapper = new List<TravelPackageWraper>();
        for(Travel_Packages__c tPackage : travelPackages){
           Boolean isFavorites = favoriteIds.contains(tPackage.id);
           travelPackageWrapper.add(new TravelPackageWraper(tPackage,isFavorites));
        }
        return null;
    }
    public class TravelPackageWraper{
        public Travel_Packages__c tPackage{get;set;}
        public Boolean isFavorite{get;set;}
        
        public TravelPackageWraper(){
            
        }
        
        public TravelPackageWraper(Travel_Packages__c tPackage,Boolean isFavorite){
            this.tPackage=tPackage;
            this.isFavorite=isFavorite;
        }
        
    }
}

VF Page - 

<apex:page showHeader="false" sidebar="false" Controller="TravelPortalSearchController">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="2">
     
                <apex:image url="{!URLFOR($Resource.TPImages, 'logo1.jpg')}" width="100" height="100" />                   
                
                <font color='Blue' size='6'>Demo Travel Portal</font>
        
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="3" id="headerSection">
                <font size='2'>Welcome {!loggedInUserName} !!!</font>
    
             <apex:image url="{!URLFOR($Resource.TPImages, 'empty.png')}" width="50" height="50" rendered="{!favoriteCount==0}"/>
             <apex:image url="{!URLFOR($Resource.TPImages, 'filled.png')}" width="50" height="50" rendered="{!favoriteCount>0}"/>

                  <font size='4'>Favorite Count: {!favoriteCount}</font>
    
            </apex:pageBlockSection>

            <apex:pageBlockSection columns="7">
                Search Term<apex:inputText value="{!searchTerm}" />
                From Price<apex:inputText value="{!fromPrice}" />
                To Price<apex:inputText value="{!toPrice}" />
                <apex:commandButton value="Search" action="{!searchTravelPackages}"/>       
            </apex:pageBlockSection>

            <apex:pageBlockSection columns="1" id="resultSection">
                <apex:pageBlockTable var="tp" value="{!travelPackageWrapper}">
                    <apex:column value="{!tp.tPackage.Location__c}"/>
                    <apex:column value="{!tp.tPackage.Number_of_Days__c}"/>
                    <apex:column value="{!tp.tPackage.Price__c}"/>
                    <apex:column >
                        <apex:commandLink action="{!addOrRemoveFavorite}" reRender="resultSection,headerSection">
                            <apex:image url="{!URLFOR($Resource.TPImages, 'empty.png')}" width="25" height="25"  rendered="{!(!tp.isFavorite)}"/>
                            <apex:image url="{!URLFOR($Resource.TPImages, 'filled.png')}" width="25" height="25"  rendered="{!tp.isFavorite}"/>

                            <apex:param name="packageId" value="{!tp.tPackage.id}"/>                                
                        </apex:commandLink>                            
                    </apex:column>

                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Appriciate for your time

thank you.




 
Hi All,
i went through the posts and articles, as i want change namespace Prefix but i found it says cant not be chabge.once it created i am using developer org, and though i unable to take support from salesforce. 

is there any way to change it ?

thanks
how to achive this--
if child record get deleteed then parent record also should get deleted in lookup relationship

 
Parent Object - Account  there are two field Total_opp__c and Total_revenue__C
(Lookup relationship)
Child object - Opportunity - field Revenue__C

i want sum of revenue on account record (in field Total_Revenue__C ) page as opportunities associated with it
and in th Total_Opp__C it should show count of opportunities like how many opportunities available in that
please help to complete below trigger...

trigger update_opp_detail on Opportunity (After insert, After update,After delete, After undelete) {
  
  set<id> oppSet = new set<id>();
  for (opportunity op : trigger.new) { 
      opSet.Add(op.AccountId);
  }


Thank you
the below written trigger showing error - Field is not writeable: CaseShare.CaseAccessLevel

trigger case_share on Case (After insert) {
    List<caseShare> csshare = new List<caseShare>();
    user ur = [SELECT id from user where Alias = 'ujosh'];
    for(Case c: Trigger.new){
        if(c.Priority=='High' && c.Origin=='Email'){
         caseShare cs = new caseShare();
         cs.caseid = c.id;
         cs.caseAccessLevel = 'Edit';
         cs.UserOrGroupId = ur.id;
         cs.RowCause = 'Manual';
        }
        csshare.add(cs);
    }
}

unable to understand where i am making error plz help ...
before asking my question ...How are you all ?    here i have written simple trigger which will simply update Description field at a time creating case record or update the record but if user has a case record where he found description is updated at the time of creation case record now he wants to modify it but when he saves he again gets same description which he deleted...?  trigger case_comments_update on Case (before insert,Before update ) {    for (case c: Trigger.new){        If(c.status == 'Working'){            c.Description = 'case is in working and user wants to modify this';        }    } }
there is a field called customer address suppose address is full field like '7828 National louisville new york 1234,  US' i need google map exit below the address field and if user click on map it should reach to address written in Address field.
 please help to get this.
where i can use custom settings or what can be scenario where in i need custom setting i have gone through the theory need any practical scenario,,?
1.i was asked a question what are communities , like partner community or there may be more what are these and there usage?    
2.i started study on salesforce lightning and when i open developer guide it has around 500 pages please help to  get exit study material so i can pass interview.
thanks.
how to show error message on same page even i put feildname.adderror('You can not delete Active accounts'); it takes me on new page for showing error can anyone answer it ... thanks in advance
Hi experts,
i want update account field from opportunity and have written below code block a class for account and a trigger which will invoke while inserting 
i have 

public class Account_opp_update_DAO {
    public static account opportunityInsert(id accountId, decimal newAmount){
        system.debug('called Account_opp_update_DAO.opportunityInsert of account id :'+accountId);
        system.debug('called Account_opp_update_DAO.opportunityInsert of newAmount id :'+newAmount);
        account act=[SELECT All_Opportunity_Revenue__c,Total_opportunity__c FROM Account where id=:accountId LIMIT 1];
        act.Total_opportunity__c= act.Total_opportunity__c+1;
        act.All_Opportunity_Revenue__c=act.All_Opportunity_Revenue__c+newAmount;
        return act;
    }
}

trigger

trigger Opportunity_detail on Opportunity (after insert,after update, after delete, after undelete) {
    list <Opportunity> lstopp = new list<opportunity>();
    list <Account> lstAccount = new list<Account>();
    if (trigger.isInsert){
        for(opportunity op: lstopp){
            system.debug(op);
            system.debug(op.AccountId);
            Account act = Account_opp_update_DAO.opportunityInsert(op.accountID, op.amount);
            lstAccount.add(act);
       }    
            insert lstAccount;
            update lstopp;
    }
}
code doesn't give any error but i unable to update account field

My Requirment
On account field there are two field Total_opportunity__C and Total_revenue_from_all_opp__C
 when ever new opportunity is created want that should be appear on account page and if there are multiple opportunity connected with account
so that total summary should show in Total_revenue_from_all_opp__C.

im going by creating DAO class on account. i have searched other way that we can directly creat trigger on opportunity, but didnot understand

please help to get this solved

Thanks.
Hi developers,
i have designed a page and its code looks of for and got saved successfully. still i unable to find bug or where i am making mistake
it throws error  -  System.NullPointerException: Attempt to de-reference a null object - on line 28 column 1
  request you to look into this code and help me please :

public class TravelPortalSearchController {
  public String searchTerm{get;set;}
    public String fromPrice{get;set;}
    public String toPrice{get;set;}
    public List<Travel_Packages__c> travelPackages{get;set;}
    public List<TravelPackageWraper> travelPackageWrapper{get;set;}
    public Contact loggedInUser{get;set;}
    public List<User_Favorites__c> userFavList{get;set;}
    public String loggedInUserName{get;set;}
    public Integer favoriteCount{get;set;}
    public Set<Id> favoriteIds = new Set<Id>();
    
    public TravelPortalSearchController(){
        travelPackages = new List<Travel_Packages__c>();
        travelPackageWrapper = new List<TravelPackageWraper>();
        loggedInUser=(Contact)Cache.Session.get('LoggedInUser');
        userFavList=(List<User_Favorites__c>)Cache.Session.get('UserFavorites');
        if(loggedInUser!=null){
            loggedInUserName=loggedInUser.firstName+' '+loggedInUser.lastName;
        }else{
            loggedInUserName='';
        }
        if(userFavList!=null){
            favoriteCount=userFavList.size();
        }else{
            favoriteCount=0;
        }
        for(User_Favorites__c favObj: userFavList){
            favoriteIds.add(favObj.Travel_Packages__c);
        }
    }
    
    public PageReference searchTravelPackages(){
        travelPackageWrapper = new List<TravelPackageWraper>();
        Decimal fromPriceNum = 0;
        Decimal toPriceNum = 0;
        if(fromPrice!=null && fromPrice.isNumeric()){
            fromPriceNum=Decimal.valueOf(fromPrice);
        }
        if(toPrice!=null && toPrice.isNumeric()){
            toPriceNum=Decimal.valueOf(toPrice);
        }
        travelPackages = TravelPackageDAO.fetchTravelPackages(searchTerm, fromPriceNum, toPriceNum);
        for(Travel_Packages__c tPackage : travelPackages){
           Boolean isFavorites = favoriteIds.contains(tPackage.id);
           travelPackageWrapper.add(new TravelPackageWraper(tPackage,isFavorites));
        }
        return null;
    }
    
    public PageReference addOrRemoveFavorite(){
        System.debug('addToFavorite');
        System.debug('loggedInUser: '+loggedInUser);
        String packageId =  ApexPages.currentPage().getParameters().get('packageId');
        System.debug('packageId');
        if(!favoriteIds.contains(packageId)){
            UserFavoriteDAO.insertUserFavorite(loggedInUser.id, packageId);
            favoriteCount+=1;
        }else{
            UserFavoriteDAO.removetUserFavorite(loggedInUser.id, packageId);
            favoriteCount-=1;
        }
        userFavList = UserFavoriteDAO.fetchFavorites(loggedInUser);
        favoriteIds=new Set<Id>();
        for(User_Favorites__c favObj: userFavList){
            favoriteIds.add(favObj.Travel_Packages__c);
        }
        travelPackageWrapper = new List<TravelPackageWraper>();
        for(Travel_Packages__c tPackage : travelPackages){
           Boolean isFavorites = favoriteIds.contains(tPackage.id);
           travelPackageWrapper.add(new TravelPackageWraper(tPackage,isFavorites));
        }
        return null;
    }
    public class TravelPackageWraper{
        public Travel_Packages__c tPackage{get;set;}
        public Boolean isFavorite{get;set;}
        
        public TravelPackageWraper(){
            
        }
        
        public TravelPackageWraper(Travel_Packages__c tPackage,Boolean isFavorite){
            this.tPackage=tPackage;
            this.isFavorite=isFavorite;
        }
        
    }
}

VF Page - 

<apex:page showHeader="false" sidebar="false" Controller="TravelPortalSearchController">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="2">
     
                <apex:image url="{!URLFOR($Resource.TPImages, 'logo1.jpg')}" width="100" height="100" />                   
                
                <font color='Blue' size='6'>Demo Travel Portal</font>
        
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="3" id="headerSection">
                <font size='2'>Welcome {!loggedInUserName} !!!</font>
    
             <apex:image url="{!URLFOR($Resource.TPImages, 'empty.png')}" width="50" height="50" rendered="{!favoriteCount==0}"/>
             <apex:image url="{!URLFOR($Resource.TPImages, 'filled.png')}" width="50" height="50" rendered="{!favoriteCount>0}"/>

                  <font size='4'>Favorite Count: {!favoriteCount}</font>
    
            </apex:pageBlockSection>

            <apex:pageBlockSection columns="7">
                Search Term<apex:inputText value="{!searchTerm}" />
                From Price<apex:inputText value="{!fromPrice}" />
                To Price<apex:inputText value="{!toPrice}" />
                <apex:commandButton value="Search" action="{!searchTravelPackages}"/>       
            </apex:pageBlockSection>

            <apex:pageBlockSection columns="1" id="resultSection">
                <apex:pageBlockTable var="tp" value="{!travelPackageWrapper}">
                    <apex:column value="{!tp.tPackage.Location__c}"/>
                    <apex:column value="{!tp.tPackage.Number_of_Days__c}"/>
                    <apex:column value="{!tp.tPackage.Price__c}"/>
                    <apex:column >
                        <apex:commandLink action="{!addOrRemoveFavorite}" reRender="resultSection,headerSection">
                            <apex:image url="{!URLFOR($Resource.TPImages, 'empty.png')}" width="25" height="25"  rendered="{!(!tp.isFavorite)}"/>
                            <apex:image url="{!URLFOR($Resource.TPImages, 'filled.png')}" width="25" height="25"  rendered="{!tp.isFavorite}"/>

                            <apex:param name="packageId" value="{!tp.tPackage.id}"/>                                
                        </apex:commandLink>                            
                    </apex:column>

                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Appriciate for your time

thank you.




 
how to achive this--
if child record get deleteed then parent record also should get deleted in lookup relationship

 
the below written trigger showing error - Field is not writeable: CaseShare.CaseAccessLevel

trigger case_share on Case (After insert) {
    List<caseShare> csshare = new List<caseShare>();
    user ur = [SELECT id from user where Alias = 'ujosh'];
    for(Case c: Trigger.new){
        if(c.Priority=='High' && c.Origin=='Email'){
         caseShare cs = new caseShare();
         cs.caseid = c.id;
         cs.caseAccessLevel = 'Edit';
         cs.UserOrGroupId = ur.id;
         cs.RowCause = 'Manual';
        }
        csshare.add(cs);
    }
}

unable to understand where i am making error plz help ...
before asking my question ...How are you all ?    here i have written simple trigger which will simply update Description field at a time creating case record or update the record but if user has a case record where he found description is updated at the time of creation case record now he wants to modify it but when he saves he again gets same description which he deleted...?  trigger case_comments_update on Case (before insert,Before update ) {    for (case c: Trigger.new){        If(c.status == 'Working'){            c.Description = 'case is in working and user wants to modify this';        }    } }
there is a field called customer address suppose address is full field like '7828 National louisville new york 1234,  US' i need google map exit below the address field and if user click on map it should reach to address written in Address field.
 please help to get this.
where i can use custom settings or what can be scenario where in i need custom setting i have gone through the theory need any practical scenario,,?
1.i was asked a question what are communities , like partner community or there may be more what are these and there usage?    
2.i started study on salesforce lightning and when i open developer guide it has around 500 pages please help to  get exit study material so i can pass interview.
thanks.
how to show error message on same page even i put feildname.adderror('You can not delete Active accounts'); it takes me on new page for showing error can anyone answer it ... thanks in advance