• ethan hunt
  • NEWBIE
  • 10 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 61
    Questions
  • 26
    Replies
I am trying this below code to view all the attachments in a single window as pdf, but i am unable to do it. Here i am using iframe.But it is not showing in a single
Is there any solution or workaround where i am view all the attachments in a single window as pdf.
 
public class AttachmentClass{
public string attachmentid {get; set;}
    public List<Attachment> atch {get; set;}
public AttachmentClass(){
    atch = new List<Attachment>();

    atch = [select Id from Attachment];
    For(Attachment a:atch){

       attachmentid=a.Id; 
    }
  //attachmentid='00P9000001HdVtc';
}
}
 
<apex:repeat value="{!atch}" var="a">
    <iframe src="{!URLFOR($Action.Attachment.Download, a.Id)}"/>
</apex:page>

 
Hi All,

Kindly help me . How can I update or delete a static resource Image file using Javascript.

Regards
Hi All,

I need to retrieve children accounts assciated to an account upto 6 level of hierarchy. Could you please help me in achieveing this.

Regards

Hi All,

I am getting XSS potential violation in the below line - 

var str = '{!XYZ_act_plan__C.key_geographies__c}';

The above code is an input for google map api and it is used in standard object Account.

Kindly help how to avoid it.

Regards
Hi All,

I am getting remote file inclusion error in the below line. Can this be optimized ...

<apex:pageBlock >
        <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Thanks
Hi All,

I need a help on this . In apex test class , if will denote it to seealldata=true code analyzer throws a viaolation of exposed test data.

Is there any harm, or impacts performace for the above.

Regards
Hi all,

I need a salesforce t-shirt. Can anyone help me in getting one.

Regards

Hi All,

Could you please help me in resloving the below warning broken null check error --

if(trigger.isDelete) {
            for(Opportunity opp: trigger.old) {
          /////////broken null check      if((opp.ExpectedRevenue != null || opp.ExpectedRevenue != 0.0) && (opp.RecordTypeId == Label.Opportunity_Low_RecordType_ID
                    || opp.RecordTypeId == Label.Opportunity_Lower_Record_Type_Id) &&
                      opp.Opportunity_Hierarchy_Link__c != null) {
                    mapOldSubOpportunity.put(opp.id, trigger.oldMap.get(opp.id));
                }

 

Regards

Hi All,

The question might sound silly. Its a generic question that I want to ask.

If I instatiate a object for Ex - Employee emp = new Employee(); multiple times with the same instance variable name emp in different method, wht will be the impact.

Will it be on Heap Size or Performance.

Regards
Hi All,


Is retunring null in catch block best practice.......

public List<Sobject> getSharedRecordsOfSObject(String query, Set<Id> setSObjectId) {
              
        List<sObject> listShareResult = new List<sObject>();       
        try {
            if(query != null) {
                listShareResult = Database.query(query);
            }
        return listShareResult;
        }
        catch(QueryException ex) {
            system.debug(ex);
            return null;
        }
    }


Regards
Hi All,

Could you please let me know which are the best practice to check null in List, Map, Set to avoid nullpointer exception....

Regards
Is returning null in catch block is best practice..

String strOpportunityRecord;
        Opportunity sourceOpportunityRecord = new Opportunity();
        try {
            strOpportunityRecord =  'SELECT ' + Queriablefields +'Name From Opportunity where id =: sourceOpportunityId';
            if (strOpportunityRecord != null) {
                sourceOpportunityRecord = Database.query(strOpportunityRecord) ;
            }
           return sourceOpportunityRecord;
        }
        catch(QueryException ex) {
            system.debug(ex);
            return null;
        }
    }
Hi All,

Can the below test class be optimized 

if I am having a class
---------------------------------------------------------
public class TVRemoteControl {
    // Volume to be modified
    Integer volume;
    // Constant for maximum volume value
    static final Integer MAX_VOLUME = 50;  
  
    // Constructor
    public TVRemoteControl(Integer v) {
        // Set initial value for volume
        volume = v;
    }
      
    public Integer increaseVolume(Integer amount) {
        volume += amount;
        if (volume > MAX_VOLUME) {
            volume = MAX_VOLUME;
        }
        return volume;
    }
  
    public Integer decreaseVolume(Integer amount) {
        volume -= amount;
        if (volume < 0) {
            volume = 0;
        }
        return volume;
    }  
  
    public static String getMenuOptions() {
        return 'AUDIO SETTINGS - VIDEO SETTINGS';
    }
     
}
--------------------------------------------------------------
When I will write the test case -

