• sai.sf
  • NEWBIE
  • 498 Points
  • Member since 2011

  • Chatter
    Feed
  • 19
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 45
    Questions
  • 133
    Replies

Am writing a test class... The need is to include a field of a object which is lookup to itself..... How can I include?

 

 

If the field was lookup to some other object then I would have written something like this:

 

field =instance.id;

 

How to include a field which is lookup to itself?

 

Pls help.....

 

Abhijeet

Hi,

 

I am new to development with APEX, and while I familiar with how to test and deploy code with Eclipse, I was wondering if it is possible to test and deploy from the Developer Console (from our sandbox to our production org). 

 

If someone could post a link to a walk-through on this, if it is possible, I would be very grateful.  Thanks!

 

TCS

Hi,

 

   I am new to creating Force.com Sites. Can anyone advise me the steps to build the force.com sites.

 

Thanks!

Hi

 

When we clone an agreement, I want to create a field named ''Previous Agreement'' which shows the Agreement number of the record from which the present record has been cloned.

 

Can anyone please help me with the code to acheive this.

 

Thanks and Kind Regards

 

Finney

Hi,

   can i get the link open in new tab when i click on the case number right now it opens in the sametab but i want it to open up in other tab , here is my code

 

 <apex:column headervalue="Case Number">
            <apex:outputlink value="/{!c.Id}" >
            <apex:outputtext value="{!c.CaseNumber}"/>
            </apex:outputlink>
   </apex:column>

 

In the below query i want the results to be shown order by ownername and then the Estimation complete date right now it's only by Estimation complete date and idk how to order by both , any help?

 

if(para1=='Sam/Sam1/Sam2')
         return [select CaseNumber,Status,owner.name,subject,Estimated_Completion_Date__c,Complete__c,ClosedDate from Case
                 where ClosedDate = LAST_N_DAYS:7 and (owner.name ='Sam' OR owner.name ='Sam1' OR owner.name ='Sam2') order by Estimated_Completion_Date__c asc];

 

TIA!       

I have the following test Apex trigger on the Case Object.

 

trigger setCaseOwner on Case (before Insert)
{
Case x = trigger.new[0];

x.Description = 'TRIGGER FIRED' + User.Id ;
}

 

I'm trying to get the ID or Alias of the logged in user.  The script below displays TRIGGER FIREDId in the description field of the Case after saving.  I've also tried 'TRIGGER FIRED' + $User.Id and 'TRIGGER FIRED' + x.$User.Id which gives me syntax errors.  what's the easiest way to get information about the logged in user from within an Apex Trigger?

thx

 

 

 

In java we can extend the properties, can we do the same in case of apex

for eg: what if i want to override the properties of <apex:command button> to toggle button?

Here is my code where I am updating one picklist field to another picklist field but I am only achieving 50% code coverage. Please help.

 

Apex trigger:

 

trigger BusinessSegment on Opportunity (before insert) {  

   for(Opportunity op: Trigger.new){      

   if(op.Solution_Offering__c=='Debt Financing'||op.Business_Application__c=='Equipment Finance' ){       

      op.Use_Type_Class__c='Financing/Capital Raising';             

  op.Use_Type__c='Equipment Finance';      

   }     } } 

 

Apex class:

 

@isTest private class testMyBusinessSegment { Public static testMethod void testTBusinessSegment () {
Opportunity opp = new Opportunity();
opp.name = 'Test - New Mapping';

opp.Type = 'Transaction - New';

opp.Region__c = 'Americas';

opp.Template__c='Blocks';

opp.StageName = 'Propose';

opp.dlDealType__c = 'Micro Deal';
insert opp;
} }

Hi,

New with salesforce code:

I am having issues with getting a custom visual page to auto check a check box. I feel like this is happening because it is a custom page, and something needs to be added into the apex code to force a true value into the checkbox(I am not sure where) to do this. Here is what my apex code for this value looks like for the checkbox on this apex custom visual page:(Any help is much apprecciated thanks!)

        <apex:inputField value="{!Account_Request__c.Test_route__c}" required="false"/>
  • May 31, 2012
  • Like
  • 0

