• Devender M
  • NEWBIE
  • 300 Points
  • Member since 2013

  • Chatter
    Feed
  • 10
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 75
    Replies

Hello.  Does anyone know what happened to the ability to click on the code coverage percentage for a speficic controller?  In the past, we could click on a percentage and see the lines of code shaded a particular color to denote coverage.  Now, when I click the coverage percentage all I get is a blank page.

 

Any thoughts?

 

 

Thanks

How can I reteive only the record created within last 12 hr?

 

I know I can reterive for last 1 day like using below.

datetime dt = System.now()-1;

 

a.CreatedDate >=: dt

 

How can I use dyamic hour to query the SOQL?

I was thinking about how to create a trigger that reads through all campaign members of a certain campaign and updates a custom campaign text field with a string containing the names of all members.

 

For example, in campaign "A" there are 3 members whose names are "John", "Joe" and "Jack". A custom field Member_List__c on "A" would read (after the trigger is executed) "John, Joe, Jack". (In my case, campaigns have only a small number of members so a default text field is fine, no need for long text areas)

 

Do you have any ideas?

 

Thank you!! 

  • July 11, 2013
  • Like
  • 0

Hi I am trying to find a solution to my following post

 

http://boards.developerforce.com/t5/Apex-Code-Development/Round-Robin-Record-Assignment-email-notification/m-p/645671

 

I have created a workflow that should be sending an email when the lead owner changes from the Queue to the actual user.

 

Created and everytime edited

 

AND(ISCHANGED(OwnerId),
NOT(BEGINS(OwnerId, "00G")),
BEGINS(PRIORVALUE(OwnerId), "00G"))

 The Workflow Action I has assigned to test this is to assign me a task with notification but I receive none, so it seems like the workflow isn't working

 

Can anyone help?

 

 

Hi Guys,

 

I've written a very simple trigger for Campaigns that works well however, I want to ensure I have a test class for it and haven't written a test class before.

 

This is my trigger:

 

rigger createjournalcodes on Campaign (after insert) {

List<Journal_Codes__c> journalcodes = new List<Journal_Codes__c>();
for (Campaign camp : trigger.new) {
    
        Journal_Codes__c jc = new Journal_Codes__c();       
        jc.Campaign__c = camp.Id;
        jc.CurrencyIsoCode = 'GBP';
        jc.L1_Country_Region__c = 'UK';
        jc.L1_Country_Region_Display__c = 'United Kingdom';
        jc.L2_Activity_Codes__c = 'U';
        jc.L2_Activity_Codes_Display__c = 'Unallocated';
        jc.L3_Donor_Codes__c = 'CAMFE';
        jc.L4__c = 'UREST';
        jc.L5_Database_Code__c = 'CAM';
        journalcodes.add(jc);
    }
for (Campaign camp : trigger.new) {
    
        Journal_Codes__c jc = new Journal_Codes__c();       
        jc.Campaign__c = camp.Id;
        jc.CurrencyIsoCode = 'USD';
        jc.L1_Country_Region__c = 'US';
        jc.L1_Country_Region_Display__c = 'United States';
        jc.L2_Activity_Codes__c = 'U';
        jc.L2_Activity_Codes_Display__c = 'Unallocated';
        jc.L3_Donor_Codes__c = 'CAMFE';
        jc.L4__c = 'UREST';
        jc.L5_Database_Code__c = 'USA';
        journalcodes.add(jc);
    }
insert journalcodes;
}

 so i'm guessing I need a test class that creates a campaign but then I'm stuck on what I should be doing from there.

 

I have some required fields on the campaign so I'm guessing it needs to have them in there but then do I also need to create these related items or what?

 

confused myself a bit :)

 

cheers

dan

When an opportunity is created as Stage Name = =’Closed Won ‘ create an opportunity of this opportunity whose Name will be as  "Cloned+Name of new Opportunity".

As well as Associated Account will be same as new opportunity

 

Thanks in advance

  • July 10, 2013
  • Like
  • 0

Hi 

 

Is there a way we can display all fields of an object (not yet inserted/no ID) in edit mode in visualforce page? Is there a simpler approach than input fields/repeat/describe approach?

 

We are implementing a custom cloning solution mimicing standard cloner for one of our custom objects. And just like the standard cloning functionality, we would like to show all record fields for the user to change before they hit save (and we save the cloned record). Clone button was overridden to transfer user to a visualforce page, this is where we want to display all fields.

 

Thank you

 

