• Amol Salve 13
  • NEWBIE
  • 35 Points
  • Member since 2017

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 14
    Replies
I have a field called 'Expiry_Date__C.  Can anybody help me to write a formula to populate the last date of this to a date field using formula
  • June 29, 2017
  • Like
  • 0
I have a field called 'Expiry_Date__C.  Can anybody help me to write a formula to populate the last date of this to a date field using formula
  • June 29, 2017
  • Like
  • 0
Hi,

I need help on the following requirement below as follows,

1) I have a account object where contract is another object related to account

2) Contract object is having contract start date and end date which populates to account (start date__c and end date __c)

My scenario is 

3)If there are 2 active contract associcated to account and the dates contain

1st Active contracts dates are

start date :1.feb 2017
end date : 31st march 2017

2nd active contract dates are

start date : 1st march 2017
end date : 17th sep 2017

then in this scenatio the first active contract end date should be automatically backdated to the previous month below as follows to avoid overlapping between 2 contracts

1st active contract end date should automatically be changed to 

end date :28th feb 2017
start date should remain the same as 1 feb 2017.

basically both contracts end dates and start dates shouldnt fall in same range to avoid overlapping

Help me how to achieve this 

please help me with the trigger code

Thanks in advance
HI,

I have dependent picklist in SFDC custom object, and like to show these two picklist fields in Lightning component. For eg  like parent filed A and its child picklist filed B, Based on picklist values in A field the value in B changes.

Can anyone suggest how to implement this in Lightning component. I tried using UI:inputSelect, but its not working.
I have 2 picklists countries & states, when I select a country it brings in the states. But my condition is if countries other than United States and Canada are selected then the state picklist should not be shown in the VF page, if the countries selected are United States & Canada only then states picklist should be shown. Here is the code I have but I am unable to achieve the above requirement
<apex:selectList value="{!fanCountry_Region}" size="1">                                                    
 <apex:selectOptions value="{!countriesList}"></apex:selectOptions>
 </apex:selectList>

 <apex:selectList id="StatesList" value="{!fanState}" size="1">                
 <apex:selectOptions value="{!statesList}"></apex:selectOptions>
  </apex:selectList>

public String fanCountry_Region { get; set; }
public String fanState { get; set; }
public List<selectOption> countriesList { 
        set; 
        get{

            List<selectOption> countriesList = new List<selectOption>();
            countriesList.add(new selectOption(' ','--Select--'));

            map<string,Countries__c> countryMap = Countries__c.getAll();
            List<string> countries = new List<string>();
            countries.addAll(countryMap.keySet());
            countries.sort();

            for(string country : countries){

                Countries__c c = countryMap.get(country);
                countriesList.add(new selectOption(c.CountryCode__c, c.Name));
            }

            return countriesList; 
        } 
    }

  public List<selectOption> statesList { 
        set; 
        get{

            List<selectOption> statesList = new List<selectOption>();

            Map<String, States__c> allstates = States__c.getAll();
            Map<string, States__c> states = new Map<string, States__c>();
            for(States__c state : allstates.values()) { 
                if (state.countryCode__c == fanCountry_Region) { 
                    states.put(state.name, state); 
                } 
            }

            List<String> stateNames = new List<String>(); 
            stateNames.addAll(states.keySet()); 
            stateNames.sort(); 

            for (String stateName : stateNames) { 
                States__c state = states.get(stateName); 
                statesList.add(new SelectOption(state.StateCode__c, state.Name)); 
            } 

            if (statesList.size() > 0) { 
                statesList.add(0, new SelectOption(' ', '-- Select One --')); 
            } else { 
                statesList.add(new SelectOption(' ', 'Not Required')); 
            }

            return statesList;  
        } 
    }


Please hlep me out.

Thanks
smita

 
Hi,

I need help on the following requirement below as follows,

1) I have a account object where contract is another object related to account

2) Contract object is having contract start date and end date which populates to account 

My scenario is 

3)If there are 2 active contract associcated to account and the dates contain

1st Active contracts dates are

start date :1.feb 2017
end date : 31st march 2017

2nd active contract dates are

start date : 1st march 2017
end date : 17th sep 2017

then in this scenatio the first active contract end date should be automatically backdated to the previous month below as follows to avoid overlapping between 2 contracts

1st active contract end date should automatically be changed to 

end date :28th feb 2017
start date should remain the same as 1 feb 2017.

basically both contracts end dates and start dates shouldnt fall in same range to avoid overlapping

