• Rohit B ☁
  • NEWBIE
  • 230 Points
  • Member since 2014
  • Senior Consultant


  • Chatter
    Feed
  • 7
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 76
    Replies
Hi all,
Can anyone help in writting the test class for the below extension class.

public class gdaControllerExtension {

    Public final GFrm__c gfrm;

    public gdaControllerExtension (ApexPages.StandardController stdController) {
        this.gfrm = (GFrm__c)stdController.getRecord();
    }

    
  public void mfarten()
  {

 
  if(gfrm.SelectProgram__c=='MA')
  {
      gfrm.Select_One_Art_Ed__c= null;
        
  }else if(gform.SelectProgram__c=='AED'){
 
      gfrm.SelectOne_MFA__c= null;

   
  }else if(gfrm.SelectProgram__c=='enroll'){
 
      gform.SelectOne_MFA__c= null;

 
  }
 
  }

}

Thanks in advace.

Regards,
mac.
I am trying to teach myself Apex, so I've come up with a project to create and am figuring it out step-by-stumbling-step. Here is the step I am stuck on.

Here is my goal: I want a page that shows you a list of records in a table. When you click the name of one of the records, the whole list disappears and you see a page showing information from that record.

Here's my code so far which is not working. It's a page which loads the two separate pages, and decides which one to render based on whether a certain variable (the selected record id) is null or not.

Controller:
public class testController {
    public id gameId{get; set;}
    
    public List<Game__c> getGames() {
    	List<Game__c> results = Database.query(
        	'SELECT id,name,owner.name,LastModifiedDate FROM game__c'
        );
        return results;
    }
}

Page 1:
<apex:page showheader="true" controller="testController">
    <apex:include pageName="listPage" rendered="{! ISNULL( gameId ) }"/>
    <apex:include pageName="detailPage" rendered="{! NOT( ISBLANK( gameId )) }"/>
</apex:page>
listPage:
<apex:page showHeader="false" controller="testController" id="display">

        <apex:form >
            <apex:pageblock >
                <apex:pageblocktable value="{! games}" var="g">                   
                    
                    <apex:column headerValue="Name">
                        <apex:commandLink value="{!g.Name}" rerender="display" >
                            <apex:param assignTo="{!gameId}" name="{!g.Id}" value="{!g.Id}"/>
                        </apex:commandLink>
                    </apex:column>

                </apex:pageblocktable>
           </apex:pageblock>
       </apex:form>
</apex:page>

detailPage:
<apex:page showHeader="false" controller="testController">    
    <apex:outputtext value="test" />
</apex:page>
Expected behavior: I click the the name of the any of the Game records in the list on the listPage and the whole list disappears and is replaced with a blank white screen and the word "test".
Actual results: Clicking the name does nothing.

Am I on the right track trying to do this with three separate pages? Or should this all be handled in one visualforce page?
My question is to Create a trigger on User to update group membership of user based on user profile and custom setting. Create  Custom settings which will store the mapping of the groups to Profiles.On Insert/Update of  User, trigger will recalculate the group membership of the user based on the mapping stored in custom settings. i Have done for insert part but for Update there are too many possibilities that can happen. So please if anyone knows answer help me.
trigger GroupMembership on User (after update,after insert) {

    list<custom_setting__c> setting = custom_setting__c.getAll().values();
    list <GroupMember> GrpMem = new list<groupMember>();
    list<GroupMember> Grp = [select id,UserOrGroupId,GroupId from GroupMember];
   
    for(User usr : trigger.new)
    { 
        if(trigger.isInsert)
        {
            for(Custom_setting__c custom : setting)
            {    Id cusId = (Id)custom.Profile_Id__c;
                if(cusId == usr.ProfileId)
                {
                    GroupMember GM = new GroupMember();
                    GM.GroupId = (Id)custom.Group_id__c;
                    GM.UserOrGroupId = usr.Id;
                    GrpMem.add(GM);
                }
            }
       
        } 
    } 
insert GrpMem;
}
This is my code when adding new user. Help me with Update code.

We created a process that updates the expiration date field of an insurance policy via process builder. It works great except for polcies with an effective date in June. It is adding an extra year to the expiration date. 
So if a six month policy effective date is 06/01/2016 it is saying the expiration date is 12/01/2017 instead of 12/01/2016. 