Hi All,

    I deployed this trigger to production but i get exception sometimes , recently am trying to assign campaigns from one user to other user by dataloader but it failed i got this error

 

Apex script unhandled trigger exception by user/organization: 00540000001RV3E/00D300000001a40

 

UpdateCount: System.LimitException: Too many SOQL queries: 101

 

Here is my trigger , please help me to avoid this exceptions

 

trigger UpdateCount on Campaign (after update,after insert) {

  Set<Id> recordIds = new Set<Id>();
  Set<Id> parentIds = new Set<Id>();
 
  for(Campaign c:Trigger.new)
   {
     //system.debug('--c.ParentId--'+c.ParentId);
     if(c.ParentId != null )
       {
         recordIds.add(c.id);
         parentIds.add(c.parentid);
         //system.debug('-------recordIds----'+recordIds);
         //system.debug('-------parentIds----'+parentIds);
   
       List <Campaign> cmpParent = [select id,ELOQUA__Emails_Sent__c,ELOQUA__Emails_Opened__c,ELOQUA__Possible_Email_Forwards__c,ELOQUA__Email_Click_Throughs__c,ELOQUA__Email_Bouncebacks__c,ELOQUA__Email_Unsubscribes__c,
       ELOQUA__Forms_Submitted__c,ELOQUA__Hypersite_Visits__c,ELOQUA__Event_Registrations__c,ELOQUA__Surveys_Completed__c,ELOQUA__Online_Referral_Visits__c from Campaign where id in :ParentIds limit 1];
         //system.debug('-------cmpParent----'+cmpParent);
         LIST<AggregateResult> ChildCmp = [select sum(ELOQUA__Emails_Sent__c)childsum,sum(ELOQUA__Emails_Opened__c)childsum1,sum(ELOQUA__Possible_Email_Forwards__c)childsum2,sum(ELOQUA__Email_Click_Throughs__c)childsum3,
         sum(ELOQUA__Email_Bouncebacks__c)childsum4,sum(ELOQUA__Email_Unsubscribes__c)childsum5,sum(ELOQUA__Forms_Submitted__c)childsum6,sum(ELOQUA__Hypersite_Visits__c)childsum7,
         sum(ELOQUA__Event_Registrations__c)childsum8,sum(ELOQUA__Surveys_Completed__c)childsum9,sum(ELOQUA__Online_Referral_Visits__c)childsum10 from Campaign where parentid in :ParentIds];
         //System.debug('ChildCmp: ' + ChildCmp);
         Decimal D = (Decimal)ChildCmp[0].get('childsum');
         Decimal D1 = (Decimal)ChildCmp[0].get('childsum1');
         Decimal D2 = (Decimal)ChildCmp[0].get('childsum2');
         Decimal D3 = (Decimal)ChildCmp[0].get('childsum3');
         Decimal D4 = (Decimal)ChildCmp[0].get('childsum4');
         Decimal D5 = (Decimal)ChildCmp[0].get('childsum5');
         Decimal D6 = (Decimal)ChildCmp[0].get('childsum6');
         Decimal D7 = (Decimal)ChildCmp[0].get('childsum7');
         Decimal D8 = (Decimal)ChildCmp[0].get('childsum8');
         Decimal D9 = (Decimal)ChildCmp[0].get('childsum9');
         Decimal D10 = (Decimal)ChildCmp[0].get('childsum10');
         //system.debug('--------D-------'+D+'-------D1----'+D1);
         //system.debug('------cmpParent[0].ELOQUA__Emails_Sent__c-----'+cmpParent[0].ELOQUA__Emails_Sent__c+'----'+ cmpParent[0].ELOQUA__Emails_Opened__c);
         if(cmpParent[0].ELOQUA__Emails_Sent__c!=null)
         cmpParent[0].Total_Emails_Sent__c = D + cmpParent[0].ELOQUA__Emails_Sent__c;
         else
         cmpParent[0].Total_Emails_Sent__c = D;
         
         if(cmpParent[0].ELOQUA__Emails_Opened__c!=null)
         cmpParent[0].Total_Emails_Opened__c = D1 + cmpParent[0].ELOQUA__Emails_Opened__c;
         else
         cmpParent[0].Total_Emails_Opened__c = D1;
         
         if(cmpParent[0].ELOQUA__Possible_Email_Forwards__c!=null)
         cmpParent[0].Total_Possible_Email_Forwards__c = D2 + cmpParent[0].ELOQUA__Possible_Email_Forwards__c;
         else
         cmpParent[0].Total_Possible_Email_Forwards__c = D2;
         
         if(cmpParent[0].ELOQUA__Email_Click_Throughs__c!=null)
         cmpParent[0].Total_Email_Click_Throughs__c = D3 + cmpParent[0].ELOQUA__Email_Click_Throughs__c;
         else
         cmpParent[0].Total_Email_Click_Throughs__c = D3;
         
         if(cmpParent[0].ELOQUA__Email_Bouncebacks__c!=null)
         cmpParent[0].Total_Email_Bouncebacks__c = D4 + cmpParent[0].ELOQUA__Email_Bouncebacks__c;
         else
         cmpParent[0].Total_Email_Bouncebacks__c = D4;
         
         if(cmpParent[0].ELOQUA__Email_Unsubscribes__c!=null)
         cmpParent[0].Total_Email_Unsubscribes__c = D5 + cmpParent[0].ELOQUA__Email_Unsubscribes__c;
         else
         cmpParent[0].Total_Email_Unsubscribes__c = D5;
         
         if(cmpParent[0].ELOQUA__Forms_Submitted__c!=null)
         cmpParent[0].Total_Forms_Submitted__c = D6 + cmpParent[0].ELOQUA__Forms_Submitted__c;
         else
         cmpParent[0].Total_Forms_Submitted__c = D6;
         
         if(cmpParent[0].ELOQUA__Hypersite_Visits__c!=null)
         cmpParent[0].Total_Hypersite_Visits__c = D7 + cmpParent[0].ELOQUA__Hypersite_Visits__c;
         else
         cmpParent[0].Total_Hypersite_Visits__c = D7;
         
         if(cmpParent[0].ELOQUA__Event_Registrations__c!=null)
         cmpParent[0].Total_Event_Registrations__c = D8 + cmpParent[0].ELOQUA__Event_Registrations__c;
         else
         cmpParent[0].Total_Event_Registrations__c = D8;
         
         if(cmpParent[0].ELOQUA__Surveys_Completed__c!=null)
         cmpParent[0].Total_Surveys_Completed__c = D9 + cmpParent[0].ELOQUA__Surveys_Completed__c;
         else
         cmpParent[0].Total_Surveys_Completed__c = D9;
         
         if(cmpParent[0].ELOQUA__Online_Referral_Visits__c!=null)
         cmpParent[0].Total_Online_Referral_Visits__c = D10 + cmpParent[0].ELOQUA__Online_Referral_Visits__c;
         else
         cmpParent[0].Total_Online_Referral_Visits__c = D10;
         
         update cmpParent;
     
    }
  }
}

