• Tej
  • SMARTIE
  • 624 Points
  • Member since 2011

  • Chatter
    Feed
  • 22
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 49
    Questions
  • 149
    Replies
I have a trigger on a custom object called Launch Checklist that is supposed to use a unique identifier to look up another custom object called App and that App's Account based on an ID field.  When I edit and save a single record, everything works swimmingly.  When I try to force a bulk upload (through Data Loader or Anonymous Apex), the Trigger just doesn't seem to fire at all, or worse, it associates the wrong app/account.

Again, though, if I save a single record with the wrong info, without making any changes, the association occurs correctly.  I've spent time to ensure my trigger is bulkified.  Can anyone help identify what I'm doing wrong?  Code is below.

trigger LaunchChecklist on Launch_Checklist__c (before insert, before update) {
    
    String appId = Null;
    Map <String, App__c> mapApp = new Map <String, App__c> ();
    
    for(Launch_Checklist__c lc: Trigger.new) {
        if (lc.Apple_ID__c != Null) {
            appId = lc.Apple_ID__c;
        } else if (lc.Package_Name__c != Null) {
            appId = lc.Package_Name__c;
        }
    }

    List<App__c> apps = new List<App__c>([select App_ID__c, Account__c from App__c where App_ID__c = :appId limit 1]);
    
    if (apps.size() > 0) {
        for (App__c app: apps)  {
        	mapApp.put(app.App_ID__c, app);
    	}
        for(Launch_Checklist__c lc: Trigger.new) {
            lc.Account__c = mapApp.get(appId).Account__c;
            lc.App__c = mapApp.get(appId).Id;
    	}
    }
}


I debugged a collection type List in the apex and I am expecting to see a total of 20 elements in that list. But I can see only 10 and after the 10th element there are few dots(.......) meaning that there are other elements but those are not displyed. how to view those elements as well,

Thanks.

Hi,

 

I am trying to retrieve history of field Salary at my custom object Employee. I am using the following query :-

 

List<Employee__c> lstEmp=[SELECT Id,Salary__c,
                          (SELECT OldValue,NewValue, FROM Histories)
                          FROM Employee__c                        
                         ];

Now I need to retrieve a particular field only which is salary, I do not want other fields tracking details and I need to get date at which the change is made. Please let me know how should i modify my query and if you have the link to the documentation of history object present in salesforce please post that.

 

 

Thanks in advance....

i first save a project from eclipse to my dev org that project contain a custom application. it is showing app when i go to Create>Apps but when i click on the right hand side to Help for selecting a custom app it is not showing that app.How to select this custom app please guideline!!

 

Hi quick question,

 

does anybody know if it is possible to set the ownership of a record using the CreatedBy field? Because the createdby is not populated until the record is inserted a before insert would not work, I dont think. 

 

Is it commonplace to use an after insert to update the same record being inserted? 

 

Thanks! 

Hi!

 

I have a table with data that needs to be redirected to other page when clicked.

 

Each row has links to other pages.

 

Please let me know how can I display  a specific detail page when I click a specific column.

 

Thanks..

  • February 25, 2013
  • 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

Is it possible to prevent a custom object from appearing in the SF "Add New" home page component?

Hi All

 

     would you loke to tell how to delete custom portal user ....  ?

 

 

Thanks

asish

 

 

 

 

I am attempting to create a view on Cases of cases that I have created who are owned by someone other than myself.

 

My thought is to check the 'My Cases' radio button, but that won't work since it says 'Filter by Owner'

 

This view needs to be seen by my entire Customer Care team so it needs to work for each of them. Any ideas?

Hi How a image should be a clickable image and it should do some operation on background when ever it is clicked. and update another field on the same object . 

Hi all,

 

I am trying to build a VisualForce page that would check certain fields for data validity before inserting.  I believe I want to use a validation rule for this.

 

How am I able to mimic the standard functionality of a validation error message appearing below the associated field?

 

Currently the insert statement in my apex controller throws a DML error referencing the validation rule I have set up for the first field that needs one.  This error does not go underneath the field as I told it to do in the validation rule, it redirects to a seemingly new page that is 100% comprised of the DML error.  How can I handle this properly, or rather make it behave like the standard intended functionality?

 

Thanks

Hi Everyone,, 

 

I'm trying to remove a lead record type that's not used any longer...but I seem to be encountering the following error:

 

"This record type RVP cannot be deleted because the following profiles use this record type as default. External Who"  

 

Can anyone PLEASE explain to me why this is the case? I don't have a profile called "External Who"!!! Thanks so much for the help! 

 

Regards, 

 

Studzey

i can't deploy code to production because production has 63% coverage, and the class with 0% coverage is this.

 

http://appexchange.salesforce.com/listingDetail?listingId=a0N30000003JEIpEAO

 

