• Anurag Saxena
  • NEWBIE
  • 414 Points
  • Member since 2016
  • Salesforce TeamLead
  • Kcloud Technologies

  • Chatter
    Feed
  • 12
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 80
    Replies
Hi,  

would need assistance for getting started with testing apex classes. I basically created a simple class that is just a SOQL query returning a list of accounts owned by a given user: 
global with sharing class AccountRemoter {
    @RemoteAction
    global static List<Account> findAll() {
        return [SELECT Id, Owner.Name, Name, Phone, Email__c, ShippingLatitude, ShippingLongitude 
                    FROM ACCOUNT
               		WHERE OwnerId=:UserInfo.getUserID()];
		}
}

so far so good and all working well in sandbox but after searching and trying to find just some simple test class in order to achieve code coverage... the best i end up with is something like: 
 
@isTest
class AccountsListControllerTest {
	static testMethod void testAccountList (){
    List<Account> accounts = new List<Account>();
    for (Integer count = 0; count < 50; count++) {
        accounts.add(new Account (Name = 'Jack'+count, Phone ='00000000'+count));
    }
        
    insert accounts;
    AccountRemoter cc = new AccountRemoter(new ApexPages.StandardController(new Account()));
    Test.startTest();
        cc.findAll();
    Test.startTest();
}
}

which still gives me two problems: 
1. Constructor not defined: [AccountRemoter].<Constructor>(ApexPages.StandardController)
2. I think I would need some asserts below but i really cannot find a post where there is a simple test class 

Could someone guide me in the redirection and if this has been answered before please guide me in the right direction. After hours I am still unable to locate a solution. 

Thanks 

Please to a batch change to replace the current INACTIVE Offerings (L4) in each of the opportunities in the attached file with the Offering in the "New Offering (L4) column.

Need to add new offerings

Here Offering(L4) and capabilities are related list.

Please any one suggest me how can we do?
  • April 24, 2017
  • Like
  • 0
Hi,

I am hyaving a scheduler class for my batch class which i am getting the following error

Error: Compile Error: Constructor not defined: [ContractBatchTriggerHandler].<Constructor>() at line 5 column 43
 
MY SCHEDULER CLASS :

global class ContractBatchTriggerHandler_Schedular implements Schedulable {

        global void execute(SchedulableContext sc) {

        ContractBatchTriggerHandler opb = new ContractBatchTriggerHandler();
        Database.executeBatch(opb,100);
        }
}
 
MY BATCH CLASS :

