• Keerthana
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

Hi All,

Can you please help me if you have already come across the same scenario. I have a button on Contract page which has relationship with account and contact. I have tried restricting via standard look up filter but the issue in my vf page is I shouldnt display Account lookup and only contact lookup is displayed. If so there are no contacts that are available in standard look up. I have to place the Account look up as well to function. 

Thanks,
Priyanka.

Can anyone help me with the test class for below controller. I am trying to get the values of the vf page on save of a new record. standard controller will be null at that point but i need to access the values so I can save it.

public CA_SamsAccountController(ApexPages.StandardController std) {
      samsid = ApexPages.currentPage().getParameters().get('id');
       accid = ApexPages.currentPage().getParameters().get('AccountId');
       if(samsid!=null)
        cont =  (CA_SamsAccount__c)std.getRecord();  --- this line gives me error whenever I try to run the test class if i remove the above if condition
        }
        
        public PageReference save() { 
            string acctype = bc.getSamsAccountTypes();
            cont.CA_Sams_Account_Name__c = str;
            cont.CA_Account__c = acc.id;
            cont.CA_Account_name__c = accname;
            cont.CA_ApiLastName__c = '.api';
            cont.CA_Country__c = selectedCountry;
            cont.CA_contract__c = contractid;
            cont.CA_Parent_ID__c = selectedParent;
            cont.CA_MisPassword__c = temp1;
            cont.CA_ApiPassword__c = temp;
            cont.CA_AccountTypeId__c = acctype;
            con = [select lastname,firstname,phone,email from contact where id=: cont.CA_Contact__c limit 1];   --- I always have cont as null and hence not able to fetch contact
            cont.CA_First_Name__c = con.firstname;
            cont.CA_Last_Name__c = con.lastname;
            cont.CA_Telephone__c = con.phone;
            cont.CA_Email__c = con.email;
            insert cont;
        }
        
         public string getApiorgname()
    {
       string apiorgname = '';
       string api = cont.CA_Sams_Account_Name__c;  --- same issues goes here as well
       list<CA_SamsAccount__c> clist = [select CA_ApiFirstName__c from CA_SamsAccount__c where CA_ApiFirstName__c=: api];
       if(clist.size()>0)
           for(CA_SamsAccount__c c : clist)
                uniquename.add(c.CA_ApiFirstName__c);
       apiorgname = checkpattern(api);
       apiorgname = apiorgname + '.api';
       system.debug('api==='+ apiorgname);
       return apiorgname;
    }

Any quick work around is highly appreciated.
Thanks, Priya
Hi all,

I have a scenario where I have a custom multi picklist from custom object shown in vf page. It has 4 values, only when 4th value is picked a new field is shown via javascript and hidden when others are selected. Now the issue is the validation must be done from front end and I have used javascript and from there to action fucntion and then to controller. Till action function, the flow is as expected but when the controller is called, the values that needs to be inserted are not passed. Please find the code below. Work around is highly appreciated. Thanks.

Save button:

<div class="modal fade" id="addGTModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog model-lg">
                <apex:form styleClass="modal-content" id="theForm">
                    <apex:pageBlock id="pb">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <h4 class="modal-title" id="myModalLabel">Add GT</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="reason" class="col-sm-4 control-label">GT Prefix:</label>
                            <div class="col-sm-8"><apex:inputText value="{!newWhitelistEntry.GT_Start_Range__c}"/></div>
                        </div>                      
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="reason" class="col-sm-4 control-label">Select a GT Preference:</label>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <apex:selectList required="true" id="GtpreferenceId" style="width:170px;height:28px" multiselect="false" size="1" label="Type" value="{!selectedGTpreference}">
                                <apex:selectOptions value="{!GTPreference}"/>
                            </apex:selectList>
                        </div>                      
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="reason" class="col-sm-4 control-label">Source Network:</label>
                            <div class="col-sm-8"><apex:inputText value="{!newWhitelistEntry.Source_Network__c}"/></div>
                        </div>                      
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="reason" class="col-sm-4 control-label">Source Country:</label>
                            <div class="col-sm-8"><apex:inputText value="{!newWhitelistEntry.Source_Country__c}"/></div>
                        </div>                      
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="reason" class="col-sm-4 control-label">TP-OA Preference:</label>
                            <div class="col-sm-8"><apex:inputField id="tpsp" value="{!newWhitelistEntry.TP_OA__c}" onchange="isTPOASpvalue_0()" /></div>
                        </div>  
                    <div class="form-group" id= "specific" style="display:none">
                            <label for="reason" class="col-sm-4 control-label">Enter Specific Value </label>
                                <div class="col-sm-3">
                                    <apex:inputText id="check" value="{!TPspeficValue}" style="width:160px;height:28px"/>
                                </div>
                                <div class="col-sm-5 control-label" style="color:red">
                                    <span ID="errSpecific" class="bold-red"></span>
                                </div>
                        </div>  
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                        <input type="button" value="Save GT" onclick="isCheck('{!newWhitelistEntry}')" /><br /><br />        
                    </div>
                    </apex:pageBlock>
                </apex:form>
            </div>
        </div>