how do i get past this? this is an app that was downloaded to production from the appexchange... i dont have the slightest idea how to start test coverage.

 

public with sharing class MassReassignOpportunitiesController {
  public ApexPages.StandardSetController optySetController;
  public String filterId {get;set;}
  public String ErrorMsg {get;set;}
  public String optyQueryString;
  public List<cOpty> optyList {get;set;}
  public list<Opportunity> optyToUpdateList {get;set;}
  public Opportunity searchRecord {get;set;}
  public Reassign_Helper__c helperRecord{get;set;}
  public boolean isSuccess{get;set;}
  public boolean searchPerformed{get;set;}
  public boolean tooManyResults{get;set;}
  
  public Integer optyListSize {get{return optylist.size();}}
  public list<SelectOption> listviewoptions {
    get{
      List<SelectOption> tempList = new List<SelectOption>();
      tempList.add(new selectOption('None',System.Label.NoViewSelection));
      if (optySetController<>null)tempList.addAll(optySetController.getListViewOptions());
      return tempList;
      }
  }

  public MassReassignOpportunitiesController(){
    
    //Variable Init
    optyQueryString = 'SELECT name,StageName,Ownerid,CloseDate from Opportunity where isDeleted=false';
    optyList = new List<cOpty>();
    optySetController = new ApexPages.Standardsetcontroller(Database.getQueryLocator(optyQueryString+' limit 1000'));
    filterId = listviewoptions[0].getValue();
    searchRecord = new Opportunity();
    helperRecord = new Reassign_Helper__c();
    isSuccess=false;
    searchPerformed = false;
    tooManyResults= false;
    
    //Apply the default filter
    //refreshOptyList();
  }
  
  /*========================================
  Applies the View filter to the Opty List
  ==========================================*/ 
  public void refreshOptyList(){
    list<Opportunity> testList = new list<Opportunity>();
    
    optyList.clear();
    isSuccess = false;
    tooManyResults = false;
    if (filterId <> null && filterId<> 'None'){
       optySetController.setFilterId(filterId);
       testList = (list<Opportunity>)optySetController.getRecords();
       searchPerformed = true;
    } else searchPerformed = false;
    System.debug('Filter used=>'+filterId);
    System.debug('Result #=>'+optySetController.getResultSize());
    Integer counter=0;
    for (Opportunity opty:testList){
      optyList.add(new cOpty(Opty));
      counter++;
      if (counter==999){
        tooManyResults=true;
         break;
      }
    }
    

    
  }
  
  public void refreshOptyListBySearch(){
    optyList.clear();
    isSuccess = false;
    
    //resultList = new List<cResult>();
    String userFilterQuery='';
    if (searchRecord.Name<>null)   userFilterQuery = ' and Name like \'%'+searchRecord.Name+'%\'';
    if (searchRecord.Type<>null)   userFilterQuery += ' and Type = \''+searchRecord.type+'\'';
    if (searchRecord.StageName<>null)   userFilterQuery += ' and StageName = \''+searchRecord.StageName+'\'';
    if (helperRecord.From__c<>null){
        DateTime startDate = DateTime.newInstance(helperRecord.From__c, Time.newInstance(0, 0, 0, 0));
         userFilterQuery += ' and CreatedDate >= '+startDate.format('yyyy-MM-dd')+'T00:00:00Z';
         
    }
    if (helperRecord.To__c<>null){
        DateTime endDate = DateTime.newInstance(helperRecord.to__c, Time.newInstance(0, 0, 0, 0));
         userFilterQuery += ' and CreatedDate <= '+endDate.format('yyyy-MM-dd')+'T00:00:00Z';
    
    }
    if (helperRecord.closedDate_From__c<>null){
        DateTime startDate = DateTime.newInstance(helperRecord.closedDate_From__c, Time.newInstance(0, 0, 0, 0));
         userFilterQuery += ' and CloseDate >= '+startDate.format('yyyy-MM-dd');
         
    }
    if (helperRecord.closedDate_To__c<>null){
        DateTime endDate = DateTime.newInstance(helperRecord.closedDate_to__c, Time.newInstance(0, 0, 0, 0));
         userFilterQuery += ' and CloseDate <= '+endDate.format('yyyy-MM-dd');
    
    }
    
    String optyQueryString =optyQueryString +  userFilterQuery ;
    optyQueryString += ' order by Name limit 1000';
    
    List<Sobject> sortedResults= new List<SObject>();
    try{
      sortedResults = Database.query(optyQueryString);
      searchPerformed = true;
    } catch (Exception e){
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
    }
    System.debug('Requete => '+optyQueryString);

    for (SObject foundObject:sortedResults){
      Opportunity opty = (Opportunity)foundObject;
      optyList.add(new cOpty(opty));    
    }
  }
  
  
  /*===============================================
  Assign the selected opportunities to a new owner
  =================================================*/
  public void Assign(){     
        list<Opportunity> optyToUpdateList=new list<Opportunity>();
        list<Task> taskToUpdateList=new list<Task>();
        list<Event> eventToUpdateList = new List<Event>();
        for (cOpty opty:optyList)
            if (opty.selected)
                optyToUpdateList.add(new Opportunity(id=opty.oOpty.id, OwnerId=helperRecord.Assign_to__c));

        
        //We also need to reassign the open activities to the new owner
        //To do so, we first loop on all the opportunities to retrieve their Open Activities
        //Then we loop through the Task or Events and reassign them
        for(Opportunity tempOpty:[select id,(select id,isTask from OpenActivities order by ActivityDate DESC, LastModifiedDate DESC limit 500) from Opportunity where id in :optyToUpdateList]){
          for (OpenActivity tempActivity:tempOpty.OpenActivities){
            if (tempActivity.IsTask) taskToUpdateList.add(new Task(id=tempActivity.id,ownerId=helperRecord.Assign_to__c));
            else EventToUpdateList.add(new Event(id=tempActivity.id,ownerId=helperRecord.Assign_to__c));
          }
        }
        
        if (optyToUpdateList.size()+taskToUpdateList.size()+eventToUpdateList.size()>=10000) {
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, System.Label.TooManyRowsError));
        } else{
        
          try
          {
              update optyToUpdateList;
          }
          catch (Exception e)
          {
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
          }
          
           try
          {
              if (taskToUpdateList.size()>0) update taskToUpdateList;
              if (eventToUpdateList.size()>0) update eventToUpdateList;
          }
          catch (Exception e)
          {
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
          }
        
          // Update the search results
          integer n=optyList.size();
          for (integer i=n-1;i>=0;i--){
              if (optyList[i].selected) optyList.remove(i);
      }
      
      if (optyToUpdateList.size()>0) isSuccess = true;
        }    
  }
  
  /*==================================================
  Inner class helping identify selected opportunities
  ====================================================*/
  public class cOpty{
    public Opportunity oOpty {get;set;}
    public Boolean selected {get;set;}
    
    public cOpty(Opportunity oOpty){
      this.oOpty = oOpty;
      selected=false;
    }
    
  }
  
  
  public static testmethod void testReassign(){
    
    Account testAccount = new Account();
    testAccount.Name = 'test';
    insert testAccount;
    
    Opportunity testOpty = new Opportunity();
    testOpty.StageName = 'Discover';
    testOpty.CloseDate = System.today()+1;
    testOpty.AccountId=testAccount.Id;
    testOpty.Name='testOpty';
    testOpty.Type = 'testType';
    insert testOpty;
    
    MassReassignOpportunitiesController controller = new MassReassignOpportunitiesController();
    controller.refreshOptyList();
    controller.filterId = controller.listviewoptions[1].getValue();
    controller.refreshOptyList();
    controller.searchRecord.stageName = 'Discover';
    controller.helperRecord.ClosedDate_From__c=System.today();
    controller.helperRecord.ClosedDate_To__c=System.today()+2;
    controller.helperRecord.From__c=System.today();
    controller.helperRecord.To__c=System.today()+1;
    controller.searchRecord.Type = 'testType';
    controller.refreshOptyListBySearch();
    
    System.assert(controller.optyList.size()>0);
    
    controller.optyList[0].selected = true;
    controller.helperRecord.Assign_to__c = UserInfo.getUserId();
    controller.Assign();
    
    
    
  }
  
  

}

 

 

 

 