@isTest
class TVRemoteControlTest {
    @isTest static void testVolumeIncrease() {
        TVRemoteControl rc = new TVRemoteControl(10);
        Integer newVolume = rc.increaseVolume(15);
        System.assertEquals(25, newVolume);
    }
  
    @isTest static void testVolumeDecrease() {
        TVRemoteControl rc = new TVRemoteControl(20);
        Integer newVolume = rc.decreaseVolume(15);
        System.assertEquals(5, newVolume);      
    }
      
    @isTest static void testVolumeIncreaseOverMax() {
        TVRemoteControl rc = new TVRemoteControl(10);
        Integer newVolume = rc.increaseVolume(100);
        System.assertEquals(50, newVolume);      
    }
  
    @isTest static void testVolumeDecreaseUnderMin() {
        TVRemoteControl rc = new TVRemoteControl(10);
        Integer newVolume = rc.decreaseVolume(100);
        System.assertEquals(0, newVolume);      
    }
  
    @isTest static void testGetMenuOptions() {
        // Static method call. No need to create a class instance.
        String menu = TVRemoteControl.getMenuOptions();
        System.assertNotEquals(null, menu);
        System.assertNotEquals('', menu);
    }
}
--------------------------------------------
Can TVRemoteControl rc = new TVRemoteControl be initialised once and can be reused.

Regards
Hi All,

I have a class called class1, which has 4 method called as method1, mthod2, method3, method4.
When i write a test class for Class1 , should i be instiating Class1,  4 times in 4 test methods.

or

I can instantiate class1 only once.
Hi All,

Can we return empty collection in Apex as we do in Java using Collection.emptylist().

Regards
Hi ,

I needed a query which can retrieve users names which has no roles assigned to it.

Please help..


Regards”
Hi,

Can anybody let me know what is parameter tampering in salesforce and how it can be prevented.

Regards
Hi All,

Could you please me in getting any article regarding memory management in Apex.

Regards
Hi All,

By using system.debug in catch block reduces the performance of system. Is using system.debug is best practice in try catch while doing dml operations


Kindly help

Regards

Hi ,

I needed a query which can retrieve profile names which has no user assigned to it.

Please help..


Regards
Hi All,

Kindly help me . How can I update or delete a static resource Image file using Javascript.

Regards
Hi All,

I am getting XSS potential violation in the below line - 

var str = '{!XYZ_act_plan__C.key_geographies__c}';

The above code is an input for google map api and it is used in standard object Account.

Kindly help how to avoid it.

Regards
Hi All,

I need a help on this . In apex test class , if will denote it to seealldata=true code analyzer throws a viaolation of exposed test data.

Is there any harm, or impacts performace for the above.

Regards
Hi All,

Can we return empty collection in Apex as we do in Java using Collection.emptylist().

Regards
Is returning null in catch block is best practice..

String strOpportunityRecord;
        Opportunity sourceOpportunityRecord = new Opportunity();
        try {
            strOpportunityRecord =  'SELECT ' + Queriablefields +'Name From Opportunity where id =: sourceOpportunityId';
            if (strOpportunityRecord != null) {
                sourceOpportunityRecord = Database.query(strOpportunityRecord) ;
            }
           return sourceOpportunityRecord;
        }
        catch(QueryException ex) {
            system.debug(ex);
            return null;
        }
    }
Hi All,

Can the below test class be optimized 

if I am having a class
---------------------------------------------------------
public class TVRemoteControl {
    // Volume to be modified
    Integer volume;
    // Constant for maximum volume value
    static final Integer MAX_VOLUME = 50;  
  
    // Constructor
    public TVRemoteControl(Integer v) {
        // Set initial value for volume
        volume = v;
    }
      
    public Integer increaseVolume(Integer amount) {
        volume += amount;
        if (volume > MAX_VOLUME) {
            volume = MAX_VOLUME;
        }
        return volume;
    }
  
    public Integer decreaseVolume(Integer amount) {
        volume -= amount;
        if (volume < 0) {
            volume = 0;
        }
        return volume;
    }  
  
    public static String getMenuOptions() {
        return 'AUDIO SETTINGS - VIDEO SETTINGS';
    }
     
}
--------------------------------------------------------------
When I will write the test case -

@isTest
class TVRemoteControlTest {
    @isTest static void testVolumeIncrease() {
        TVRemoteControl rc = new TVRemoteControl(10);
        Integer newVolume = rc.increaseVolume(15);
        System.assertEquals(25, newVolume);
    }
  