=================================================================

Javascript:


function isCheck(id) {
        alert('id==='+ id);
            if(document.getElementById("pg:theForm:pb:check").value == ''){
                alert('ischeck');
                document.getElementById("errSpecific").innerHTML="Enter specific value ";
                document.getElementById("pg:theForm:pb").focus();
                return false;
            }else{
                alert('in else');
                Addgtpopup('id');
            }
        }   

==================================================================


Action function:


 <apex:actionFunction name="Addgtpopup" action="{!AddGT}" rerender="addGTModal">
            <apex:param name="gtWhiteListId1" value="" assignTo="{!newWhitelistEntry}" />
  </apex:actionFunction>


===================================================================

Controller:
    public SmartHub_GTWhitelist__c newWhitelistEntry {get; set;}



 public void AddGT(){  
      system.debug('inside add gt===='+ newWhitelistEntry);
        if (newWhitelistEntry.Source_Country__c == '' || newWhitelistEntry.Source_Network__c == '' || (newWhitelistEntry.GT_Start_Range__c).trim() == '')
        {
          alert = 'Please make sure you provide a GT, country and network before adding to the whitelist';
          alertType = 'warning';
          return;
        }
        
        if((newWhitelistEntry.TP_OA__c).contains('TP-OA Specific Value')){
           if(!pattern.matches('^[a-zA-Z0-9]{2,12}$',TPspeficValue)){
                    alert = 'Please enter specific value length should be 2 to 12 Character, A–Z or a–z or 0-9';
                    alertType = 'warning';        
                    return;
              }
            }
        
        try {
        system.debug('inside try add gt====');
          newWhitelistEntry.Account__c = getUserAccountId();
          newWhitelistEntry.Description__c = TPspeficValue;
          insert newWhitelistEntry;
        }
Can anyone help me with the test class for below controller. I am trying to get the values of the vf page on save of a new record. standard controller will be null at that point but i need to access the values so I can save it.

public CA_SamsAccountController(ApexPages.StandardController std) {
      samsid = ApexPages.currentPage().getParameters().get('id');
       accid = ApexPages.currentPage().getParameters().get('AccountId');
       if(samsid!=null)
        cont =  (CA_SamsAccount__c)std.getRecord();  --- this line gives me error whenever I try to run the test class if i remove the above if condition
        }
        
        public PageReference save() { 
            string acctype = bc.getSamsAccountTypes();
            cont.CA_Sams_Account_Name__c = str;
            cont.CA_Account__c = acc.id;
            cont.CA_Account_name__c = accname;
            cont.CA_ApiLastName__c = '.api';
            cont.CA_Country__c = selectedCountry;
            cont.CA_contract__c = contractid;
            cont.CA_Parent_ID__c = selectedParent;
            cont.CA_MisPassword__c = temp1;
            cont.CA_ApiPassword__c = temp;
            cont.CA_AccountTypeId__c = acctype;
            con = [select lastname,firstname,phone,email from contact where id=: cont.CA_Contact__c limit 1];   --- I always have cont as null and hence not able to fetch contact
            cont.CA_First_Name__c = con.firstname;
            cont.CA_Last_Name__c = con.lastname;
            cont.CA_Telephone__c = con.phone;
            cont.CA_Email__c = con.email;
            insert cont;
        }
        
         public string getApiorgname()
    {
       string apiorgname = '';
       string api = cont.CA_Sams_Account_Name__c;  --- same issues goes here as well
       list<CA_SamsAccount__c> clist = [select CA_ApiFirstName__c from CA_SamsAccount__c where CA_ApiFirstName__c=: api];
       if(clist.size()>0)
           for(CA_SamsAccount__c c : clist)
                uniquename.add(c.CA_ApiFirstName__c);
       apiorgname = checkpattern(api);
       apiorgname = apiorgname + '.api';
       system.debug('api==='+ apiorgname);
       return apiorgname;
    }

Any quick work around is highly appreciated.
Thanks, Priya