Hello there,

 

I have been reading some posts on this great forum and it seems like one can perform field colouring, I still do not find the syntax that I should use, so can somebody please tell me how to do this. I'm looking for the syntax to add colours without any condition and to add colour WITH conditions like if field = 'x' then red...

 

Any thoughts???

 

Cheers,

 

JAB

Hi,

 

I wish to determine if there are specific URL's contained across the board within our custom buttons & custom links in our SFDC environment. Is there a way to search these objects/links?  I've been able to search through classes, triggers, pages, components..... using the Force.com IDE but I wondered if I could search through other such custom developed settings?

 

Similar to this, Can I search for content contained within Custom Components such as a HTML Area?

 

Thanking you in advance.

This is such a simple idea and it is killing me that I can't figure it out.  I have APEX in place that automatically creates a campaign.  What I am trying to do is get todays date and extract the year into the name of a campaign.  In othewords, I want the campaign name to read "YYYY - Campaign Name".

 

I would love to see some documentation on this, but I can't find anything regarding APEX methods.  Can someone please help me??  

we are having multiple issues with summer14 release.

1)our org test coverage dropper to 68% all of sudden, it was fine for couple of days after the release because we aere able to put some patches, but suddenly we started having issues. 
Is there anything changed how the org test coverage is calculated????