Help me how to achieve this 

Thanks in advance
I am using apex:pagemessages to show error message on my VF page. I want to hide/disapper it in 2 seconds. Anyone tell me how can i do this?
Help me to create test class for below code , Actually updating on lookup field on another


trigger code :

trigger updatecompany on pse__Expense_Report__c(after insert, after update){
        set<Id> ersIds = new set<Id>();

        // get the ids of the er whose company is not equal to null
        for(pse__Expense_Report__c er : trigger.new){
                if(er.ffpsai__OwnerCompany__c != null || er.ffpsai__OwnerCompany__c != ''){
                        ersIds.add(er.Id);
                }
        }

        List<pse__Region__c> reg = new List<pse__Region__c>();

        // query the export report with the er ids --
        
        for(pse__Region__c er : [select id, name, pse__Expense_Report__r.ffpsai__OwnerCompany__c from pse__Region__c where pse__Region__r.pse__Expense_Report__c  in : ersIds]){
                //assign the company value of er to export report company feidl
                
                er.ffpsai__OwnerCompany__c = er.pse__Expense_Report__r.ffpsai__OwnerCompany__c;

                // add them to the list
                reg.add(er);
        }

        update reg;
}

 
          List<Program_Member_Stage_MVN__c>Pms =[select id,Name,Parent_Program_Member_Stage_MVN__c,Program_Stage_MVN__c,Status_MVN__c,Program_Stage_Name_MVN__c,Stage_Sequence_Number_MVN__c,Activity_Sequence_Number_CTS__c,Parent_Program_Stage__c from Program_Member_Stage_MVN__c  where Program_Member_MVN__c=:Pm.id and Status_MVN__c='Not Started' and Parent_Stage__c !='Parent_Stage_MVN' order by Parent_Program_Stage__c,Activity_Sequence_Number_CTS__c]; 

I am getting this error:
 Field must be grouped or aggregated: Id at line 18 column 49.How to bypass this error?
Hi friends ,

I wrote a trigger on Territory2 object . And i create custom setting and field . In this custom setting the custom check field is checked for any particular user he only have the permission to delete option.

How to write test class for this trigger

Trigger :

trigger Triggerdelete on Territory2 (before delete) {
    id ids=userinfo.getProfileId();
    Delete_Permission__c del=Delete_Permission__c.getinstance(ids);
    if(del.Permission__c==false){
        Trigger.old[0].adderror('User Can\'t delete this Territory');
    }

}

 
Hi guys,

Can anyone please provide me an example on how to call a apex controller method in a visualforce custom component using a command button?
We have Layout Read-only fields to be added. Seems like a bug, when we try to add read-only fields they become read-write on layout. Please see below example.
 
public class metadatatest {
    public static void runUpdateLayouts(){        
        Metadata.Layout la = getLayout('Account-Account Layout');

        Metadata.LayoutSection sec = new Metadata.LayoutSection();
        sec.customLabel = true;
        sec.detailHeading = true;
        sec.editHeading = true;
        sec.label = 'Custom fields';
        sec.style = metadata.LayoutSectionStyle.OneColumn;

        Metadata.LayoutColumn col1 = new Metadata.LayoutColumn();

        Metadata.LayoutItem layoutField = new Metadata.LayoutItem();

        layoutField.field = 'testfield__c';
        layoutField.behavior = metadata.UiBehavior.Readonly;

        col1.layoutItems.add(layoutField);
        sec.layoutColumns.add(col1);

        la.layoutSections.add(sec);

        Metadata.DeployContainer dc = new Metadata.DeployContainer();
        dc.addMetadata(la);

        Id jobid = Metadata.Operations.enqueueDeployment(dc,null);
    }

    public static Metadata.Layout getLayout(String layoutName){
        List<String> layoutList = new List<String>{layoutName};
            List<Metadata.Metadata> components = Metadata.Operations.retrieve(Metadata.MetadataType.Layout, layoutList);
        return (Metadata.Layout)components[0];
    }
}


Above code will add testfield__c field to Account standard layout. But it shows as Readonly in Layout editor. But in Account both view and edit modes it's read-write.

On Layout editor:
In Layout editor

On View/Edit mode:
Edit/View Mode

It's actually editable and saving data to Account object here. Feel free to try out above code snippet. Appreciate any fix/workaround for this. Thanks.

 
Hi,
There is a flow i want to delete which have many paused and Waiting Interviews. (this flow run whenever an Event is created or updated)
I created a flow to delete all paused and Waiting Interviews but after deleting all interviews i cannot find the flow in the menu - not under flows sections and not under Paused and Waiting Interviews.