Hi guys,

 

Does anyone have a sample code to automatically add all NEW users to a specific Public Group?

 

Thank you!:)

Hi,

 

SInce I'm new to Apex development, I'm not quite sure how to handle a UTC datetime like '2012-04-23T14:54:29+05:30' . I just wanted to display the above value as Apr 23, 2012 2:54 PM to the user.

 

I tried datetime.getInstance('2012-04-23T14:54:29+05:30') and it threw an error saying "Invalid Date/Time" . 

Any pointers on how to use the datetime class to do the above task can be helpful. Thanks. 

 I'm trying to display the contract owner field which is a lookup field under the contract standard field.  All that appears is the ID instead of the name.  How do I fix this?

Prepared by: {!Contract.Owner}<br />

 

Then I tried this code and received the error: "Expression Values does not resolve to a field."

 

Prepared by: <apex:outputField value="{!Contract.Owner}"/>

 

Any help would be greatly appreciated.  Thank you.

This is probably a dumb question, but where is the products page ? I see from looking under my apps > customize > products , that there is indeed a product object but I can figure out how to get to it. I assumed that there was a page very similar to opportunity, lead, and account that would let you edit/view a list of products, but I can't seem to locate it.

 

I did, however see that you can add a product to an opportunity, although it asks me to choose a price book but there are none. Where do I add a pricebook ?