2)visual work flow was broken, we did a small change and activated the flow and recieving some internal soap error.

is anybody else having similer issues
  • July 16, 2014
  • Like
  • 0
can we put a commandlink in apex error message?

when user gets an error message it contain a clickable content/commandlink ,which should open a popup with instructions.

is it possible to add commandlink in errormessage??
  • June 26, 2014
  • Like
  • 0
how to build map<String, list<list<string>>>..

Thank you.
  • June 17, 2014
  • Like
  • 0
Can we achive below format in a vf page.

I have a long list of strings that needs to be displayed in a table and the user should be able to select them. 
since there are only 2 columns can we wrap them in below format so we can avoid a lot of scrolling.
Thanks,
User-added image


  • June 09, 2014
  • Like
  • 0
i have a commandlink in a pbtable, that should change color conditionally. I am doing something like below but it complains about "Error Error: Syntax error. Missing ')'". any ideas?

<apex:commandlink value="test" action="{!testaction}" style="{!IF(testMap.get(rowId).size > 0, 'background:red;color:white', '')}">
  • April 11, 2014
  • Like
  • 0
i have a list of records that i have to show in a matrix/grid view.
some thing like below. i have labels on rows and columns and i should present the data in such a way that where a record have that combination i should put a star there. so user can click on it and open another page to see the record related to that row and column combo.for ex B and IL star.
this is something new and i am struggling to get it done. does anybody did anything similer?
 User-added image
  • April 10, 2014
  • Like
  • 1
i have a list of records which are displayed in a page block table. one of whic is a command link. if i click on it, will open the right record but if i right click on it, it's opening the same record again andagain.

<apex:column>
<apex:commandLink value="View" action="{!viewRecord}">
            <apex:param value="{!record.Id}" name="RowId" assignTo="{!RowId}"/>
        </apex:commandLink>
       
    </apex:column>

public Pagereference viewRecord(){

       
        PageReference ref = new Pagereference('/apex/mypage?id='+RowId);
        ref.getParameters().put('Id',RowId);
   
        return ref;

    }

what am i doing wrong...
  • February 28, 2014
  • Like
  • 0
I have a requirement where there is a list of strings which is quite big, around few thousands. but need to be displayed in different lines and could be able to export/ take print etc...
please check the below image for reference.

please help.

 User-added image
  • February 10, 2014
  • Like
  • 0

This functionality is working for a very long time and it stopped recently not sure why.

 

we have to create a user through apex and grant them customer portal access and they should be recieving a welcome email with their login credentials.

 

Please take a look at our existing code. Its' giving them the portal access but not sending the email,

 User portalUser = new User();
            portalUser.Alias = con.Name.substring(0,2)+ultility_GlobalFunctions.generateRandomString(3);
            portalUser.Username = con.Email;
            portalUser.FirstName = con.FirstName;
            portalUser.LastName =  con.LastName;
            portaluser.CommunityNickname = con.Name.substring(0,2)+ultility_GlobalFunctions.generateRandomString(5);            
            portalUser.Email = con.Email;
            portalUser.Cost_Center__c = 'None';
            portalUser.Country = 'USA';
            portalUser.Region__c = 'AMER';
            portalUser.ContactId = con.Id;
            portalUser.ProfileId = [select Id from profile where Name= 'Manager'].Id;
            //portalUser.UserRoleId = [select Id from UserRole where Name = :recordtype].Id;        
            portalUser.emailencodingkey='UTF-8';
            portalUser.languagelocalekey='en_US';
            portalUser.localesidkey='en_US';
            portalUser.timezonesidkey='America/New_York';
            
            Database.DMLOptions dlo = new Database.DMLOptions();
            dlo.EmailHeader.triggerUserEmail = true;
            dlo.EmailHeader.triggerAutoResponseEmail= true;
                
            
            try{
                portalUser.setOptions(dlo);         
                insert portalUser;     
     
            }catch( exception ed){              
            
            }  

 Please help...

  • November 12, 2013
  • Like
  • 0

i am using database.upsert to update/insert a large volume of records into salesforce assuming that database.upsert have the advanatge - if one record in the bunch errors out, the rest of the operation will continue.

 

but its not the case, if one record fails the whole transaction is failing.

 

and also using the save result method is there any way i can capture which records are failing and send an email or something.

these records are coming from an external system.

 

 

  • September 13, 2013
  • Like
  • 0

What is the size limit of response from a webservice call.

 

i found this in governor limits, does it matter which format the response in?

 

Maximum size of callout request or response (HTTP request or Web services call) 3 MB

 

appriciate your help.

  • July 11, 2013
  • Like
  • 0

