• Abhishek Prasad 8
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 12
    Replies
HI Friends,
I am new to Apex. I am facing this challenege where i want to compare fields of two different lists. Here is the pseudo code:
 
Opportunity Opp = ([select, id, Site__C from Opportunity where id = Opp.id]); // Opp.id passed from the calling method

List<Contract__c> Contra= new List <Contract__c>([select, id, Site__c from Contract__c where Opportunity__c = Opp.id]);

List<Deal__c> Deals= new List <Contract>([select, id, Site__c from Deal__c where Opportunity__c = Opp.id]);

for(Contract__c Con:Contra){
       for(Deal__c D: Deals){
              if(Con.Site__c == D.Site){
                 
                        //PUT THE VALUE IN LIST FOR UPDATE

                      }
              else
                      {
                            //PUT THE VALUE IN LIST FOR INSERT
                          }

       }
}

Now, this code is not perfect. But i am using two for loops, which i want to avoid. What should be the best way to achieve this (comparing two list values)? If possible, please provide some code snippent.

Thanks in advance.
Hi Friends,
I am stuck at this for quite some time. the error is given below:

System.LimitException: Apex CPU time limit exceeded
Error is in expression '{!Process}' in component <apex:commandButton> in page quoteforaccounts: Class.QuoteUtilities.setMaInfor: line 21, column 1

Here is my method: 
Please help me out
public static void setMaInfor(Quote__c eq, list<Quote_Si__c> qsList, list<Quote_Pr__c> quoteTerms, list<KA_Mar_Elect__c> elecMargins, list<KA_Mar_Gas__c> gasMargins) {
        String type;
        String product;
        Decimal margin;
        Quote__c equote;
        Decimal count = 0;
        Decimal runner = 0;
        Decimal bestRunner = 0;
        Decimal currentMultiplier = 0;
        Boolean firstRun = true;
        Opportunity op;
    
        //Get list of all quote term prices that are selected
        
        List<Quote_Pr__c> qtpList = quoteTerms;
        //Get list of all KA Margin Electricity records
        List<KA_Mar_Elect__c> marElec = elecMargins;
	
	// newBEIndex
        firstRun = true;
	for(KA_Mar_Elect__c me : marElec){
                        if(firstRun){
                            bestRunner = math.abs(me.margin_mwh__c - newBEMargin);
                            currentMultiplier = me.index_new__c;
                            firstRun = false;
                        }else{
                            runner = math.abs(me.margin_mwh__c - newBEMargin);
                            if(runner < bestRunner){
                                bestRunner = runner;
                                currentMultiplier = me.index_new__c;
                            }
                        }
                    }

}

 
We have got one button, which, with the help of conga composer, opens an attachment. I am leveraging the functionality of that button to create another button. Here is my VF code:
<apex:commandButton value="Generate Doc" action="{!CallProc}"  onClick="openConga();return false;" rendered="{!if(valErr == true, false, true)}"/>
and here is my JS script:
 
<Script Language="JavaScript"> 
             function openConga() 
                { 
                    window.open('{!URLFOR($Action.Contract1__c.Conga_Composer_Main_Doc, Id)}', '','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes, toolbar=no,location=yes,status=yes'); 

                }

        </Script>

It is successfully invoking the COnga Composer, and its opening the window, but it throws the error:
The id parameter is missing
can anyone help me? what should i pass as the Id? i have tried object__c.Id, but it not identifying it.
 
Hi all,
I have a Java Script (Conga query which runs behind a button). I am asked to create a custom button, which will invoke the javascript (and open a conga template). I have created a custom button on the VF page and put the details over there. However, whenever any change happens in the JS, i need to change the VF as well (not desired). How should i achieve this. This is what i have tried till now:

Custom Settings: putting the JS code in Custome settings, and accessing it in Apex, and subsequently in VF custom button. I cant store the JS code in a custom setting field as my code is more than 255 characters (limitation of custom settings).