Hi All,

 

If current user is belongs to queue of the record or not else throws alert  in javascript..How to determine current user !=Queueof record in javascript.I am using this Js in custom button

 

 

Thanks

 

 

  • January 23, 2013
  • Like
  • 0

Hi,

 

     Is there any way to have minimum character limit on rich text area field (say min 200 characters).I have this field on visualforce page.

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

 

Thanks

  • January 11, 2013
  • Like
  • 0

Hi,

 

     Is there any way to have minimum character limit on rich text area field (say min 200 characters).I have this field on visualforce page.

 

Thanks

  • January 10, 2013
  • Like
  • 0

I am getting this error in batch apex  "DML operation on setup object is not permitted after you have updated a non-setup object  ".


How to fix this.

  • October 17, 2012
  • Like
  • 0

HI All,

 

 How to collect the failed record ids from database.saveresult.

  • October 16, 2012
  • Like
  • 0

Hi All,

 

what is the difference between account team,public group and roles in salesforce.

 

Thanks

  • October 09, 2012
  • Like
  • 0

Hi,

 

 I need to check whether a field of type string contains only number in trigger.Is there any method?

 

Thanks

  • September 28, 2012
  • Like
  • 0

Hi All,

 

  I have installed salesforce mobile app on my iphone.I want to test some functionality on my sandbox.How to do this?

 

Thanks

  • September 27, 2012
  • Like
  • 0

Hello All,

 

  I want to get ready for Dev501. Please advice me from where I should study and if there is any sample questions as well.

 

Thanks

  • September 11, 2012
  • Like
  • 0

Hi All,

 

  I am able to create a new user through apex but the user is not receiving an password confirmation email.Any thoughts?

 

 

Thanks

  • August 21, 2012
  • Like
  • 0

trigger UpdateUser on CustomObject__c(before insert) {
 list<CustomObject__c> clist = new list<CustomObject__c>();
 String[]uId = new String[]{};
 for(CustomObject__c e: trigger.new){
    uId.add(e.MID__c);
   }
 
 map<Id,User> umap  = new map<Id,User>([Select u.Emp_ID__c, u.Id From User u where u.Emp_ID__c in:uId]);
 
 
 map<String,Id> umap2 = new map<String,Id>();
 
 for(User u:umap.values()){
     umap2.put(u.Emp_ID__c,u.Id);
 }
 
 
  for(CustomObject__c e: trigger.new){
    if(umap2.containsKey(e.MID__c)){
       
          e.User__c = umap2.get(e.MID__c);
         }
         else
         {
             clist.add(e);
         }
  }
 Map<String, String> mid_cid = new Map<String, String>();
 Map<String, CustomObject__c> mid_obj = new Map<String, CustomObject__c>();
 Map<String, Account> cid_account = new Map<String, Account>();
 List<User> newUserList = new List<User>();
 
  for(CustomObject__ce:clist){
      mid_cid.put(e.mid__c,e.Cost_Center__c);
      mid_obj.put(e.mid__c,e);
  }

  List<Account> alist = [Select a.Role_ID__c, a.Name, a.Id, a.Cost_Center__c From Account a where a.Cost_Center__c in : mid_cid.values()];

  for(Account acc:alist){
      cid_account.put(acc.Cost_Center__c,acc);
  }


  for(CustomObject__c e:clist){
 
      String emailAddr =e.Email_Address__c;
      
      User u = new User(FirstName=e.First_Name__c,
                        LastName=e.Last_Name__c,
                        Alias=e.First_Name__c.substring(0,1)+e.Last_Name__c.substring(0,3),
                        email= e.Email_Address__c,
                        UserName=e.Email_Address__c,
                        CommunityNickname= emailAddr.split('@')[0],
                        ProfileId='00eQ0000000M59D',
                       UserRoleId = cid_account.get(e.Cost_Center__c).Role_ID__c, // if i comment this line then its working
                       Branch__c = cid_account.get(e.Cost_Center__c).Name,
                       languagelocalekey='en_US',
                     localesidkey='en_US',
                     timezonesidkey='America/New_York',
                     emailencodingkey='UTF-8',
                     Emp_ID__c= e.MID__c);
    newUserList.add(u);
    }
  insert newUserList;
}

 

 