i couldn't find reset my security token option in my summer 13 sandbox, what happend?

  • July 03, 2013
  • Like
  • 0

I created a trigger to update a field in Case to either New or Read based on attached emailmessages status.

 

if there are any new emails attached to case, the case email status should be "new".

 

If there are no New emails the case email status should be "Read".

 

everything is working fine except, the trigger is not getting fired when they open the new email to read, the emailmessage status is getting updated from New to Read, but the trigger is not getting fired to update the case email status.

 

please check the below code.

trigger CaseEmailStatusUpdate on EmailMessage (after insert, after update) {

	ID caseId;
	list<EmailMessage> emails = new list<EmailMessage>();
	set<string> status =  new set<String>();
	Case c = new Case();

	
	for( EmailMessage e : trigger.new){
	
		caseId = e.ParentId;
	}
	
	emails = [ SELECT Id, ParentId, Status, Subject FROM EmailMessage where parentId = :caseId];
	c = [ Select Id, Case_Email_Status__c From Case where Id = :caseId];
	
	for( EmailMessage e : emails){
			
			status.add(e.Status); 
		
	}
	
	if(status.size() > 0 && status.Contains('0')){
	
		c.Case_Email_Status__c = 'New';
		
	}else if (status.size() > 0 && !status.Contains('0')){
	
		c.Case_Email_Status__c = 'Read';
		
	}
	
	update c;
	
	
}

 

  • March 27, 2013
  • Like
  • 0

Hi I have lengthy custom form, wher user can upload some docs,when he uploads the vf pafe refreshes and shows the list of docs uploaded and the statuses in different section changes.

 

but when the user submits, the page gets refreshed it gng to the top of the page , but i want that to scroll down to the section wher he is wrking automatically.

 

i found the snippet of java script function which works fine on page load, but i want it to happen conditionally

 


<script>
function Scrolldown() {
window.scroll(0,500);
}
window.onload = Scrolldown;
</script>

 

below is my command button

 

 <apex:commandButton value="  Submit  " action="{!docSubmit}" onclick="return confirmSubmit()" />

 

i added the oncomplete to my button and called the js function it didnt work.

 

I am kind of struck now.

 

  • February 11, 2013
  • Like
  • 0

With the new apex test execution, i cant see the coverage of  a single test class am working on and what are the lines covered/not covered.

 

how can i get that info with this new spring 13?

  • February 11, 2013
  • Like
  • 0

when the record gets aproved, we need to send an email with approval comments.

 

i created a visualforce email template, visualforce component and controller.

 

when i test it from email template from the button - "Send Test And Verify Merge Fields" everything working fine, but in real transaction the comments are coming empty.

attached is the code.

Any body dealt with this kind of req? Please help

 

Component:

<apex:component controller="JCApprovedEmailTemplate" access="global" >
    <apex:attribute name="jcId" assignTo="{!jcId}" type="String" description="ID of JobCode"/>
    
    
<apex:dataTable value="{!approvalSteps}" var="step">

        <apex:column value="{!step.Comments}"/>
    </apex:dataTable>
</apex:component>

 

Controller:

public class JCApprovedEmailTemplate {
	
	public String jcId { get; set; }
	
	public list<ProcessInstanceHistory> getApprovalSteps() {
		
		system.debug('------------------------------jcID--------------'+jcId);
		
      if (jcId != null) {
      	
       Job_Code__c jc = [Select Id, (Select TargetObjectId, SystemModstamp, StepStatus, RemindersSent, ProcessInstanceId, OriginalActorId, IsPending, IsDeleted, Id, CreatedDate, CreatedById, Comments, ActorId From ProcessSteps order by SystemModstamp desc limit 1) from Job_Code__c where Id = :jcId ];
		
		system.debug('------------------------------jcID--------------'+jc);
		system.debug('------------------------------jc.ProcessSteps--------------'+jc.ProcessSteps);
		return jc.ProcessSteps;
      }
      
      return new List<ProcessInstanceHistory> ();
    }
    
    
     
}

 

Visual Force Email Template:

<messaging:emailTemplate subject="Notice of Approved Job Code Request" recipientType="User" relatedToType="Job_Code__c">
<messaging:HtmlEmailBody >

<html>
<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
    <meta name="Template" content="Response"/>
 <p>  A request for a Job code update {!relatedTo.Job_Title__c} was approved<br/></p>
</head>
<body>
<p>
<b>Approver:</b> {!relatedTo.Product_Area_Approver__r.Name}<br/>
</p>
<p>
<b>Comments: </b>
<c:JCApprovedEmailTemplate jcId="{!relatedTo.Id}"/></p>
</body>
</html>
</messaging:HtmlEmailBody>
</messaging:emailTemplate>

 

  • October 29, 2012
  • Like
  • 0

we are strugglisng for almost 2 days to accomplish the below request.

 

