• Rupal Kumar
  • NEWBIE
  • 339 Points
  • Member since 2015
  • Salesforce developer
  • Mirketa Software Pvt. Ltd.

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 104
    Replies
I am trying to learn Apex coding and I am unable to figure out how to write a test class for the code below:

public class FilterTasksCall {
   
    public Task[] tasks {get; private set;}
   
    public FilterTasksCall() {
        Id id = (Id) ApexPages.currentPage().getParameters().get('id');
         tasks = [Select
                    Who.Id,
                    Who.Name,
                    Id,
                    Subject,
                    What.Name,
                    ActivityDate,
                    Owner.Name,
                    Status,
                    LastModifiedDate
                    From Task
                    Where Subject Like '%Call%' and Who.Id=:ApexPages.currentPage().getParameters().get('id')];
    }

}

Thank you and your help is very much appreciated,
Jim
I have written a apex class with test class both are running but my code coverage is only 66%.Please help to solve the problem.
Apex Class-
global class Deleteoppotest implements Schedulable{

    global void execute(SchedulableContext SC) {
        deleteoppo();
    }

    public static void deleteoppo() {

        for(List<opportunity> objoppo : [SELECT Id FROM opportunity WHERE CreatedDate <= :(Date.Today() - 200) LIMIT 10])
            {
                delete objoppo;
            }    
    }
}

Test Class
@isTest
private class Deleteoppotestcls {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test



        Opportunity op = new Opportunity();
        op.Name = 'test1';
        op.StageName = 'Qualified';
        op.CloseDate = Date.Today();
        op.Description ='testingoppotestcls';
        op.Business_Type__c = 'Domestic';


        insert op;


        Deleteoppotest.deleteoppo();

    }
}

 
Hi There,

I have a custom object called SBP, On the object I have 2 look up fields to the Contact object "Principal" and "SBP Coordinator"
I'm trying to build a custom formula field which will provide the Principal email address from the Contacts oject and another formula field for the SBP Coordinator email address. 
In the Custom formula field creator these fields are not available.
Can I simply write out the formula manually something like "Principal_{!Contact_MyEmail_c" to get it to work?
Or is there an issue as due to 2 formula fields?

Thanks
Hello,

We are trying to create new WF with criteria that based on the field Amount under the opportunity object. Since we are using multiple currencies we would like to use the converted amount (same as appears in reports). The problem is that we should use formula to define the criteria (because we are using ISCHANGE() as well), we already know how to preform this with regular criteria by comparing the amount to "USD <some amount>", the question is what is the syntax while using formula?

Below is an example of how to do it with the regular criteria box:

User-added image

Thanks,

Udi
Hi,

I am building a Visualforce page for our force.com site. I am running into a formatting issue when I try to rerender. I have 4 Checkbox option buttons. If anyone is selected others have to be collapsed. Currently I have implemented the actionSupport only for first checkbox. Other 3 checkboxes collpase properly. But if I uncheck option1 formatting for other 3 is lost. How can I resolve this issue. PFB the code for checkboxes:
 