Seems like it works perfect for all other dates and months except for June. The formula is below. If anyone could take a look at it I would grealty apprciate it.  I am sure it is just a minor error.   Thanks! 

DATE(
year([Policy__c].Effective_Date__c)
+ floor((month([Policy__c].Effective_Date__c) + 6)/12) + if(and(month([Policy__c].Effective_Date__c)=12,6>=12),-1,0)
,
if( mod( month([Policy__c].Effective_Date__c) + 6, 12 ) = 0, 12 , mod( month([Policy__c].Effective_Date__c) + 6, 12 ))
,
min(
day([Policy__c].Effective_Date__c),
case(
max( mod( month([Policy__c].Effective_Date__c) + 6, 12 ) , 1),
9,30,
4,30,
6,30,
11,30,
2,if(mod((year([Policy__c].Effective_Date__c)
+ floor((month([Policy__c].Effective_Date__c) + 6)/12) + if(and(month([Policy__c].Effective_Date__c)=12,6>=12),-1,0)),4)=0,29,28),
31
)
)
)
I have a custom javascript button on the Opportunity object that when clicked should icnrease the value of a numerical field by '1' but instead it's simply adding '1' to the existing value. So if the number in the field is currently '1' then clicking the button changes it to '11' and clicking again changes it to '111' and so on... it's as if it is simply appending a '1' to the end of the numerical string.

Here is my code to update the counter field 'VelocifyResync':
 
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")} 

var opp = new sforce.SObject("Opportunity");
opp.Id = '{!Opportunity.Id}';
var VelocifyResync = '{!Opportunity.Velocify_Resync__c}';

// assign values to fields on opportunity object

opp.Velocify_Resync__c = VelocifyResync + 1;

//save the change
var result = sforce.connection.update([opp]);

if(result[0].getBoolean("success")) { 
window.location.reload();;
} else { 
alert('Error : '+result);
}
Appreciate any help here! 
  • February 21, 2017
  • Like
  • 0

A. Account and Group

B. Account and AccountShare

C. Case and CaseComment

D. Oppotunity and User

I'm confused after I see https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_non_mix_sobjects.htm article. 

Hi All,
I'm in the console and when I click on logout button "sforce.console.ConsoleEvent.CONSOLE_LOGOUT" this event occurs and I can perform my functionality over this event but if my session gets timeout and logout happens automatically by salesforce then this event doesn't occur. I want to perform the same functionality at the time of logout by session expire as well.
Hope I made my requirement clear. If you have any doubt, please respond.
Your help is much appreciated.

Thanks in advance. 
Hello Community,
I was thinking about this and screwed my mind but didn't get the appropriate answer. Can anyone help me in understanding this?
I would like to know the best or appropriate use case where we need to query list type of custom setting rather than provided getValues() function.

Thanks in advance..
Hi All,
I was doing some poc for my work and I encountered with a weird problem. On the selection of radio button value I want to rerender the output panel below (based upon the selected radio button value) but it is not functioning well.
I know I'm doing some silly mistake but not able to recognize. Here is my code :-

VF Page
------------------------------------------------------------------------
<apex:page Controller="TestPage_Class">
    <apex:form >
        <apex:selectRadio id="selectedContact" value="{!selectedValue}">
             <apex:selectOptions value="{!listSelectedContact}"/>                                        
             <apex:actionSupport event="onchange" reRender=" outerOutputP1, outerOutputP2" status="status" action="{!selectOnClick}"/>
        </apex:selectRadio> 
        
        <apex:actionstatus id="status">
            <apex:facet name="start">
                <div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb;
                       height: 100%;opacity:0.65;width:100%;"> 
                    <div class="waitingHolder" style="top: 74.2px; width: 91px;">
                        <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                        <span class="waitingDescription">Please Wait...</span>
                    </div>
                </div>
            </apex:facet>
        </apex:actionstatus>
    
        <apex:outputPanel id="outerOutputP1">
            <apex:outputPanel id="innerOutputP1" rendered="{!op1}">
                <apex:outputLabel > Output Panel 1</apex:outputLabel>
            </apex:outputPanel>
        </apex:outputPanel>
        
        <apex:outputPanel id="outerOutputP2">
            <apex:outputPanel id="innerOutputP2" rendered="{!op2}">
                <apex:outputLabel > Output Panel 2</apex:outputLabel>
            </apex:outputPanel>
        </apex:outputPanel>
    </apex:form>