we have a video to post on our portal , so end user can see it on click.

we have been provided with a html code, which plays perfect, we are not sure how to embed this in visualforce or for that matter any where in salesforce, from where we can get an url and can be posted as a link.

 

Please help...

 

can i play some thing like below from salesforce

<html>
<body>

<video width="320" height="240" controls="controls" autoplay="autoplay">
  <source src="movie.ogg" type="video/ogg">
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.webm" type="video/webm">
<object data="movie.mp4" width="320" height="240">
  <embed width="320" height="240" src="movie.swf">
</object>
</video>

</body>
</html>

 

  • October 22, 2012
  • Like
  • 0

My securitytoken is getting reset automatically everytime i validate or deploy a change set,

 

Happend when i tried it from IDE too.

 

Any idea why is it happening?

 

  • September 21, 2012
  • Like
  • 0

we have search page where it returns large amounts of data,that needs to be displayed in visual force page, page block table.

 

It erroring out because of the volume.

 

I tried the pagenation, the error is resolved but its taking longer time to display the next chunk of data when i click the next button.

 

any body expereinced the same issue, Please Help

  • September 11, 2012
  • Like
  • 0

I want to invoke the search functionality by pressing the search button or by clicking the enter key.

 

Its working fine for the input text fields, but not for the radio button.

 

I referred the http://developer.force.com/cookbook/recipe/submit-a-form-with-the-enter-key 

 

Attached is my code please help.

<apex:page controller="myCon" sidebar="true">
<script type='text/javascript'>
        function noenter(ev)  {
            if (window.event && window.event.keyCode == 13 || ev.which == 13) {
                doSearchAF();
                return false;
             } else {
                  return true;
             }
         }
    </script>

 <apex:form >
 <apex:pageBlock mode="edit">
            
    <apex:actionFunction name="doSearchAF" action="{!searchJobs}" />
            
       <apex:pageBlockButtons location="bottom">
         <apex:commandButton value="Search Jobs" action="{!searchJobs}" id="mybutton"/>
         <apex:commandButton Value="  Clear  " action="{!cancel}" onclick="return confirmCancel()" />
       </apex:pageBlockButtons>
            
            <apex:pageBlockSection columns="1">
                <apex:pageBlockSectionItem >
                    
                    <apex:outputLabel value="State" for="state" styleClass="textFont"/>                  
                    <apex:inputText value="{!state}" id="state" onkeypress="return noenter(event);" />
                </apex:pageBlockSectionItem>

                <apex:pageblocksectionItem >
                    <apex:outputLabel value="Job Type" for="jt"/>
                    <apex:outputPanel id="jt">
                         <apex:selectRadio value="{!SelectJobType}" onclick="return noenter(event);">
                             <apex:selectOptions value="{!jobType}"/>
                         </apex:selectRadio>
                     </apex:outputPanel>               
                </apex:pageblocksectionItem>            
                
            </apex:pageBlockSection>
       
        </apex:pageBlock>

 

  • September 06, 2012
  • Like
  • 0
i have a list of records that i have to show in a matrix/grid view.
some thing like below. i have labels on rows and columns and i should present the data in such a way that where a record have that combination i should put a star there. so user can click on it and open another page to see the record related to that row and column combo.for ex B and IL star.
this is something new and i am struggling to get it done. does anybody did anything similer?
 User-added image
  • April 10, 2014
  • Like
  • 1
I have a trigger on a custom object called Launch Checklist that is supposed to use a unique identifier to look up another custom object called App and that App's Account based on an ID field.  When I edit and save a single record, everything works swimmingly.  When I try to force a bulk upload (through Data Loader or Anonymous Apex), the Trigger just doesn't seem to fire at all, or worse, it associates the wrong app/account.

Again, though, if I save a single record with the wrong info, without making any changes, the association occurs correctly.  I've spent time to ensure my trigger is bulkified.  Can anyone help identify what I'm doing wrong?  Code is below.

trigger LaunchChecklist on Launch_Checklist__c (before insert, before update) {
    
    String appId = Null;
    Map <String, App__c> mapApp = new Map <String, App__c> ();
    
    for(Launch_Checklist__c lc: Trigger.new) {
        if (lc.Apple_ID__c != Null) {
            appId = lc.Apple_ID__c;
        } else if (lc.Package_Name__c != Null) {
            appId = lc.Package_Name__c;
        }
    }

    List<App__c> apps = new List<App__c>([select App_ID__c, Account__c from App__c where App_ID__c = :appId limit 1]);
    
    if (apps.size() > 0) {
        for (App__c app: apps)  {
        	mapApp.put(app.App_ID__c, app);
    	}
        for(Launch_Checklist__c lc: Trigger.new) {
            lc.Account__c = mapApp.get(appId).Account__c;
            lc.App__c = mapApp.get(appId).Id;
    	}
    }
}