<apex:outputPanel layout="block" styleClass="requiredBlock" id="opt1OP">
    					<apex:outputText value="Option 1" style="font-family:Open Sans; font-size:15px; font-weight:bold;"/>
						</apex:outputPanel>
						
						<apex:outputPanel layout="block" id="opt1CB">
                        <apex:inputCheckbox id="chckOpt1" style="width:10px;height:10px;" value="{!val1}" />
                                                           
                            <apex:outputLabel value="I am a sole practitioner" style="font-family:Open Sans; font-size:15px; font-weight:bold; color:black;" for="chckOpt1"/>
                            <apex:actionSupport event="onchange" reRender="opt2OP,opt3OP,opt4OP" action="{!find}"/>
                            
                        </apex:outputPanel>
						<br></br>

						<apex:outputPanel id="opt2OP">
						<apex:outputPanel layout="block" styleClass="requiredBlock" rendered="{!NOT(val1)}">
    					<apex:outputText value="Option 2" style="font-family:Open Sans; font-size:15px; font-weight:bold;"/>
						</apex:outputPanel>

						<apex:outputPanel layout="block" rendered="{!NOT(val1)}">
                        <apex:inputCheckbox id="chckOpt2" style="width:10px;height:10px;" value="{!val2}" />
                                                           
                            <apex:outputLabel value="I am employed by a corporation or partnership" style="font-family:Open Sans; font-size:15px; font-weight:bold; color:black;" for="chckOpt2"/>
                            <apex:outputText value="Please enter your Employer's Name" style="font-family:Open Sans; font-size:15px; font-weight:bold;"/>
                            <apex:inputText value="{!case.Employer_s_Name__c}" id="empNameOpt2" styleClass="inputText" style="font-family:Open Sans;"/>
                        </apex:outputPanel> 
						</apex:outputPanel>
						<br></br>
						<apex:outputPanel id="opt3OP">
						<apex:outputPanel layout="block" styleClass="requiredBlock" rendered="{!NOT(val1)}">
    					<apex:outputText value="Option 3" style="font-family:Open Sans; font-size:15px; font-weight:bold;"/>
						</apex:outputPanel>

						<apex:outputPanel layout="block" rendered="{!NOT(val1)}">
                        <apex:inputCheckbox id="chckOpt3" style="width:10px;height:10px;" value="{!val3}"/>
                                                           
                            <apex:outputLabel value="I am employed by a Commonwealth/State/Local Government" style="font-family:Open Sans; font-size:15px; font-weight:bold; color:black;" for="chckOpt3"/>
                            <apex:outputText value="Please enter your Employer's Name" style="font-family:Open Sans; font-size:15px; font-weight:bold;"/>
                            <apex:inputText value="{!case.Employer_s_Name__c}" id="empNameOpt3" styleClass="inputText" style="font-family:Open Sans;"/>
                        </apex:outputPanel> 
						</apex:outputPanel>
						<br></br>

						<apex:outputPanel id="opt4OP">
						<apex:outputPanel layout="block" styleClass="requiredBlock" rendered="{!NOT(val1)}">
    					<apex:outputText value="Option 4" style="font-family:Open Sans; font-size:15px; font-weight:bold;"/>
						</apex:outputPanel>

						<apex:outputPanel layout="block" rendered="{!NOT(val1)}">
                        <apex:inputCheckbox id="chckOpt4" style="width:10px;height:10px;" value="{!val4}"/>
                                                           
                            <apex:outputLabel value="I am not covered by a policy" style="font-family:Open Sans; font-size:15px; font-weight:bold; color:black;" for="chckOpt4"/>
                        </apex:outputPanel>
						</apex:outputPanel>

Thanks in Advance.
Challenge is as below:--
To complete this challenge, add a validation rule which will block the insertion of a contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).
Name the validation rule 'Contact must be in Account ZIP Code'.
A contact with a MailingPostalCode that has an account and does not match the associated Account ShippingPostalCode should return with a validation error and not be inserted.
The validation rule should ONLY apply to contact records with an associated account. Contact records with no associated parent account can be added with any MailingPostalCode value. (Hint: you can use the ISBLANK function for this check)


--------------------------------------------
My validation rule is as attached pictureUser-added image

And Error is- Challenge Not yet complete... here's what's wrong: 
The validation rule failed to enforce the business logic
  • September 02, 2016
  • Like
  • 0
Hi
I need to built a page with say two or more fields – their values will be Yes or No – based on if it is selected or not.
Get these field values in class and based on field values set variable values and call the function e.g:
VF Page:
Text1: Yes(it is a radio button)
Text2: Yes(radio)
call saveList from action button on VF page.
Apex Class:
Public String Cat
Public String Req
public PageReference saveList()
{
if(Text1 == Yes):
Cat = ‘abc’
Req = ‘abc’
CallFunction(Cat,Req)
}
if(Text2 == ‘Yes’){
Cat = ‘def’
Req = ‘def’
CallFunction(Cat,Req)
}
}
public void CallFuntion(String Cat, String Req)
{
statements;
}
what is pagination in vf ? how do I implement it with an example. Thanks
I am trying to learn Apex coding and I am unable to figure out how to write a test class for the code below:

public class FilterTasksCall {
   
    public Task[] tasks {get; private set;}
   