when iam trying to create new custom object record.iam getting following error.

 

 Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger UpdateUser caused an unexpected exception, contact your administrator: UpdateUser: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): User, original object:  CustomObject__c: []: Trigger.UpdateUser: line 70, column 1

  • August 17, 2012
  • Like
  • 0

Is it possible to create user from apex code(batch apex) and also insert the permission set  and then send an email to the user

  • August 10, 2012
  • Like
  • 0

Hi All,

  

     I need to find out the string contains in set of string.Please give me some example.

 

 

Thanks

Hi All,

 

 I have two after insert triggers on sameobject.I want to know which one will execute first?

 

Thanks

Hi All,

  

   sforce.connection.query('Select Name,Id from Account where Name=xyz') returns only records that are accesseble to user in button.So the query returns not same results to all users.how to retreive all records from the query?

 

Thanks

 

Hi All,

 

 Soql in ajax button is not giving same results for all users.Any Thoughts?

 

Thanks

Hi All,

 

 soql in my class gives no records for some users whereas for sys admin we will get the record.Is that the user should have an access to a record ?Please help.

 

Thanks

Hi All,

 

   I need to replace single quotes from text field with empty string in formula field like Sam's to Sams

 

Thanks

Hi All,

 

   I need to replace single quotes from text field with empty string  in formula field like Sam's to Sams

 

Thanks

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_merge.htm

 

According to above link we can only use Merge statement for accounts,contacts and leads.I need to merge custom object records.Any help?

 

Thanks

Hi,

 

     Is there any way to have minimum character limit on rich text area field (say min 200 characters).I have this field on visualforce page.

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

 

Thanks

  • January 11, 2013
  • Like
  • 0

Hi,

 

     Is there any way to have minimum character limit on rich text area field (say min 200 characters).I have this field on visualforce page.

 

Thanks

  • January 10, 2013
  • Like
  • 0

I need to show a Custom message on Visualforc Page.

 

VF Page

<apex;page standard controller="contact">

<b>You can find documents in{!custom}  to send to clients here</b>

</apex:page>

 

My custom setting is 

Object name : Help Text

Type : Hierarchy

Field ; Message default value "SMART"

 

The custom value should change when the user change the default value in any org

 

Kindly help.

I am getting this error in batch apex  "DML operation on setup object is not permitted after you have updated a non-setup object  ".


How to fix this.

  • October 17, 2012
  • Like
  • 0

HI All,

 

 How to collect the failed record ids from database.saveresult.

  • October 16, 2012
  • Like
  • 0

Hi,

 

 I need to check whether a field of type string contains only number in trigger.Is there any method?

 

Thanks

  • September 28, 2012
  • Like
  • 0

Hi All,

 

  I have installed salesforce mobile app on my iphone.I want to test some functionality on my sandbox.How to do this?

 

Thanks

  • September 27, 2012
  • Like
  • 0

Hi,

 

Can u tell me what is the relation between pricebook and product? 

Hi,

 

I'm using the PageReference getContent method to retreive the contents of a visualforce page. In the visualforce pages controller I set some cookies. I would like to retrieve the cookies that were set in the visualforce page. Is there anyway to do this? 

 

Thanks!

Scott

  • September 18, 2012
  • Like
  • 0

I need to implement the following scenarios in Lookup Relationship.

 

Scenario1-

 

We have one Object say like "A" it has three child objects say "B1", "B2", "B3" associated with Lookup Relationship.

There is a field named "Grand Revenue" on object  "A" and all three fields named "Revenue" on objects "B1" , "B2", "B3".

 

We need to implement

"Grand Revenue"= "Revenue"+"Revenue"+"Revenue" on A(Parent).

 

Scenario2-

 

If we delete one records on "A" all associated records should be deleted from childs "B1", "B2", "B3".

 

Could anyone please suggest how to achieve it.

 

Thanks for your suggestions.

 

Thanks,

JaanVivek

 

 