    @isTest static void testVolumeDecrease() {
        TVRemoteControl rc = new TVRemoteControl(20);
        Integer newVolume = rc.decreaseVolume(15);
        System.assertEquals(5, newVolume);      
    }
      
    @isTest static void testVolumeIncreaseOverMax() {
        TVRemoteControl rc = new TVRemoteControl(10);
        Integer newVolume = rc.increaseVolume(100);
        System.assertEquals(50, newVolume);      
    }
  
    @isTest static void testVolumeDecreaseUnderMin() {
        TVRemoteControl rc = new TVRemoteControl(10);
        Integer newVolume = rc.decreaseVolume(100);
        System.assertEquals(0, newVolume);      
    }
  
    @isTest static void testGetMenuOptions() {
        // Static method call. No need to create a class instance.
        String menu = TVRemoteControl.getMenuOptions();
        System.assertNotEquals(null, menu);
        System.assertNotEquals('', menu);
    }
}
--------------------------------------------
Can TVRemoteControl rc = new TVRemoteControl be initialised once and can be reused.

Regards
Hi All,

I have a class called class1, which has 4 method called as method1, mthod2, method3, method4.
When i write a test class for Class1 , should i be instiating Class1,  4 times in 4 test methods.

or

I can instantiate class1 only once.
Hi ,

I needed a query which can retrieve users names which has no roles assigned to it.

Please help..


Regards”

Hi ,

I am getting Avoid instantiating new objects inside loops in the below line. Can this be avoided.Please suggext

Map<Id, Opportunity> mapOpportunityOwnerId;
            List<OpportunityTeamMember> listOpportunityTeamMember;
            if(setOpportunityId != null) {
                // get the map of Opportunity Id and it's corresponding owner Id
                mapOpportunityOwnerId = queryDMLHelper.getOpportunity(setOpportunityId);    
                // get the list of Opportunity team members for a set of Opportunities     
                listOpportunityTeamMember = queryDMLHelper.getListOpportunityTeam(setOpportunityId);
            }
            Map<Id, Set<Id>> mapOpportunitySalesTeamId = new Map<Id, Set<Id>>();       
            if(listOpportunityTeamMember != null) {
            for(OpportunityTeamMember salesTeamMember : listOpportunityTeamMember) {
                setSalesTeamId = new Set<Id>(); ///////////////////////////////////Avoid instantiating new objects inside loops
                if(mapOpportunitySalesTeamId.get((Id)salesTeamMember.get('OpportunityId'))== null) {           
                    setSalesTeamId.add((Id)salesTeamMember.get('UserId'));
                    mapOpportunitySalesTeamId.put((Id)salesTeamMember.get('OpportunityId'), setSalesTeamId);
                }
                else {
                    mapOpportunitySalesTeamId.get((Id)salesTeamMember.get('OpportunityId')).add((Id)salesTeamMember.get('UserId'));
                }
            }
            }
Hi,

Can the below code be optimised. I need the query to filter all the not null id's , so that i can remove the variable strOpportunityRecord.

public Opportunity getOpportunityRecord(String Queriablefields, id sourceOpportunityId) {       
        String strOpportunityRecord;
        Opportunity sourceOpportunityRecord = new Opportunity();
        try {
            strOpportunityRecord =  'SELECT ' + Queriablefields +'Name From Opportunity where id =: sourceOpportunityId';
            if (strOpportunityRecord != null) {
                sourceOpportunityRecord = Database.query(strOpportunityRecord) ;
            }
           return sourceOpportunityRecord;
        }
        catch(QueryException ex) {
            system.debug(ex);
            return null;
        }
    }

Regards
Hi,

I have two text field A & B and one checkbox. I want when i click the check box address from A will get copy to B before saving.
Could you please suggest what should i do. Weather a trigger, Workflow or formula field.

Regards

Hi,

 

I have a visualforce page where i have a from date and to date field and a picklist which has all objects. There is a command button.

 

We have to select from date and to date and select a object from picklist and when pressed, it will display all the records in that object.

 

Need Help

----

<apex:page controller="objectLists">
   <apex:form >
    From Date :<input type="date" name="frmday" id="fday"/>
    To Date :<input type="date" name="today" id ="tday"/>
    <apex:SelectList value="{!val}" size="1">
       <apex:selectOptions value="{!Name}" id="list"></apex:selectOptions>
     </apex:SelectList>
     <apex:commandButton value="Display" action="{!display}"/>
   
   </apex:form>
   <apex:pageBlock ></apex:pageBlock>
 </apex:page>

 