Is there anything i miss?

Any help would be very appreciated!

Thanks,
Tal
Apex class:
public class SkipMilestone
{
     //wrapper objwrapper;
     
     //System.debug('paramValue:'+paramValue);
          public List<wrapper> lst{get;set;}
     //List<wrapper> lstwrapper=new List<wrapper>();
         // public integer rowIndex{get;set;}
          public Program_Member_MVN__c Pm;
          public SkipMilestone(ApexPages.StandardController controller){
          Pm = (Program_Member_MVN__c)controller.getRecord();
          lst = new list<wrapper>();
          //Program_Stage_MVN__c Ps=[select Is_Parent_Stage_MVN__c from Program_Stage_MVN__c  where Program_Member__c=:Pm.id];
          //Program_Member_Stage_MVN__c Pm=[select Program_Stage_Name_MVN__c,(select id,Parent_Stage_MVN__c from Program_Member_Stages__r) from Program_Member_Stage_MVN__c where Program_Member_MVN__c=:Pm.id];
          //for(Program_Member_Stage_MVN__c exclude:Program_Member_Stages__r){
          List<Program_Member_Stage_MVN__c>Pms =[select id,Name,Parent_Program_Member_Stage_MVN__c,Program_Stage_MVN__c,Status_MVN__c,Program_Stage_Name_MVN__c,Stage_Sequence_Number_MVN__c,Activity_Sequence_Number_CTS__c,Parent_Program_Stage__c from Program_Member_Stage_MVN__c  where Program_Member_MVN__c=:Pm.id and Status_MVN__c='Not Started' and Parent_Stage__c !='Parent_Stage_MVN' order by Stage_Number__c desc]; 
             for(integer i=0;i<Pms.size();i++)
            {
                  wrapper objwrapper=new wrapper();
                  objwrapper.Pmm =Pms[i];
                  //objwrapper.selected = false;
       //objwrapper.rowNo = lst.size();
                  lst.add(objwrapper);
             }
  }
          public Id paramValue{get;set;}
          public PageReference savemethid(){
          System.debug('paramValue:'+paramValue);
          //wrapper objProgramWrapper = new wrapper();
          //objProgramWrapper.Pmm.Id = this.paramValue;
         // string Value= System.currentPageReference().getParameters().get('paramValue');
          //Program_Member_Stage_MVN__c IdGet= new Program_Member_Stage_MVN__c();
          //IdGet.id=this.paramValue; 
          
          List<Program_Member_Stage_MVN__c> Ref2=new List<Program_Member_Stage_MVN__c>();
          Program_Member_Stage_MVN__c StageSequence=[select Activity_Sequence_Number_CTS__c from Program_Member_Stage_MVN__c where id =: paramValue];
          System.debug('StageSequence:'+StageSequence);
          //Program_Stage_MVN__c StageSequence1=[select 
          //Map<id,Program_Member_Stage_MVN__c>ParentStage=new Map<id,Program_Member_Stage_MVN__c>([select Parent_Program_Member_Stage_MVN__c from Program_Member_Stage_MVN__c where id=:paramValue]);
          List<Program_Member_Stage_MVN__c> ParentStage=new List<Program_Member_Stage_MVN__c>([select Parent_Program_Member_Stage_MVN__c from Program_Member_Stage_MVN__c where id=:paramValue]);
          Map<string,Program_Member_Stage_MVN__c>ProgramMemberIds = new Map<string,Program_Member_Stage_MVN__c>();
          for(Program_Member_Stage_MVN__c a: ParentStage)
          ProgramMemberIds.put(a.Parent_Program_Member_Stage_MVN__c ,a);
          Set<string> ProgramMemberIds1=ProgramMemberIds.keyset();
           system.debug('ProgramMemberIds1:'+ProgramMemberIds1);
           
            for(Program_Member_Stage_MVN__c ChildStages:[select Name,Stage_Number__c,(select id,name,Status_MVN__c,Stage_Sequence_Number_MVN__c,Program_Stage_MVN__c,Activity_Sequence_Number_CTS__c from Program_Member_Stages__r) from Program_Member_Stage_MVN__c where id=:ProgramMemberIds1]){
          List<Program_Member_Stage_MVN__c>ProgramStage=new List<Program_Member_Stage_MVN__c>([select Program_Stage_MVN__c from Program_Member_Stage_MVN__c where id=:paramValue]);
          Map<string,Program_Member_Stage_MVN__c>ProgramIds = new Map<string,Program_Member_Stage_MVN__c>();
          for(Program_Member_Stage_MVN__c b: ProgramStage)
          ProgramIds.put(b.Program_Stage_MVN__c ,b);
          Set<String> ProgramIds1 = ProgramIds.keySet();
          system.debug('ProgramIds1 :'+ProgramIds1 );
          
          List<Program_Stage_MVN__c> ParentStage1 =new List<Program_Stage_MVN__c>([select Parent_Stage_MVN__c from Program_Stage_MVN__c where id=:ProgramIds1]); 
          Map<string,Program_Stage_MVN__c>ParentIds= new Map<string,Program_Stage_MVN__c>();
          for(Program_Stage_MVN__c c: ParentStage1 )
          ParentIds.put(c.Parent_Stage_MVN__c ,c);
          Set<string>ParentIds1=ParentIds.keySet();
          system.debug('ParentIds1:'+ParentIds1);
          
          for(Program_Stage_MVN__c childStages1:[select Name,(select id,Name,Stage_Sequence_Number_MVN__c,Activity_Sequence_Number_CTS__c from Child_Stages_MVN__r) from Program_Stage_MVN__c where id=:ParentIds1]){
          system.debug('ChildStages:'+ChildStages.Program_Member_Stages__r);
          system.debug('childStages1:'+childStages1);
          for(Program_Member_Stage_MVN__c ref : ChildStages.Program_Member_Stages__r){
          for(Program_Stage_MVN__c ref1 : childStages1.Child_Stages_MVN__r){
          List<Program_Member_Stage_MVN__c> Pstages=[select id,Stage_Number__c,Parent_Stage__c,Status_MVN__c from Program_Member_Stage_MVN__c where Program_Member_MVN__c=:Pm.id and Parent_Stage__c='Parent_Stage_MVN'];
          //for(Program_Member_Stage_MVN__c re1 : Pstages){
          for(Program_Member_Stage_MVN__c re1 : Pstages){
          system.debug('Pstages:'+Pstages);
          if(ref.Program_Stage_MVN__c == ref1.id && ref.Status_MVN__c!='Started' && ref.Activity_Sequence_Number_CTS__c==StageSequence.Activity_Sequence_Number_CTS__c){
          ref.Status_MVN__c='Started';
          }
          if(ref.Program_Stage_MVN__c == ref1.id && ref.Status_MVN__c!='Started' && ref.Activity_Sequence_Number_CTS__c<StageSequence.Activity_Sequence_Number_CTS__c) {
          ref.Status_MVN__c='Completed';
          }
          Ref2.add(ref);
          if(re1.Stage_Number__c<ChildStages.Stage_Number__c){
          re1.Status_MVN__c='Completed';
          }
          Ref2.add(re1);
          }
          }
          }
          }
          }
          set<Program_Member_Stage_MVN__c> dedupSet = new set<Program_Member_Stage_MVN__c>();
          dedupSet.addAll(Ref2);
          List<Program_Member_Stage_MVN__c> dedupList = new List<Program_Member_Stage_MVN__c>();
          dedupList.addAll(dedupSet);
          Update dedupList;
          //Update Ref2;
          //System.debug('Ref2:'+Ref2);
          pagereference ref3 = new pagereference('/apex/Final_Message');
          ref3.setredirect(true);
          return ref3;
     //integer i;
        // for(i=0;i<lst.size();i++){
        // if(lst[i].selected == true){
        // lst[i].Pmm.Status_MVN__c='Started';
       //  }
         //update lst[i].Pmm; 
        // 
        //  update lst[i].Pmm; 
        /* pagereference ref = new pagereference('/apex/Milestone_skip');
         ref.setredirect(true);
         return ref;*/
        }        

         public class wrapper{
         public Program_Member_Stage_MVN__c Pmm{get;set;}
         public string paramValue{get;set;}
        // public integer rowNo {get;set;}
    //public boolean isEdit{get;set;}
        // public Boolean selected {get;set;}
 }
}

I need help at this part:
Ref2.add(ref);
          if(re1.Stage_Number__c<ChildStages.Stage_Number__c){
          re1.Status_MVN__c='Completed';
          }
          Ref2.add(re1);
          }
          }
          }

is it the correct way of adding different lists into one list and updating sobject?