can we put a commandlink in apex error message?

when user gets an error message it contain a clickable content/commandlink ,which should open a popup with instructions.

is it possible to add commandlink in errormessage??
  • June 26, 2014
  • Like
  • 0
We have serveral triggersdating back from the days before my time, many have been failing and with similar errors.
They all  has always worked and still worked, in Production and the other developer sandbox, but not the full sandbox which was recently refreshed. 

This is one of the failures i get when adding or editing an opportunity:
"Apex trigger UpdateOpportunityProduct caused an unexpected exception, contact your administrator: UpdateOpportunityProduct: execution of BeforeUpdate caused by: line 5, column 21: trigger body is invalid and failed recompilation: Variable does not exist: pricebookentryid"

and the code:
trigger UpdateOpportunityProduct on OpportunityLineItem (before insert, before update) {
	    Set<Id> pbeIds = new Set<Id>();
	    for (OpportunityLineItem oli : Trigger.new) 
	        pbeIds.add(oli.pricebookentryid);
	    Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>([select Product2.Product_Type__c, Product2.Product_Category__c, Product2.ProductCode, Product2.Assessment__c, Product2.PD_Complimentary_Group_Type__c from PricebookEntry where id in :pbeIds]);
	    for (OpportunityLineItem oli: Trigger.new) {
	        Product2 product = entries.get(oli.PricebookEntryId).Product2;
	        oli.Product_Type__c = product.Product_Type__c;
	    }  
}

Already reach out to salesforce and closed my ticketet saying it's "Internal Server Error", let me know what you guys think?


I debugged a collection type List in the apex and I am expecting to see a total of 20 elements in that list. But I can see only 10 and after the 10th element there are few dots(.......) meaning that there are other elements but those are not displyed. how to view those elements as well,

Thanks.
I'm having trouble with the following. I have a custom object and in that custom object I have a product manager field. The field needs to be filled with the product manager's name/ID from the user object. I have successfully retrieved the user record but I am unsure how to fill the custom object's product manager field. The code is below. The u1.ID does contain the correct ID for the product manager and I do successfully get the user record. The problem is how do I correctly fill the product_manager_1__c field so it maintains the lookup relationship to the user record. Product_manager_1__C is a lookup field to the user object.

If (PM1 != null ){
         User u1 = [Select ID, Name
                     From User
                     Where Name = :PM1];
            system.debug('pm1 ID =  ' + u1.id);
            If (u1.Id != '')sr.Product_Manager_1__c = u1.ID;
            Update sr;
            
        } //End PM1 if
Hi ,

I have the following controller and Vf page that adds one attachment

controller:

public with sharing class OpportunityAttachmentController{
  
    public Opportunity_Attachment__c objOppAtt {get; set;}
 
    public OpportunityAttachmentController(ApexPages.StandardController controller) {
        attach = new Attachment();
        objOppAtt = (Opportunity_Attachment__c)controller.getRecord();
     
    }

    public Attachment attach {get;set;}
    public Attachment attach1 {get;set;}
 
    //When user clicks upload button on Visualforce Page, perform upload/insert

    public ApexPages.Pagereference save(){
        if(attach.body==null){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please select a file to upload'));
            return null;
        }
        insert objOppAtt;
     
      
        attach.ParentId = objOppAtt.id;
        insert attach;
      
       
        objOppAtt.URL__c = URL.getSalesforceBaseUrl().toExternalForm()+'/servlet/servlet.FileDownload?file='+attach.id;
        objOppAtt.name = attach.Name;
        update objOppAtt;
      
        return new PageReference('/'+objOppAtt.Opportunity__c); 
    }
  
  
  
  
  
}


VF page:
<apex:page standardController="Opportunity_Attachment__c" extensions="OpportunityAttachmentController">
    <apex:sectionHeader title="New Opportunity Attachment" subtitle="Opportunity Attachment Edit"/>
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockSection columns="1">
              
                <apex:outputField value="{!Opportunity_Attachment__c.Opportunity__c}"/>
                <apex:pageBlockSectionItem >Upload Contract<apex:inputFile required="true" value="{!attach.body}" filename="{!attach.name}" /></apex:pageBlockSectionItem>
              
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Upload" action="{!save}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>


I want to add one more attachment  so i modify the vf as follows:
<apex:page standardController="Opportunity_Attachment__c" extensions="OpportunityAttachmentController">
    <apex:sectionHeader title="New Opportunity Attachment" subtitle="Opportunity Attachment Edit"/>
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockSection columns="1">
             
                <apex:outputField value="{!Opportunity_Attachment__c.Opportunity__c}"/>
                <apex:pageBlockSectionItem >Upload Contract<apex:inputFile required="true" value="{!attach.body}" filename="{!attach.name}" />
            <apex:pageBlockSectionItem >Upload Attributes<apex:inputFile required="true" value="{!attach.body}" filename="{!attach.name}" />