---controller --

public class objectLists{
String searchText;
  List<Lead> results;
  public String val {get;set;}
  public String objName { get; set; }
  List<Account>  lstaccount = new List<Account>();
  public List<SelectOption> getName()
 {
    List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();  
    List<SelectOption> options = new List<SelectOption>();
    for(Schema.SObjectType f : gd)
    {
     options.add(new SelectOption(f.getDescribe().getLabel(),f.getDescribe().getLabel()));
    }
    return options;
    }

Hi,

 

Please if anybody can help me in generating PPT from visualforce page with slides break.

 

Regards

Hi,

 

I have a custom list button on Opportunity object , I want when Stage field in Oppertunity changes to Prospecting the custom buuton wil get diabled and when it chnage to some other value the button will get enabled.

 

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.Opportunity)};
var status = "{!Opportunity.StageName}";
if(status=='Prospecting')
{
alert ('Completed');
}
else{
this.disabled = true;
}

 

Regards

Hi All,

 

Could you please help me in achieveing the following.

 

1. VF page has all account name with checkbox.

2. On checkbox click on VF page it should redirect to the account page detail of that record.

 

Regards.

Hi,

 

I have created a list view with column as Account Name . I want when i will click on any name it should ger redirect to that particular account details.

 

Please help.

Below is my VF code

 

<apex:page standardController="Account" recordSetVar="accounts" tabStyle="Opportunity" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:commandButton value="Edit" action="{!edit}"/>
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!accounts}" var="a">
<apex:column value="{!a.name}"/>
<apex:column headerValue="Type">
<apex:inputField value="{!a.type}"/>
</apex:column>
<apex:column headerValue="Account Site">
<apex:inputField value="{!a.site}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

Hi,

 

I am doing a simple add function using Javascript and actionfunction.Could you please help me achieveing this.I need to do this using both javascript and action function

 

My VF code - 

-----------------------

<apex:page controller="add">
<apex:form >
<apex:actionFunction name="doAdd" action="{!doAdd}" reRender="out">
<apex:param AssignTo="{!res}" value=""/>
</apex:actionFunction>
<apex:pageBlock >
<apex:inputText id="test" value="{!tex1}"/>
<apex:commandButton value="Click" onclick="doAd();return false"/>
</apex:pageBlock>

<apex:outputPanel id="out">
<apex:outputText value="{!res}">

</apex:outputText>
</apex:outputPanel>

<script>
function doAd()
{
var a = document.getElementById('{!$Component.tex1}').value
}
</script>
</apex:form>
</apex:page>

 

My Controller - 

-----------------------------------

public with sharing class add
{
public integer tex1{get;set;}
public decimal res{get;set;}
public boolean show { get; set; }

public add() {

show = false;
}
public PageReference doAdd() {
show = true;

res = (tex1+ 1);
return null;
}
}

 

Regards

Hi,

 

I have one inputtextbox and one outputtext. Initially both will show same value. But when i click the button my outputtext should show what i am passing in javascript which is not happening presently. Kindly help and let me know where i have mistaken.

 

My VF Code - 

------------------------

<apex:page controller="text">
<apex:form >
<apex:actionFunction name="myJSAction" action="{!myJSAction}" rerender="mypanel">
<apex:param name="firstparam" assignTo="{!myparam}" value="" />

</apex:actionFunction>

<apex:outputpanel id="mypanel">
<apex:inputText value="{!myparam}"/>
<apex:commandButton id="button" value="click" onclick="innerJavascript()"/> <br/>
<apex:outputText value="{!myparam}"></apex:outputText> <!-- <a href="javascript&colon;innerJavascript()">Invoke action here</a> -->
</apex:outputpanel>

<script>
function innerJavascript(){
alert('Start invoking vf action!');

myJSAction('Value is changed by action called by Javascript in Visualforce.');
}
</script>
</apex:form>
</apex:page>

 

 

My Controller ------

----------------------------------------

public class text{

public string myparam {get; set;}
public string myparam1 {get;set;}

public text(){
myparam = 'Initial value';

}

public PageReference myJSAction(){

return null;
}
}

 

Regards.

Hi,

 

I am trying to assingn the below mentioned javascript to my custom button on VF page. But i am getting syntax error messsage. Kindly help to resolve.

 

 

 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

IF(ISBLANK({!Recruiter__c.CompanyName__c}))
{
alert ("Company Name cannot be blank");
}
else{
window.open('https://c.ap1.visual.force.com/apex/sid19');
}