global class ContractBatchTriggerHandler implements Database.Batchable<sObject> {
Set<Id> contractIdSet = new Set<Id>();

    // Constructor will take set of new Contract IDs
    global ContractBatchTriggerHandler (Set<Id> contractIdSet){
        this.contractIdSet = contractIdSet;
    }
 global Database.QueryLocator start(Database.BatchableContext bc) {
        // Query all Contract records that were in Trigger.new
        return Database.getQueryLocator([SELECT Status__c, Account__c FROM Contract__c WHERE Id IN :contractIdSet]);
    }

    // The execute method will call three methods
    global void execute(Database.BatchableContext bc, List<Contract__c> scope) {
        ContractfieldsupdateonAccount(scope);
        contractcommencementdate(scope);
        contractexpirydate(scope);
    }

help me what i am doing wrong here

thanks
Hello,

I want to give read only permission to the "Account" object. Similarly i want to make "Account " fields read only. Only 3 fields in account object should be editable. I have clone the Salesforce Admin profile. Then Gave only read only access to the object and 3 feilds are editable other all remaining fields are editable. But In my case when object is read only then all fields become read only and if i give object edit permission then all fields become editable. I am not getting what to do. I have given permission set to make those 3 field raed only and assigned user to them
Please anyone know the correct solution reply as soon as possible. I need to resolve this issue immediately

Thanks & Best Regards,
Satakshi
Hello,

I have object like below
 
Account
  CustField1__c [Lookup to object CustObj1__c]

CustObj1__c
  Name [Text] Standard field
  CustomField2__c [Text]

I populated the name of the EEF, if it it present on Account.
If( CustomField2__c  == 'EEF')
  Then On Account CustField1__c = "Name of EEF"
I have used a combination of Flow and process builder for that.

Everythuing works well but I have catched the exception and i get below error
An error has occurred on the flow :
The flow tried to update these records: null. This error occurred: MALFORMED_ID: CustomField2__c () : id value of incorrect type: SomeValue. For details, see <a href='https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm#'>API Exceptions</a>.
I wonder how to correct this error.






 
Hello Community

"Not sure if its under the right category"

I'm using the professional edition and would like to only show some more newly added fields to the account page if the standard field "type" (its a single picklist) has the value "partner" then I would like to have some additional (3-4) fields (multipick list fields) on this account page. Otherwise if the value is not partner, then all those fields shouldn't show up at all.

Can you help me how to do this? Is this possible?
Hello,

i am new to salesforce and I have a custom field on account as Consecutive_Contacts_Name__c. Whenever a new contact is inserted the field should have value of the contact first name if Consecutive_Contacts_Name__c =null on account. if Consecutive_Contacts_Name__c != null it should have the previous value +',' + recent contact first name. Below is my code but it is not working properly. Could anyone please help on the same.

rigger ContactOnAccount on Contact (after insert) {
    List<Account> accList = new List<Account>();
    for (Contact con:[select FirstName, Account.Consecutive_Contacts_Name__c, Account.Id from Contact where id in:trigger.new]) 
    {
        
        Account acc = new Account(id=con.Account.id);  
        
        acclist.add(acc);
        if(acc.Consecutive_Contacts_Name__c == '' && acc.Consecutive_Contacts_Name__c == Null)
        {
            acc.Consecutive_Contacts_Name__c = con.FirstName; 
            update acclist;       
        }
        else{
            acc.Consecutive_Contacts_Name__c = acc.Consecutive_Contacts_Name__c + ',' + Con.FirstName;
           update acclist;
            }
    }
     
    
}
Hello, I'm building a trigger that I had at a previous company where an asset is populated on the account, from the listed products on an Opportunity, anytime it is Closed Won.
the trigger is:

trigger CreateAssetonClosedWon on Opportunity (after insert, after update) {
     for(Opportunity o: trigger.new){ 
      if(o.isWon == true && o.HasOpportunityLineItem == true){
         String opptyId = o.Id;
         OpportunityLineItem[] OLI = [Select UnitPrice, Quantity, PricebookEntry.Product2Id, PricebookEntry.Product2.Name, Project_Association__c, Product_Family__c, Product_Category__c, Converted_to_Asset__c  
                                      From OpportunityLineItem 
                                      where OpportunityId = :opptyId  and Converted_to_Asset__c = false];
         Asset[] ast = new Asset[]{};
         Asset a = new Asset();
         for(OpportunityLineItem ol: OLI){
            a = new Asset();
            a.AccountId = o.AccountId;
            a.Product2Id = ol.PricebookEntry.Product2Id;
            a.Quantity = ol.Quantity;
            a.Price =  ol.UnitPrice;
            a.PurchaseDate = o.CloseDate;

The error I'm getting is: Error: Compile Error: expecting right curly bracket, found '<EOF>' at line 17 column 0

I added a curly bracket on line 17, so it pushed the error to line 18.  What am I missing?
Hello,

I an issue regarding "Active Opportunity". I cannot access "Active Opportunity" on Account Object from Opportunity. 
User-added image

And when trying to choose a field from "Record Type*", cannot access to "Active Opportunity". What ever I select "Select the Opportunity record that started your process" neither "Select a record related to the opportunity"
User-added image

I already checked the FLS regarding "Active Opportunity" on Account object.

​Thanks in advanced for your help.
I have used this formula, it gave me a field with a red or green flag.  I would like a banner displayed across the top of the account. 

IF( ISPICKVAL( Type, "Client"), 

IMAGE("/img/samples/flag_red.gif","Customer Account"), 

IMAGE ( "/img/samples/flag_green.gif","Prospect Account"))

Can I get some help?  Appreciate it. 
API name of custom object is "Payroll_Checklist__c".  I created a Field on this object called 'Checklist Complete?' (API Name = "Checklist_Complete__c").  Each Checklist can have 3 - 9 different tasks associated with it.  When every task status is 'Completed' (or ultimately removed from the Checklist), I want the checkbox to be trigged from default 'false' to 'true'.  It seems regular workflow will not work on this (the custom object is not 'related' to tasks).  How can I achieve this?  Seems doable, but a bit beyond my capabilities!
I am in the process of setting up an email button on the opportunity page layout. 

I followed this article - https://success.salesforce.com/ideaView?id=087300000006tqzAAA which was a great guide, but I am having problems. I substituted the 'case' for Opportunity & there were no problems with the syntax. However, when I tested the button I got the following error - 

Unable to Access Page
The value of the "template_id" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information. 

I later found some pointers here, and tried the following URL:

/_ui/core/email/author/EmailAuthor?rtype=003&p3_lkid={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}&p5={!$User.Email}&p24&template_id=00XC0000001O7Ck

Problem here is the following error (below) 

User-added image


Changed it to & still received an error

_ui/core/email/author/EmailAuthor?rtype=003&p3_lkid={!Opportunity.Id}&retURL=!Opportunity.Id}&p5={!$User.Email}&p24&template_id=00X20000001Fom6

User-added image

Thanks in advance!

I need to write a SAQL to get the lowest margin of my shipment records:

Here is the formula:
Lowest margin = (Lowest unit price-Cost price of product which has lowest unit price)/Cost price of product which has lowest unit price .
Here is My SAQL-


q = load "Shipment_with_Receiver";
q = group q by all;
q = foreach q generate trunc((((min('Unit_Price__c')-min('Product__c.Cost__c'))*0.01)/min('Product__c.Cost__c')),2) as 'Lowest Margin Calcualtion';

Thanks

challenge link : https://trailhead.salesforce.com/trails/force_com_dev_beginner/modules/business_process_automation/units/process_builder . 

 in trail heads i am getting the following message "An update to an account record failed to update the mailing address fields of all child contact records. Make sure that the process is correct and that it is activated."

but when i try to manually update the account address and then check with the related contact the process is working fine there is no problem . the issue is trailhead is not accepting this solution .
User-added imageUser-added image
P.S : i have tried deactivating all the triggers , flows , validation rules , all other stuff on both the objects . please help . !
 
Hi All,

I have three objects obj1, obj2, obj3 where obj2 is junction object for obj1 and obj2.

now my requirement is i have to retrive obj1 name from obj3 through query.

Please help me with sample query for the same. Thansk


Best Regards,
Mohammad Yaseen
 
Hi,  

would need assistance for getting started with testing apex classes. I basically created a simple class that is just a SOQL query returning a list of accounts owned by a given user: 
global with sharing class AccountRemoter {
    @RemoteAction
    global static List<Account> findAll() {
        return [SELECT Id, Owner.Name, Name, Phone, Email__c, ShippingLatitude, ShippingLongitude 
                    FROM ACCOUNT
               		WHERE OwnerId=:UserInfo.getUserID()];
		}
}

so far so good and all working well in sandbox but after searching and trying to find just some simple test class in order to achieve code coverage... the best i end up with is something like: 
 
@isTest
class AccountsListControllerTest {
	static testMethod void testAccountList (){
    List<Account> accounts = new List<Account>();
    for (Integer count = 0; count < 50; count++) {
        accounts.add(new Account (Name = 'Jack'+count, Phone ='00000000'+count));
    }
        
    insert accounts;
    AccountRemoter cc = new AccountRemoter(new ApexPages.StandardController(new Account()));
    Test.startTest();
        cc.findAll();
    Test.startTest();
}
}

which still gives me two problems: 
1. Constructor not defined: [AccountRemoter].<Constructor>(ApexPages.StandardController)
2. I think I would need some asserts below but i really cannot find a post where there is a simple test class 

Could someone guide me in the redirection and if this has been answered before please guide me in the right direction. After hours I am still unable to locate a solution. 

Thanks 

Please to a batch change to replace the current INACTIVE Offerings (L4) in each of the opportunities in the attached file with the Offering in the "New Offering (L4) column.

Need to add new offerings

Here Offering(L4) and capabilities are related list.

Please any one suggest me how can we do?
  • April 24, 2017
  • Like
  • 0
Hi I'm a salesforce newbie and I'm trying to work my way throught the 'Build Your First App' tutorial. When I try to verify, I receive the following error

;unable to verify message

Can anybody give me any clues as to what the problem is, as my application quick action link seems to work ok.

Thanks, Mark
Hi,

I am hyaving a scheduler class for my batch class which i am getting the following error

Error: Compile Error: Constructor not defined: [ContractBatchTriggerHandler].<Constructor>() at line 5 column 43
 
MY SCHEDULER CLASS :

global class ContractBatchTriggerHandler_Schedular implements Schedulable {

        global void execute(SchedulableContext sc) {

        ContractBatchTriggerHandler opb = new ContractBatchTriggerHandler();
        Database.executeBatch(opb,100);
        }
}
 
MY BATCH CLASS :

global class ContractBatchTriggerHandler implements Database.Batchable<sObject> {
Set<Id> contractIdSet = new Set<Id>();

    // Constructor will take set of new Contract IDs
    global ContractBatchTriggerHandler (Set<Id> contractIdSet){
        this.contractIdSet = contractIdSet;
    }
 global Database.QueryLocator start(Database.BatchableContext bc) {
        // Query all Contract records that were in Trigger.new
        return Database.getQueryLocator([SELECT Status__c, Account__c FROM Contract__c WHERE Id IN :contractIdSet]);
    }

    // The execute method will call three methods
    global void execute(Database.BatchableContext bc, List<Contract__c> scope) {
        ContractfieldsupdateonAccount(scope);
        contractcommencementdate(scope);
        contractexpirydate(scope);
    }

help me what i am doing wrong here

thanks
Hi All, 

When I am trying to Deleted Class from Production I am getting error

Average test coverage accross all apex classes and trigger is 58% at least 75% test coverage is required. Please see below snapshot User-added image
Hi ,

I have written a trigger on NOTE ,which will update a checkbox called note_availbale__c on event object.

scenario:
if there is a note the Note_avilable__c should be checked

Here My Code:-
trigger NoteAvilable on Note (after insert,before delete,after update){

   if(trigger.isinsert){
       List<Event> co = New List<event>([select id from Event where id =: Trigger.New[0].ParentId]);
       If(co.size()>0){            
       co[0].Note_Available__c = True;
              update co;        
     }
}

  if(trigger.isdelete){
  List<Event> co = [select id from Event where id =: Trigger.old[0].ParentId];        
   If(co.size()>0){            
   co[0].Note_Available__c = false;            
    update co;        
    }
  }
 }

Its not firing .

Thanks In Advance
Tapas