</apex:page>



Controller Class :-
------------------------------------------------------------------------------------------
public class TestPage_Class {
    public String selectedValue {get; set;}
    public Boolean op1 {get; set;}
    public Boolean op2 {get; set;}
    
    public List<SelectOption> getlistSelectedContact() {
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('Value1','Output Panel 1')); 
        options.add(new SelectOption('Value1','Output Panel 2')); 
        return options; 
    }
    
    public PageReference selectOnClick() {
        if(selectedValue=='Value1') {
            op1 = true;
            op2 = false;
        } else {
            op1 = false;
            op2 = true;
        }
        return null;
    }
}


Please try to understand this code and provide me a solution.

Thanks in advance.
I'm having a custom button on a custom object. On the click of this button I want to open a new record creation page of another custom object and I want to pre-populate some fields. To populate these fields I need to pass the field id (layout one) and the value which I want to populate. I've the value and it is passing correctly but field id that I need to pass in the URL is in Custom Setting.
I'm not able to utilize the custom setting directly in the URL creation of this custom button. Is there any direct approach to do this through custom setting or I've to switch to JS for this?

Any thoughts?

Thanks in advance!
I want to configue (insert/edit/delete) list views for some objects like account, case, contact, etc. for each and every user we are ceating in the salesforce. Some list views will be generic for all and some for dedicated to that specific user. They are normal salesforce users not portal or customer user. 

How can we achieve this functionality? Any thoughts?

Thanks in advance.
Hi All,
I'm in the console and when I click on logout button "sforce.console.ConsoleEvent.CONSOLE_LOGOUT" this event occurs and I can perform my functionality over this event but if my session gets timeout and logout happens automatically by salesforce then this event doesn't occur. I want to perform the same functionality at the time of logout by session expire as well.
Hope I made my requirement clear. If you have any doubt, please respond.
Your help is much appreciated.

Thanks in advance. 
I have two fields RegFrom__c and RegUntil__c.

I would like to calculate how many calendar years there are between 2 dates WHERE:

CertRegFrom__c= 01-06-2018
CertRegUntil__c = 02-06-2023

This is a period of 5 years, but 6 calendar years, so result of the formula should be 6, the formula below returns 5. 

between the dates above you have the following calendar years 2018, 2019, 2020, 2021, 2022, 2023.

If CertRegFrom = 01-01-2018 AND CertRegUntil = 31-01-2022 then the formula must equal = 5
 
(CertRegUntil__c - CertRegFrom__c) /365

Can anyone help me adapt this formula?

Dave
Hi, 
I have a custom JIT handler that will create a user record in SF when the user tries to log in using SSO. My requirement is to update the inactive user to active when the user logs in. I tried doing it but it's not working as the user is inactive. It says "unable to verify identity" in the portal and "user is inactive" in login history status. It's obvious that the user can't log in as the status is inactive. But any idea how can I implement this? 
I created Force.com project in Eclipse to connect to Sandbox, I want to downloadd all components from sandbox
but the src folder contains only classes, pages and triggers.

Please let me know why other components like flows, workflows, objects, profiles... are not downloaded, I did not have the option to select any component from sandbox when I created the project

Thanks
Hi Experts,  

  I want to build a logic inside trigger it must fire when sycn button is clicked on quote please suggest me how to apply this logic inside the trigger. 

Thanks
Sudhir
  • March 14, 2017
  • Like
  • 0
Hi all,
Can anyone help in writting the test class for the below extension class.

public class gdaControllerExtension {

    Public final GFrm__c gfrm;

    public gdaControllerExtension (ApexPages.StandardController stdController) {
        this.gfrm = (GFrm__c)stdController.getRecord();
    }

    
  public void mfarten()
  {

 
  if(gfrm.SelectProgram__c=='MA')
  {
      gfrm.Select_One_Art_Ed__c= null;
        
  }else if(gform.SelectProgram__c=='AED'){
 
      gfrm.SelectOne_MFA__c= null;

   
  }else if(gfrm.SelectProgram__c=='enroll'){
 
      gform.SelectOne_MFA__c= null;

 
  }
 
  }

}