</apex:pageBlockSectionItem>
             
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Upload" action="{!save}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>


do i have to write a seperate controller,or i can modify the same?If modify the same ,how?
i have a list of records which are displayed in a page block table. one of whic is a command link. if i click on it, will open the right record but if i right click on it, it's opening the same record again andagain.

<apex:column>
<apex:commandLink value="View" action="{!viewRecord}">
            <apex:param value="{!record.Id}" name="RowId" assignTo="{!RowId}"/>
        </apex:commandLink>
       
    </apex:column>

public Pagereference viewRecord(){

       
        PageReference ref = new Pagereference('/apex/mypage?id='+RowId);
        ref.getParameters().put('Id',RowId);
   
        return ref;

    }

what am i doing wrong...
  • February 28, 2014
  • Like
  • 0
I have a requirement where there is a list of strings which is quite big, around few thousands. but need to be displayed in different lines and could be able to export/ take print etc...
please check the below image for reference.

please help.

 User-added image
  • February 10, 2014
  • Like
  • 0

Hi

 

I am trying to query my endpoint from custom setting in my RESTFULL call.

I created a object and a customfield in custom setting and made it public.

I gave my endpoint in that customfield(asdefaultvalue).

In my apex class Icreated a list and trying to query that field from that object.

But Iam getting nullvalue. Please help if I am missing something.

 

Hi,

 

I am trying to retrieve history of field Salary at my custom object Employee. I am using the following query :-

 

List<Employee__c> lstEmp=[SELECT Id,Salary__c,
                          (SELECT OldValue,NewValue, FROM Histories)
                          FROM Employee__c                        
                         ];

Now I need to retrieve a particular field only which is salary, I do not want other fields tracking details and I need to get date at which the change is made. Please let me know how should i modify my query and if you have the link to the documentation of history object present in salesforce please post that.

 

 

Thanks in advance....

Hello,

I have a email template, this email is related to Lead, if I send a test of email template or an workflow I recieve the email with the variables, but if I send for a Send Email button in Activity History, the variables of template do not appears.

 

Anybody can help me?

 

Thanks.

Have trigger to check duplicate with certain parameters

 

 

Query is:

 

(Select id from x__c where (((a__c = request.a__c) and (b__c =request.b__c) and (c__c = request.c__c) and (lastmodifieddate>=system.today) limit 1);

 

X__c is the object having 1,75,000 records. For satisfying this condition, its having only 5 records,

 

The same query, ran in the developer console,controller its running successfully.

 

When i run this query in the trigger, its throwing error.

 

Could any one help on this? Please..:(

 

 

Hi there,

 

I'm trying to create test coverage for a trigger over User object, soI need to create a User to fire the trigger. I coded a test class following this: http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_dml_non_mix_sobjects.htm?SearchType

 

This is how it looks like:

 

public class UserTriggerHandlerTest {
 
        @isTest (seeAllData=true)
        static void testUserCreate(){
               
                // Setup test data
                // This code runs as the system user
                Profile p = [SELECT Id
                             FROM Profile
                             WHERE Name='Portal User'];
 
                Profile p2 = [SELECT Id
                              FROM Profile
                              WHERE Name='System Administrator'];
                 
                User u = new User(Alias = 'custPort', Email='customer@portal.com',
                EmailEncodingKey='UTF-8', LastName='Portal', LanguageLocaleKey='en_US',
                LocaleSidKey='en_US', ProfileId = p.Id,
                TimeZoneSidKey='America/Los_Angeles', UserName='customer@portal.com');
               
                User u2 = new User(Alias = 'admn', Email='admin@test.com',
                EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
                LocaleSidKey='en_US', ProfileId = p2.Id,
                TimeZoneSidKey='America/Los_Angeles', UserName='customer@portal.com');
               
                System.runAs(u2) {
               
                        insert u;
               
                }
       
        }
}

 



The test fails with the following message:

FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
FATAL_ERROR Class.UserTriggerHandlerTest.testUserCreate: line 23, column 1

 

Any ideas? Does anyone know how to avoid this or any workaround to do test coverage for a trigger over User?

 

Thanks.

 

MGA.

We have a formula field, GrossBudget__c, that should only be displayed on the layout if a certain condition is true. I don't want to create a visualforce page to replace the entire standard layout. Is it possible to achieve this by creating a visualforce page for just GrossBudget__c and add in a condition that it should only be visible under a certain condition? And then we can just place that mini visualforce page on the standard layout?

 

If anyone can let me know if this is even possible or point me in the direction of any documentation or blog posts on this it would be greatly appreciated!