Static resource: i read on the net that this could be achieved by: (http://jevonearth.blogspot.ca/2011/08/using-static-resources-with-salesforce.html)
 
{!REQUIRESCRIPT('/resource/' & LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ',''),10) & '000/jbUtils')}

However, REQUIRESCRIPT cant be used for this purpose anymore (summer '16).

How should i proceed?
I am stuck with this if clause in my Test Clasuse. Can anybody help me. Here is my code example
public MethodName(ApexPages.StandardController Controller){

Newflag = false; //(variable Initialized as false)

if(Newflag )
{
// Do some stuff
}
//No else present or needed in this case.
}


When i am trying to pass this method by calling MethodName in my test class, 
and initializing the Newflag as true in the testclass, it not getting passed, as NewFlag is already initialized as false in the main class,
 and the testclass flag is getting overwritten by false. 

What should it do here

 
Hi,
i am working on field sets.
here is my VF code:
 
<apex:PageblockSection columns="2" >
             
                      <apex:repeat value="{!$ObjectType.Student__c.FieldSets.STU_FS2}" var="F2">
                      <apex:inputField value="{!Student__c[F2]}"/>
                      </apex:repeat>
              </apex:PageblockSection>  
              
              <apex:PageblockSection columns="2" >
             
                      <apex:repeat value="{!$ObjectType.Student__c.FieldSets.STU_FS3}" var="F3">
                      <apex:inputField value="{!Student__c[F3]}"/>
                      </apex:repeat>
              </apex:PageblockSection>

there are 3 field sets STU_FS1, STU_FS2 and STU_FS3. When they are shown on the VF page, the fields are coming as it is defined in the object. How can i give individual names to such field which are present in field sets STU_FS1,2,3. In short, i want to use something like label for the fields present in field sets.
Hi All,
I want to know that if we can restrict tab/view/Object in salesforce. 
I know we can restrict Viewable stuffs using a profile. But, my scenario is that, i have 100 users with profile A. out of that i want to restrict 10 users from viewing a single object...say Contact object. How can we achieve that?
Hi All,
I want to know that if we can restrict tab/view/Object in salesforce. 
I know we can restrict Viewable stuffs using a profile. But, my scenario is that, i have 100 users with profile A. out of that i want to restrict 10 users from viewing a single object...say Contact object. How can we achieve that?
HI Friends,
I am new to Apex. I am facing this challenege where i want to compare fields of two different lists. Here is the pseudo code:
 
Opportunity Opp = ([select, id, Site__C from Opportunity where id = Opp.id]); // Opp.id passed from the calling method

List<Contract__c> Contra= new List <Contract__c>([select, id, Site__c from Contract__c where Opportunity__c = Opp.id]);

List<Deal__c> Deals= new List <Contract>([select, id, Site__c from Deal__c where Opportunity__c = Opp.id]);

for(Contract__c Con:Contra){
       for(Deal__c D: Deals){
              if(Con.Site__c == D.Site){
                 
                        //PUT THE VALUE IN LIST FOR UPDATE

                      }
              else
                      {
                            //PUT THE VALUE IN LIST FOR INSERT
                          }

       }
}

Now, this code is not perfect. But i am using two for loops, which i want to avoid. What should be the best way to achieve this (comparing two list values)? If possible, please provide some code snippent.

Thanks in advance.
Hi Friends,
I am stuck at this for quite some time. the error is given below:

System.LimitException: Apex CPU time limit exceeded
Error is in expression '{!Process}' in component <apex:commandButton> in page quoteforaccounts: Class.QuoteUtilities.setMaInfor: line 21, column 1

Here is my method: 
Please help me out
public static void setMaInfor(Quote__c eq, list<Quote_Si__c> qsList, list<Quote_Pr__c> quoteTerms, list<KA_Mar_Elect__c> elecMargins, list<KA_Mar_Gas__c> gasMargins) {
        String type;
        String product;
        Decimal margin;
        Quote__c equote;
        Decimal count = 0;
        Decimal runner = 0;
        Decimal bestRunner = 0;
        Decimal currentMultiplier = 0;
        Boolean firstRun = true;
        Opportunity op;
    
        //Get list of all quote term prices that are selected
        
        List<Quote_Pr__c> qtpList = quoteTerms;
        //Get list of all KA Margin Electricity records
        List<KA_Mar_Elect__c> marElec = elecMargins;
	
	// newBEIndex
        firstRun = true;
	for(KA_Mar_Elect__c me : marElec){
                        if(firstRun){
                            bestRunner = math.abs(me.margin_mwh__c - newBEMargin);
                            currentMultiplier = me.index_new__c;
                            firstRun = false;
                        }else{
                            runner = math.abs(me.margin_mwh__c - newBEMargin);
                            if(runner < bestRunner){
                                bestRunner = runner;
                                currentMultiplier = me.index_new__c;
                            }
                        }
                    }

}

 
We have got one button, which, with the help of conga composer, opens an attachment. I am leveraging the functionality of that button to create another button. Here is my VF code:
<apex:commandButton value="Generate Doc" action="{!CallProc}"  onClick="openConga();return false;" rendered="{!if(valErr == true, false, true)}"/>
and here is my JS script:
 
<Script Language="JavaScript"> 
             function openConga() 
                { 
                    window.open('{!URLFOR($Action.Contract1__c.Conga_Composer_Main_Doc, Id)}', '','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes, toolbar=no,location=yes,status=yes'); 

                }

        </Script>

It is successfully invoking the COnga Composer, and its opening the window, but it throws the error:
The id parameter is missing
can anyone help me? what should i pass as the Id? i have tried object__c.Id, but it not identifying it.
 
Hi all,
I have a Java Script (Conga query which runs behind a button). I am asked to create a custom button, which will invoke the javascript (and open a conga template). I have created a custom button on the VF page and put the details over there. However, whenever any change happens in the JS, i need to change the VF as well (not desired). How should i achieve this. This is what i have tried till now:

Custom Settings: putting the JS code in Custome settings, and accessing it in Apex, and subsequently in VF custom button. I cant store the JS code in a custom setting field as my code is more than 255 characters (limitation of custom settings).

Static resource: i read on the net that this could be achieved by: (http://jevonearth.blogspot.ca/2011/08/using-static-resources-with-salesforce.html)
 
{!REQUIRESCRIPT('/resource/' & LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ',''),10) & '000/jbUtils')}

However, REQUIRESCRIPT cant be used for this purpose anymore (summer '16).

How should i proceed?
Hi,

We have an Apex Class that we need to add two lines of code to.

We've tested the code in Sandbox and used Eclipse IDE software to make the changes and seems very easy to make the changes by right clicking on the code in Eclipse and selecting 'Save to Server'.

I'd like to know when we come to deploy the changes in our production org is it just as easy to do, i.e. open up the production Apex Class in Eclipse, add the two lines that we verified works fine in Sandbox and simply just right click and select 'Save to Server'?

Is that or am I missing something?

Many thanks,
Dave
I am stuck with this if clause in my Test Clasuse. Can anybody help me. Here is my code example
public MethodName(ApexPages.StandardController Controller){

Newflag = false; //(variable Initialized as false)

if(Newflag )
{
// Do some stuff
}
//No else present or needed in this case.
}


When i am trying to pass this method by calling MethodName in my test class, 
and initializing the Newflag as true in the testclass, it not getting passed, as NewFlag is already initialized as false in the main class,
 and the testclass flag is getting overwritten by false. 

What should it do here

 
Hi,
i am working on field sets.
here is my VF code:
 
<apex:PageblockSection columns="2" >
             
                      <apex:repeat value="{!$ObjectType.Student__c.FieldSets.STU_FS2}" var="F2">
                      <apex:inputField value="{!Student__c[F2]}"/>
                      </apex:repeat>
              </apex:PageblockSection>  
              
              <apex:PageblockSection columns="2" >
             
                      <apex:repeat value="{!$ObjectType.Student__c.FieldSets.STU_FS3}" var="F3">
                      <apex:inputField value="{!Student__c[F3]}"/>
                      </apex:repeat>
              </apex:PageblockSection>

there are 3 field sets STU_FS1, STU_FS2 and STU_FS3. When they are shown on the VF page, the fields are coming as it is defined in the object. How can i give individual names to such field which are present in field sets STU_FS1,2,3. In short, i want to use something like label for the fields present in field sets.
Hi All,
I want to know that if we can restrict tab/view/Object in salesforce. 
I know we can restrict Viewable stuffs using a profile. But, my scenario is that, i have 100 users with profile A. out of that i want to restrict 10 users from viewing a single object...say Contact object. How can we achieve that?

Hello,

 

i wanted to know if there is a way to get the IDs of listviews of an Object in Apex Code.