Edit: Another solution I had in mind was to use apex:detail with inline support and subject=original record, use JS to remove the standard buttons and then clone the original record. But this approach I think is going to confuse the users.

  • July 09, 2013
  • Like
  • 0

I have the following test script:

 

@isTest

public class theBatchLoadTest{

 

    public static testMethod void testMyController() {

        

        BatchLoadDaily controller = new BatchLoadDaily('fm017104');

         Database.executeBatch(controller, 20);

 

        }

}

 

 

Which tests the following:

 

global class BatchLoadDaily implements Database.Batchable<sObject> {

  

  global final String bdId;

   

  global BatchLoadDaily(String bdId) {

    this.bdId = bdId;

     

  }

 

 

  global Database.QueryLocator start(Database.BatchableContext bc) {

     

return Database.getQueryLocator('SELECT payout__PrimaryKey__c, payout__Account_Desc__c, payout__Account_Opening__c, payout__Account_Type__c, payout__Albridge_ID__c, payout__Asset_Fund_Name__c, payout__Asset_Type__c, payout__BD_Id__c, payout__Cirrus_Source__c, CreatedById, CreatedDate, payout__CumDisc__c, payout__Cusip__c, payout__Dealer__c, payout__DealerBranch__c, IsDeleted, payout__Financial_Account_Number__c, payout__FirstName__c, payout__IRS_Code__c, Name, LastModifiedById, LastModifiedDate, payout__LastName__c, payout__Last_Price__c, payout__Last_Price_Update__c, payout__Market_Value__c, payout__MiddleName__c, payout__Num_Of_Shares__c, OwnerId, payout__Payout_Date__c, payout__PersonMailingCity__c, payout__PersonMailingStateProv__c, payout__PersonMailingStreet__c, payout__PersonMailingZip__c, payout__PersonOtherPhone__c, payout__Phone__c, payout__Plan_Status_Code__c, ConnectionReceivedId, Id, payout__Registration_Line_1__c, payout__Registration_Line_2__c, payout__Registration_Line_3__c, payout__Registration_Line_4__c, payout__SSN__c, payout__SSN_Financial_Account__c, ConnectionSentId, payout__Shares__c, payout__Sponsor_Name__c, payout__Symbol__c, SystemModstamp, payout__Systematic_Plan_Type__c, payout__Tax_Status__c, payout__UniqueId__c, payout__Valuation_Date__c, payout__RepId__c  FROM payout__ImportStaging__c where payout__BD_Id__c = \'' + String.escapeSingleQuotes(bdId) + '\' AND payout__Processed_Flag__c <> \' Y \'');

  }

 

  global void execute(Database.BatchableContext bc, List<payout__ImportStaging__c> scope) {

      

       

       System.Debug('Get in void execute');

 

}

 

But for some reason the global void execute code is NOT getting run (tested). Any ideas?.... The query does return rows to the getQueryLocator, but then the test stops and no more code is tested/covered.

 

Thanks so much for any help!

-Jim

Hi,

 

I want to throw the error message for comments field if everytime Date field is updated

 

I have written the formula below but whenever comments field is not blank it is not working properly.

 

isblank(Comments__c)
&&
ISCHANGED(Date__c)

 

Can anyone help?

Hi,

 

I  want to create the custom button for updating the field value by means of some condition. 

 

For an example, If the field name is 'Test', After clicking the custom button, field name should be changed to "Test Updated'

 

Please guide me for doing this..

 

Any help is appreciated .

 

 

Thanks,

Ambiga

Hi,

 

I am getting below error when i run the test class.

 

System.QueryException: List has no rows for assignment to SObject

 

Error is in below line in controller:

 

User unamename = [Select id,Name,Email from User where id=:lecord.ownerid Limit 1];

 

 

From Visualforce Page i am passing the UserId to controller. IN test method iam not able to pass the UserId in the Above Query , hence Query fetches 0 Row and error occurs. How to Pass the Userid in test method. I tried using

 

apexpages.currentpage().getparameters().put('lecord.Id',Userid.id);

 

but still it fails. Guide me how to pass Pls.

  • August 13, 2013
  • Like
  • 0

Hello,

 

 

I created two custom object for my application and created tabs as well. every thing is visible for me and working perfect

 

I have admin profile for my self in sandbox where the application is present, i created 2 other profile for users with different permission sets 

 

In Both the profile and persmision set - i have give different criter but TAB is visible 

 

but when i log in as a user, all i can see is only one tab for only one custom object out of two - other one is not shown, both the custom object have same setting in profile and permission set 

 

when i make the tab of object that isn't visible as default object for that app, now when i log in as user - it still tab not visible but salesforce is diaplaying "Insufficient Privileges: You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary

I have tried lot of thing non seems to work - if any one has any ideas or suggestion 

would be great help

thanks

 

i have a custom field on standard page  'Rating'. this field is  updated based on the other field population... it has a textbox .

 

now i want  this textbox  dont allow anything from user. (because it was populated based on other field)...so how to  disable this textbox.

Hi All,

      How to write apex class for to get dynamic url in any record and objects.

Hai all,

 

     I am new to visualforce page faceing problem in multi file uploading to a particular record  i have searched a lot but i got this link which is working fine till 2.10 MB files but salesforce allows upto 5 MB uploading so is there any way to extend this functionality 

http://www.tehnrd.com/multi-file-uploader-for-salesforce-oh-ya-and-progress-bars-too/ 

 

        Please help me in sloving this 

I have a simple page set up to take in candidate data, and it works perfectly fine. But when save is clicked, it moves me from http://pjl-developer-edition.na15.force.com/ExternalSurvey to http://pjl-developer-edition.na15.force.com/ExternalSurvey/a00i0000005BYLR  and then I get the Authorization Required  error. The records on the candidate database are still updated and the new information is added perfectly well. How do I get this to save and just clear the data and stay on the page, or change the redirect to go to a thank you page that would be publicly available? Code is below! This is my first post so im not quite sure how to get it in a "code box" , sorry about that! Thanks

 

<apex:page standardController="Candidate__c"  >

 

    <apex:form >

        <h1>

        First Name: <br/>

        <apex:inputField value="{!Candidate__c.First_Name__c}" />

        <br/><br/>

        Last Name:<br/>

        <apex:inputField value="{!Candidate__c.Last_Name__c}" />

        <br/><br/>

        Email: <br/>

        <apex:inputField value="{!Candidate__c.Email__c}" />

        <br/><br/>

        Phone:<br/>

        <apex:inputField value="{!Candidate__c.Phone__c}" />

        <br/><br/>

        School:<br/>

       <apex:inputField value="{!Candidate__c.School__c}" />

       <br/><br/>

        GPA:<br/>

        <apex:inputField value="{!Candidate__c.GPA__c}" />

        <br/><br/>          

        </h1>

 

        <apex:commandButton action="{!save}" value="Save record"/>

        <br/>

        <apex:commandButton action="Cancel" value="Cancel"/>

        <br/>

    </apex:form>           

</apex:page> 

 

 

Hi,

when the owner of account is changed the realted list objects owner neeed to be changed.

Related objects like contact/opportunity/event/task/contract.

 

Can any help me out how to frame the logic to achive this funcationality.

 

Any help is highly appriciated.

 

Regards,

Vishnu.

Hello.  Does anyone know what happened to the ability to click on the code coverage percentage for a speficic controller?  In the past, we could click on a percentage and see the lines of code shaded a particular color to denote coverage.  Now, when I click the coverage percentage all I get is a blank page.

 

Any thoughts?

 

 

Thanks

Hi, 

 

I've been running this trigger in production for awhile, but it's running into governor limits for too many SOQL queries. Any suggestions on how to fix it?

 

Trigger

Trigger marketassignmenttrigger on Account (before Insert, before Update)
{
    //Iterate through all accounts passed to the trigger
    Account[] accounts = Trigger.new;
    for (Account a : accounts)
    {
        //The market on the account needs to be populated and (the record is new or (the record is updated and (the market field is changed or the geojunction is null)
        if (a.Market__c != null && (Trigger.isInsert || (Trigger.isUpdate && ((Trigger.oldMap.get(a.Id).Market__c != a.Market__c) || (a.geojunction__c == null) ))))
        { 
            //pull the geojunction ids
            List<GeoJunction__c> geojunctions = [select Id, Market_Assignments__r.Market_Manager__r.id, Market_Assignments__r.Market_Manager__r.IsActive  from GeoJunction__c where name = :a.Market__c];
            
            //Iterate the geo_junctions
            for (GeoJunction__c g : geojunctions)
            {
                if (g.id != null)
                {
                    //updates geojunction on account
                    a.geojunction__c = g.Id;
                    
                    if(a.ownerid == '00560000001267d' && g.Market_Assignments__r.Market_Manager__r.id != null && g.Market_Assignments__r.Market_Manager__r.IsActive  == TRUE)
                    {
                        //updates geojunction on account
                        a.ownerid = g.Market_Assignments__r.Market_Manager__r.id;
                        a.Account_Owner_hidden__c = g.Market_Assignments__r.Market_Manager__r.id;
                    }
                }
            }
        }
    }
}

 

Please point out  what I am doing wrong

 

<apex:page Controller="EmployeeDemo" >
  <apex:form >
  <h1>Congratulations</h1>
  This is your new Page: ForDocument
  <Apex:pageBlock >
  <apex:inputField value="{!objEmployee.Employee_Name__c}"/>
  <apex:pageBlockSection >
<apex:commandButton Action="{!Save}" Value="Save" />
</apex:pageBlockSection>
   </Apex:pageBlock>
  </apex:form>
 </apex:page>

 

public with sharing class EmployeeDemo
{

    public EmployeeDemo()
    {
     objEmployee= new Employee__c();
    }

    public Employee__c objEmployee {get;set;}
   
    public  PageReference Save()
    {
        try
        {
            Insert objEmployee;
        }
        catch(Exception ex)
        {    
            System.debug('\n\nException ='+ex.getMessage()+'\n\n');
        }
        return null; 
    }
}

 

Regards

Ambivert



Hi am writing the trigger updating the parent object record based on child records

i have 2 custom objects
1 Opportunity__c,
2 work__c (look up to opportunity) --- this object i have one check box field Received__c if it is true i need to update the parent object field Received__c =true,
if in any case user will try to update the parent object field Received__c=true ,it should have to check the child records ,in child records it is true ot not,
if its is not true i need to show error message.


can any one tell me where am missing

 

 

trigger Received on Opportunity__c(before update) {
for(Opportunity__c op:trigger.new)
{
for(work__c ar:[select id,Received__c from work__c where Opportunity__c=:op.id])
{
system.debug('error message1');
if((ar.Received__c==false) && (op.Received__c==true))
{
system.debug('error messagesssssssssssss');
op.adderror('Received is not checked please check in work records');
system.debug('error message'+op.Received__c);
}
if(ar.Received__c=true)
{
op.Received__c=true;
}
}
}

}

 

 

regards

venkatesh

Hello Everyone,

 

I have a batch class which will delete the Accounts having Duplicate_Id__c !=null according to our shedule time. Please let me know how we can write the test class for it.

 

Code:

 

global class DeleteAccount implements Database.Batchable<SObject>
{

   Public String Query='Select Id, Duplicate_ID__c From Account where Duplicate_ID__c!=null';   
    global  Database.QueryLocator Start(Database.BatchableContext BC)
    {
      return Database.getQueryLocator(query);
    } 
    global void Execute(Database.BatchableContext BC,List<Account> accs)
    {
    try{
      List<Account> ListAcc =new List<Account>();
      for(Account objAcc:accs)
      {
            if(objAcc.Duplicate_ID__c !=null)
            {
                ListAcc.add(objAcc);
            }
 
        }
        if(ListAcc!=null && ListAcc.size()>0)
        list<Database.DeleteResult> sr = Database.delete(ListAcc,false);      
    }catch(Exception e){} 
    }
    global void finish(Database.BatchableContext BC)
    {
    }
    
}

i am trying to set value of custom url field to a visualforce page to for that i need domain oring prefix like ap1.salesforce.com or na1.salesforce.com .how to get that in UI it is showing some global objects $Organization,$Profile,$System,$User,$UserRole which object should be used and which field please tell

Hi,

 

   In Oppertunity we have a field called Oppertunity_Initialted_International_c . This field must be mandatory to only few users. to add this conditions

 

  In Users Object there is a check box with name User_International_c,  If this is checked user should be mandatory to enter in oppertunity field Oppertunity_Initialted_International_c .

 

 


Please suggest me how to do this validation.

 

Thanks

Sudhir

Hi Guys,

I am new to writing triggers.

I have an object called Store_Visits__c and one called Field_Check_In__c.

In the case that there exists a Field_Check_In__c with the same Owner, Date and StoreID as a Store_Visit__c Owner, Date and StoreID, i want to set Store_Visit.Related_Check_In to the Check_In__c.id.

 

Here is what I have so far:

trigger CheckInTrigger on Store_visit__c (after insert, after update) {

//Find all Field_Check_Ins where owner,date, and storeId matches Store_visit__c owner, date and storeId
List<Field_Check_In__c> cis = [SELECT Id FROM Field_Check_In__c WHERE (CheckIn_Date__c IN : Trigger.new.Actual_Date_of_Visit__c ) AND ( Retail_Store__c IN : Trigger.new.Retail_Store_Visited_del__c ) AND (Owner IN : Trigger.new.Owner)];
	
//Loop through related CheckIns and set Store_visit__c.
    	 for ( Field_Check_In__c c: cis){
				Trigger.new.Related_Field_Check_In__c = c.Id;
				update c;
    	 	}
}

 The error I am getting is "Initial term of field expression must be concrete SObject: List<Store_visit__c>

 

Any ideas?

 

 

Hello, 

 

How I can do this assignment correctly?

 

Thanks

 

 

global Database.Querylocator start(Database.BatchableContext bc){
//where fecha_del_evento__c>=LAST_N_DAYS:1
return Database.getQueryLocator([SELECT ID, Comentarios_Invitados__c,EventRelationId__c,Estado_Invitado__c,fecha_del_evento__c FROM Informe_icex__c]);
}

global void execute(Database.BatchableContext BC, List<sObject> scope){

Map<ID, Informe_icex__c> iMap = new Map<ID, Informe_icex__c>((List<Informe_icex__c>)scope);
System.Debug('iMap Records : ' + iMap);

Set<Id> sIdInforme = new Set<Id>();
Informe_icex__c ii;

for(sObject c:scope) {
ii = (Informe_icex__c) c;
if(!sIdInforme.contains(ii.EventRelationId__c))
sIdInforme.add(ii.EventRelationId__c);

}
System.Debug('sIdInforme Records: ' + sIdInforme);


List<Informe_icex__c> listToBeUpdated = new List<Informe_icex__c>();

for(EventRelation er:[SELECT Id,response,Status,RelationId,EventId,RespondedDate FROM EventRelation WHERE Id IN :sIdInforme]){
System.Debug('EventRelation Records er: ' + er);
if (!iMap.containsKey(er.Id)) {
System.Debug('passed through here : ' + iMap);
Informe_icex__c icex = iMap.get(er.Id); //I saw that this assignment is empty, the error is System.NullPointerException: Attempt to de-reference a null object
System.Debug('Icex Records : '+ icex);
if(er.Status!='New'){
System.Debug('Its different from new : ');
icex.Comentarios_Invitados__c = er.response;
icex.Estado_Invitado__c = er.status;
listToBeUpdated.add(icex);

}
}

}
if(listToBeUpdated.size()>0) update listToBeUpdated;
System.Debug('passed through here update : ');
}

Hi,

 

I have a custom object named candidate (Salesforce Std Page layout) and in that we are capturing candidate email address.

 

I would like to send email to the candidate by clicking send email custom button. By clicking the send email button, outlook should  open with to as candidate email address and user can enter the body and subject. 

 

Note: I am not integrated outlook with salesforce

 

How to achieve this? Kindly advise.

 

 

Hi,

       

Here i attached my Update trigger and test class method. Test class method fails.Please help me where i went wrong.

    

////Trigger    

trigger updateContactOpportunity on Account (before update) {
 
 Set<Id> ids=new Set<Id>();
 for(Account a:Trigger.new){
 ids.add(a.id);
 }
 List<Contact> con=[Select id, accountId, phone from Contact where accountId in:ids];
 
 List<Opportunity> opp= [Select id, AccountId, Custom_Opportunity_Number__c from Opportunity where accountId in:ids];
 for(Account a:Trigger.new){
 
 for(integer j=0;j<con.size();j++){
 if(a.id==con[j].accountId){
  con[j].phone=a.phone;
 }
 }
 for(integer i=0; i<opp.size();i++){
 
  if(a.id==opp[i].accountid){
       
   opp[i].Custom_Opportunity_Number__c=a.Custom_Account_Number__c;
   
  }
 }
 }
 update con;
 update opp;

}

 

////TestClass

@isTest
private class testupdateConOpp{
 
  static testMethod void testUpdate(){
  Account a=new Account(name='test',phone='2234',Custom_Account_Number__c='6537');
   insert a;
   Contact c= new Contact(lastName='test', accountId='test.id',phone='2234');
   insert c;
   Opportunity o=new Opportunity(accountId='a.id', Custom_Opportunity_Number__c='6537');
   insert o;
   
   a.phone='111';
   a.Custom_Account_Number__c='222';
   update a;
   
   Contact updatedContact=[Select accountid, phone from Contact where id =:a.id ];
   
   system.assertEquals(updatedContact.phone,'111');
   
   Opportunity updatedOpp=[Select accountId,Custom_Opportunity_Number__c from opportunity where id=:a.id];
   
   system.assertEquals(updatedOpp.Custom_Opportunity_Number__c,'222');
   
}
}

  • July 13, 2013
  • Like
  • 0