    public FilterTasksCall() {
        Id id = (Id) ApexPages.currentPage().getParameters().get('id');
         tasks = [Select
                    Who.Id,
                    Who.Name,
                    Id,
                    Subject,
                    What.Name,
                    ActivityDate,
                    Owner.Name,
                    Status,
                    LastModifiedDate
                    From Task
                    Where Subject Like '%Call%' and Who.Id=:ApexPages.currentPage().getParameters().get('id')];
    }

}

Thank you and your help is very much appreciated,
Jim
Hi all,
I have a test class something like this.

global class Maincontroller()
{
  global virtual class summary extends summary1
  {
    global virtual override void startPage()
    {    
    //Lines of code
    }
  }
}

Can anyone please tell me how to cover the startPage method in my test class.Since this method is inside the inner class, I have no idea how to write the test class for that.Any help would be greatly appreciated.
I have written a apex class with test class both are running but my code coverage is only 66%.Please help to solve the problem.
Apex Class-
global class Deleteoppotest implements Schedulable{

    global void execute(SchedulableContext SC) {
        deleteoppo();
    }

    public static void deleteoppo() {

        for(List<opportunity> objoppo : [SELECT Id FROM opportunity WHERE CreatedDate <= :(Date.Today() - 200) LIMIT 10])
            {
                delete objoppo;
            }    
    }
}

Test Class
@isTest
private class Deleteoppotestcls {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test



        Opportunity op = new Opportunity();
        op.Name = 'test1';
        op.StageName = 'Qualified';
        op.CloseDate = Date.Today();
        op.Description ='testingoppotestcls';
        op.Business_Type__c = 'Domestic';


        insert op;


        Deleteoppotest.deleteoppo();

    }
}

 
Hi everyone,
I want to use <apex:actionregion > component in <div></div>tags in mycustom visualforce page. Can anyone help me over.

Regards,
mac
Hi All,

Q). what is the difference between actionFunction and actionSupport, Explain with funcionality?

can anyone reply for this post...
Thanks in advance..
I am trying to write a trigger that will copy the same attachment to all related contact when we insert an attachment to Account Object.
trigger CopyAttachmentsToCon on Attachment (after insert) {

    Set<Id> AccountIds = new Set<Id>();
    for(Attachment file : Trigger.new) {
     
        if(file.ParentId.getSObjectType() == Account.getSObjectType()) {
            AccountIds.add(file.ParentId);
        }
    }
Now how to get map of all the related contact of coresponding Account with Attachment?
 
Hi All,
I have one requirement that i need to use mid() String function in Apex class.I have a set called zip and in that i am adding all the Account.Billingpostal code .for this i need to fetch only first 5 to return.I used like zip.add(String.mid(Account.BillingPostalCode, 1, 5));
But error i scoming as variable string doesnot exist.How to do this mid() and add it to the set called Zip with all account Postal code.

​Kindly help me on this  
 
How to hide "Save & New Task" button from task page layout.
User-added image
How to make a input field readonly witth Java Script?
Hi All,

Why we are using custom controller and custom extensions in the same vf page? In which situation we are going to use both custom controller and extensions?

Can anyone reply for this post.......
Thanks in Advance............
Hi All,
Some body can help need to show column
1.out put text value red color if text value is closed 
2. out put text value green color if text value is open 
3. out put text value  grey color if text value is Existing

Below is the vf code
<apex:column >
<apex:facet name="header">PANEL STATUS</apex:facet>                                                
<p>  <span class="label label-default">{!objRecord.panel_status}</span></p>
 </apex:column>

 
Can somebody explain what are the scenarios for both and how to implement them:
1. Calling controller method from JavaScript
2. Calling Javascript Function from controller
I have captured the values.Now that I have to send those values to the email template.How to do that?
Please help.
hi Friends,

   I am created workflow rule for ending emails..my critiria is every tiime created And Edited..but when i am creting a record the email was not send to the emails ...
what is the reason....
rule critiria is: AND(NOT( ISBLANK(Focus_ID__c )), 
NOT(ISNULL(Focus_ID__c )))
means when  foccus_ID__C created my workflow sshold be triggerd..
what is the reason....