Thanks in advace.

Regards,
mac.
Hi,

I need help on the following req

1) I am having an opportunity record which is getting created automatically from case object
2) I am having another button where i am trying to create a new proposal object record auomatically from opportunity which is master object through a button click on opporunity

I have written a javascript on button click , but its not working

Below is my code
 
MY JAVASCRIPT CODE


{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')} 

var newproposal = new sforce.SObject('Proposal__c'); 
newproposal.Opportunity__c ='{!Opportunity.Id}'; 
newproposal.Account__c	= '{!Case.AccountId}'; 
newproposal.Name = '{!Opportunity.Name}'; 
newproposal.Status__c= 'ENG approved'; 
newproposal.Proposal_Start_Date__c = new Date(); 
newproposal.Proposal_End_Date__c = new Date(); 
newproposal.RecordTypeId='012O0000000DE3V'; 


var result = sforce.connection.create([newproposal]); 

if(result[0].success=='true'){ 
alert('The Proposal record has been Created Successfully.'); 
window.location = '/' + result[0].id; 
}
 Kindly help me on this pls

Thanks in Advance
 
hi all
       this is the custom setting object in my class
   1) FrCCC_SearchDisplaySettings__c srchDispCS = FrCCC_SearchDisplaySettings__c.getValues('Account');
and if condition in the class is
 if(srchDispCS != null && srchDispCS.FrCCC_FieldNames__c != null){query = 'SELECT '+srchDispCS.FrCCC_FieldNames__c;}

how to give values to srchDispCS,srchDispCS.FrCCC_FieldNames__c in test class so if condition becomes true
2)public boolean isSalesRepMSEAccess =false;     
  public boolean isSalesRepMMFAccess =false;
 public boolean getIsSalesRepMMFAccess(){         return Schema.sObjectType.Account.fields.FrCCC_MMF_TerritoryName_KAM__c.isAccessible();     }
if(salesRep != null && !salesRep.trim().equalsignorecase(blankStr) && isSalesRepMSEAccess){                 query += salesRepMSEVar+' like \'%'+salesRep +'%\' and ';                 flag= true;}
this is the method and if conition in my original class
how to supply values for isSalesRepMSEAccess in my test class so if condition evaluates to true
 
APEX CLASS:

public class fetch1 {
    public list<account> acc{set;get;}
    public map<string,list<contact>> mp{set;get;}
    public fetch1(){
        acc=[select name,(select lastname,firstname from contacts) from account ];
        list<contact> con=new list<contact>();
        mp=new map<string,list<contact>>();
        for(account a:acc){
            for(contact c:a.contacts){
                con.add(c);
                 }
            mp.put(a.name,con);
        }
        }
        }

VF:

<apex:page controller="fetch1" >
    <apex:form >
    <apex:pageBlock >
       <apex:pageBlockTable value="{!acc}" var="a">
        <apex:column headerValue="ACCOUNTS" value="{!a.name}"/>
           <apex:column headerValue="RELATED CONTACTS" >
               <apex:pageBlockTable value="{!mp}" var="cont">
               <apex:column value="{!mp[cont].firstname}"/>
                   <apex:column value="{!mp[cont].lastname}"/>
               </apex:pageBlockTable>
           </apex:column>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

ERROR:
There are no errors in code.But when i am going for a preview of vf page i am getting this error "Incorrect parameter type for subscript. Expected Number, received Text "

 
Hi

I created a visualforce page but I am unable to create new global action using this visualforce page.
I am not able to find what went wrong!! Please help me in this.

Thanks in advance!!

I am not able to create new global action using custom visualforce page
Hi All,

I am doing some VF development. I am about able to launch the vf page using "Show in salesforce web" option. can anyone please suggest me if need to do some changes in the eclipse configuration
Hi, all - We had an outside firm code some custom Apex in our Salesforce instance. I need to add to that code so some new fields I've created are included in its functionality. I found the code, and I'm 99% sure I can edit it myself, but there's no Edit button. We have enterprise accounts - no sandbox, etc. Do I need an outside developer just to unlock the Apex? Thanks.
When I have made a field not editable within Visualforce.  I have a process builder that needs to update to update the field.  

When the field is able to be updated then the Process Builder works with no issues.