We have a custom object called Deal_Desk_Form__c which is in a master-detail relationship with Opportunity. I'm trying to write a trigger that updates a field on the Opportunity based on a field on the Deal_Desk_Form__c. This is my current code:

trigger MasterDDValidation on Deal_Desk_Form__c (before insert,before update) {

 
//create list of Opportunity IDs
List<ID>OppIDs = New List <ID>();
for(Deal_Desk_Form__c dd: Trigger.new){
    OppIDs.add(dd.Opportunity__c);
    }

//get Deal Desk Ids + Version Type
List<Deal_Desk_Form__c>DDform=[SELECT Id, VersionType__c, Opportunity__c FROM Deal_Desk_Form__c WHERE Id in: Trigger.new];
   
//create list of opportunities to iterate on
List<Opportunity> OppUpdateList = [SELECT Id, HasMasterDDForm__c FROM Opportunity WHERE id in: OppIDs];
          
    for(integer i=0; i < OppUpdateList.size(); i++){
        if(DDform.VersionType__c == 'Master Terms'){
        OppUpdateList[i].HasMasterDDForm__c += 1;}
       
        if(DDform.VersionType__c != 'Master Terms'){
        OppUpdateList[i].HasMasterDDForm__c +=0;}
}
}
update OppUpdateList;        
}

 

Right now I'm getting the error message: Compile Error: unexpected token: update at line 24 column 0. 

 

Do I need some sort of map to relate the Opportunity to the Deal Desk Form? Thank you so much for any help you can offer!

  • September 17, 2012
  • Like
  • 0

I have created a page which performs a search and displays the matching records using List by a pageblocktable.

 

Along with the records names,I need to show some dummy percentage values assoicated to these records.I tried displaying the data using for loop,but all the records are getting displayed with same percentage.

<apex:column headerValue="Account">
<apex:outputLink value="/{!a.Id}" target="_blank">{!a.Name}</apex:outputLink> {!percentage} % Match
</apex:column>

I have created accList which performs my search

 

Public Integer percentage{get;set;}

for(Account acc:accList)
{
percentage=78;
}

. How to display different values for each record using pageblocktable.

 

Thanks,

prasanna

 

HI,

 

 i declared the class as well as the variables as global still i am unable to view my page. 

 

The code,

 

 

VisualForce:

 

<apex:page Controller="newpage1">
<apex:pageBlock >

<apex:pageBlockSection >

<Apex:pageblocktable value="{!leadrec}" var="l">
<apex:column value="{!l.Name}" />
<apex:column value="{!l.Email}" />
</apex:pageblocktable>
</apex:pageBlockSection>

</apex:pageBlock>
</apex:page>

 

apex:

 

global class newpage1 {

global list<lead> leadrec{get;set;}
global newpage1()

{
leadrec=[select Name,Email from lead limit 10 ];

}
}

Am writing a test class... The need is to include a field of a object which is lookup to itself..... How can I include?

 

 

If the field was lookup to some other object then I would have written something like this:

 

field =instance.id;

 

How to include a field which is lookup to itself?

 

Pls help.....

 

Abhijeet

Hi All,

 

  I am able to create a new user through apex but the user is not receiving an password confirmation email.Any thoughts?

 

 

Thanks

  • August 21, 2012
  • Like
  • 0

Do we have any design pattern for salesforce data(model) accessing.

 

In .NET we do have enterprise library to access the data model.. here we have such design patterns

Hi

 

I need to use the "UserRecordAccess" in Apex Trigger in order to get the User permission on the Record,is it possible to use this in Trigger.

 

I have used the  UserRecordAccess in the Trigger while updating the record to get the User Permission on that record,but I am unable to get these lines of code executed.

 

 

If any one know about this,please help me.

Any body get this error before ? Any solution...I know it is about person account but ı do not figure out how Iam going to fix...

I ve already checked to profile setting for record types.

 

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Account: bad field names on insert update call: Name: [Name]

Hi All 

 

Here is my question . If we are inserting Users  in  Salesforce with all mandatory fields then how is the password generated. Can we have our desired password and insert the Users.

 

Second question : How do we delete users in through Data Loader. 

and how do I schedule the Data Loader?