• cduncombe44
  • NEWBIE
  • 100 Points
  • Member since 2012

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 30
    Replies

I'm having the hardest time doing something that should be relatively simple.  I have a VF component that is displaying a list of custom objects and a penel that will display details about each object.  For each child object in the details, I want the ability to upload an attachment.  I have used a wrapper class to help with this.  The issue is I am getting a VF error: Required field missig [Body] : [Body] every time.

 

Here is the relevant section of VF



<apex:repeat value="{!formWraps}" var="fWrap"> <tr> <td style="font-weight:bold"><apex:outputField value="{!fWrap.form.Form_Template__r.Name}"/></td> <td><apex:inputfield value="{!fWrap.form.Collected_Paper_Form__c}"/></td> <td><apex:inputfield value="{!fWrap.form.Attached_in_SalesForce__c}"/></td> <td><apex:outputLabel value="File: " for="file" style="font-weight:bold"/> <apex:inputText value="{!fWrap.attachment.Name}"/> <apex:inputFile value="{!fWrap.attachment.Body}" filename="{!fWrap.attachment.Name}"/></td> </tr> </apex:repeat>
<apex:pageblockButtons location="bottom">
      <apex:commandButton value="Save Changes" action="{!saveChanges}"/>
</apex:pageblockButtons>

 

  Here are the controller properties, methods, and wrapperClass that apply

public Contact con 					{get;set;}
public Event_Affiliation__c currentEvent 		{get;set;}
private list<Form__c> forms				{get;set;}
public list<formWrapper> formWraps			{get;set;}

..........

Id eventId = System.currentPageReference().getParameters().get('event');
currentEvent = [Select Id, Name, Pre_Registered__c, Attended__c, Fishing_Partnership_Event__c,
Fishing_Partnership_Event__r.Name, (Select Id, Name From Attachments), Fishing_Partnership_Event__r.Location__c,
Fishing_Partnership_Event__r.Event_Date__c From Event_Affiliation__c Where Id = : eventId]; forms = [Select Id, Name, Form_Template__c, Form_Template__r.Name, Collected_Paper_Form__c, Attached_in_SalesForce__c,
Attachment_ID__c, Event_Affiliation__c From Form__c Where Event_Affiliation__c =: currentEvent.Id]; for(Form__c f : forms){ formWraps.add(new formWrapper(f)); } ............... public PageReference saveChanges(){ for(formWrapper wrap : formWraps){ wrap.attachment.Name = wrap.form.Form_Template__r.Name + ' ' + con.Name; wrap.attachment.ParentId = wrap.form.Event_Affiliation__c; wrap.attachment.OwnerId = UserInfo.getUserId(); wrap.attachment.Body = fileBody; system.debug('attachment Name: ' + wrap.attachment.Name);
system.debug('attachment OwnerID: ' + wrap.attachment.OwnerId);
system.debug('attachment ParentID: ' + wrap.attachment.ParentId); system.debug('attachment Body: ' + wrap.attachment.Body); insert wrap.attachment; } try{ update currentEvent; update healthInts; }catch(Exception e){ ApexPages.addMessages(e); } PageReference page = new PageReference('/' + currentEvent.Id); page.setRedirect(true); return page; } .................. /*WRAPPER CLASS*/ public class formWrapper{ public Form__c form {get;set;} public string attachmentID {get;set;} public Attachment attachment {get;set;} public formWrapper(Form__c f){ form = f; attachmentID = ''; attachment = new Attachment(); } public formWrapper(Form__c f, string aID, Attachment a){ form = f; attachmentID = aID; attachment = a; } }

 

Here is the Debug logs...for some reason the body of the attachment is not being bound from the input file to the attachment within the wrapper class, all the other attributes are being set....I've been pouding my head on the wall for a while with this one

09:58:45.341 (341358000)|SYSTEM_METHOD_ENTRY|[63]|System.debug(ANY)
09:58:45.341 (341376000)|USER_DEBUG|[63]|DEBUG|attachment Name: Signed Consent Form Johnny Appleseed
09:58:45.341 (341384000)|SYSTEM_METHOD_EXIT|[63]|System.debug(ANY)
09:58:45.341 (341403000)|METHOD_ENTRY|[64]|01pK00000001Qv8|EventAffiliationListController.formWrapper.__sfdc_attachment()
09:58:45.341 (341422000)|METHOD_EXIT|[64]|01pK00000001Qv8|EventAffiliationListController.formWrapper.__sfdc_attachment()
09:58:45.341 (341466000)|SYSTEM_METHOD_ENTRY|[64]|String.valueOf(Object)
09:58:45.341 (341480000)|SYSTEM_METHOD_EXIT|[64]|String.valueOf(Object)
09:58:45.341 (341492000)|SYSTEM_METHOD_ENTRY|[64]|System.debug(ANY)
09:58:45.341 (341502000)|USER_DEBUG|[64]|DEBUG|attachment OwnerID: 005d00000011zsxAAA
09:58:45.341 (341510000)|SYSTEM_METHOD_EXIT|[64]|System.debug(ANY)
09:58:45.341 (341524000)|METHOD_ENTRY|[65]|01pK00000001Qv8|EventAffiliationListController.formWrapper.__sfdc_attachment()
09:58:45.341 (341542000)|METHOD_EXIT|[65]|01pK00000001Qv8|EventAffiliationListController.formWrapper.__sfdc_attachment()
09:58:45.341 (341620000)|SYSTEM_METHOD_ENTRY|[65]|String.valueOf(Object)
09:58:45.341 (341640000)|SYSTEM_METHOD_EXIT|[65]|String.valueOf(Object)
09:58:45.341 (341661000)|SYSTEM_METHOD_ENTRY|[65]|System.debug(ANY)
09:58:45.341 (341676000)|USER_DEBUG|[65]|DEBUG|attachment ParentID: a0gK00000011xBeIAI
09:58:45.341 (341686000)|SYSTEM_METHOD_EXIT|[65]|System.debug(ANY)
09:58:45.341 (341701000)|METHOD_ENTRY|[66]|01pK00000001Qv8|EventAffiliationListController.formWrapper.__sfdc_attachment()
09:58:45.341 (341721000)|METHOD_EXIT|[66]|01pK00000001Qv8|EventAffiliationListController.formWrapper.__sfdc_attachment()
09:58:45.341 (341734000)|SYSTEM_METHOD_ENTRY|[66]|String.valueOf(Object)
09:58:45.341 (341741000)|SYSTEM_METHOD_EXIT|[66]|String.valueOf(Object)
09:58:45.341 (341753000)|SYSTEM_METHOD_ENTRY|[66]|System.debug(ANY)
09:58:45.341 (341762000)|USER_DEBUG|[66]|DEBUG|attachment Body: null
09:58:45.341 (341769000)|SYSTEM_METHOD_EXIT|[66]|System.debug(ANY)

 

I know this is bits and pieces, and totaly not best practices with SOQL in for loops and such, but that wouldnt cause the Body of the attachment to be null.  I figure I want to get it working before worrying about optimizing the code.  

 

Any help would be greatly appreciated.  Just hoping there is something obvious that I am missing that someone could point out.  PLEASE HELP

 

Chris

 

I am pulling my hair out with this one.

 

I have a few jqGrids on my VF page.  I now have a select list Im using to try to filter one of the jqGrids.  If I hardcode an ID in the controller to filter with, it works, and the grid reloads, but if i try to use the parameter that I am passing in via an ActionFunction, the logs show my parameter as null.

 

jquery change method

jQuery('[id$=htmlSelect]').change(function(e) {
			
	filterPage(this.value);
	var commGrid = jQuery('#commList');
	commGrid.trigger("reloadGrid");
			
});  

 Action Function

<apex:actionFunction name="filterPage" action="{!makeNewCommJSON}" >
      <apex:param name="acc" value="" assignTo="{!stringID}"/>
</apex:actionFunction>

 

Controller function to filter list

public void makeNewCommJSON(){		
		
	Id acc = system.currentPageReference().getParameters().get('acc');
	system.debug('accountid Parameter: ' + acc); 
	system.debug('stringID Value: ' + stringID); 
		
	list<Commitment__c> comms = [select id, Name, Due_Date__c, Status__c, Account__c, Account__r.Name, Owner__c, Owner__r.Alias
		from Commitment__c
		where Owner__c = :Userinfo.getuserid()
		and Status__c != 'Completed'
		and Account__c =: acc];
		//and Account__c = '001M000000JKGcNIAX'];		
		
	if(comms != null && comms.size() > 0) {
			newCommJSON = '{"page":"1","total":"' + ( 1 + ( comms.size() / 10 )) + '","records":"' + String.valueOf(comms.size()) + '","rows":[';
			
		for(Commitment__c c : comms ) {
			newCommJSON += '{"id":"' + c.id + '","cell":[';
			newCommJSON += JqGridDataController.parseCell(c.Due_Date__c);
			newCommJSON += JqGridDataController.parseCell('<a href=/'+ c.Account__c + '>'+ c.Account__r.Name +'</a>')
			newCommJSON += JqGridDataController.parseCell(c.Owner__r.Alias);
			newCommJSON += JqGridDataController.parseCell('<a href=/'+ c.Id + '>' + c.Name + '</a>');				
			newCommJSON = newCommJSON.subString(0,newCommJSON.length() - 1);
			newCommJSON += ']},';
		}
		
		newCommJSON = newCommJSON.subString(0,newCommJSON.length() - 1);
		newCommJSON += ']}';
	}
	else {
		//no records were retrieved
		newCommJSON = '{"page":"1","total":1,"records":"' + String.valueOf('0') + '","rows":[';
		newCommJSON += '],"userdata":{"amount":3220,"tax":342,"total":3564,"name":"Totals:"}}';
	}
	DashIdCarrier.commJSONString = newCommJSON;
		
		
}

 

This all works fine, but as I said, when I check the logs, the parameter isnt being passed properly.  see below

 

17:56:00.082 (82279000)|SYSTEM_METHOD_EXIT|[33]|String.valueOf(Object)
17:56:00.082 (82302000)|SYSTEM_METHOD_ENTRY|[33]|System.debug(ANY)
17:56:00.082 (82313000)|USER_DEBUG|[33]|DEBUG|accountid Parameter: null
17:56:00.082 (82320000)|SYSTEM_METHOD_EXIT|[33]|System.debug(ANY)
17:56:00.082 (82341000)|METHOD_ENTRY|[34]|01pM00000009QmO|CommitmentDashboardController.__sfdc_stringID()
17:56:00.082 (82377000)|METHOD_EXIT|[34]|01pM00000009QmO|CommitmentDashboardController.__sfdc_stringID()
17:56:00.082 (82395000)|SYSTEM_METHOD_ENTRY|[34]|System.debug(ANY)
17:56:00.082 (82403000)|USER_DEBUG|[34]|DEBUG|stringID Value: null
17:56:00.082 (82410000)|SYSTEM_METHOD_EXIT|[34]|System.debug(ANY)

 

 

If i dont use the parameter, and hard code an ID of an account, it works fine and the grid reloads perfectly.  Am i doing something wrong?  What am I missing here, why is the parameter not being passed properly?

 

Any help would be hugely appreciated.

 

Chris

 

hi guys,

 

Please help me in with the query.

My contact will have only one opportunity  1-1 relation ship:-1 account ,1 contact 1, opportunity.

 

  for(Comments__c cs:trigger.New){
        cms=cs;    
        if(cms.Opportunity__c==null && cms.Contact__c!=null ){
            sobjectSetOfIds.add(cms.Contact__c);           
        }
    }   
    
    Map<Id,Contact>smap1= new Map<Id, Contact>([Select id
                                                        ,Name
                                                        ,Opportunities__r.id // error  
                                                         from Contact 
                                                         where Id in : sobjectSetOfIds]);
                
    for(Comments__c s: trigger.new){
        if(smap1.containsKey(s.Contact__c)){        
            s.Opportunity__c=smap1.get(s.Contact__c).Opportunities.id;    //error
                
        }
    }

 

Thanks

Anil.B

 

Hello all,

 

 

I've been trying to sort a list of strings like a summary but I have no idea about what to try now.

 

There is my problem:

 

I have string that represents positions in a summary, example: "1", '1.1", "1.1.1", "1.1.2", etc.

 

And I want to sort those in order like a structured things in the Microsoft project.

 

But for strings, "4" is not greater than "1.1". So things won't be in correctly order.

 

Searching in Google and here I tried to make a Wrapper. That looks like this:

 

global class PacoteWrapper implements Comparable {

public Pacote__c pac;

public PacoteWrapper(Pacote__c pc) {
pac = pc;
}

global Integer compareTo(Object compareTo) {

PacoteWrapper compareToPac = (PacoteWrapper)compareTo;

Integer returnValue = 0;

Double posDouble = Double.valueOf(pac.Posicao_EDT__c);
Double posCompareDoulb = Double.valueOf(compareToPac.pac.Posicao_EDT__c);

if (posDouble > posCompareDoulb) {
returnValue = 1;
} else if (posDouble < posCompareDoulb) {
returnValue = -1;
}

return returnValue;
}

 

 

And i use pacWrapperList.sort() to make things works.

 

But it will only works if my string is not greater than 2 dots. 

 

That means, it works great for strings like "1", "1.2", "2.3", etc.

 

It will fail for strings using 2 dots, of course. There is no double number with 2 dots, hahaha.

 

So, if anyone has a tip or a piece of code that can help me, i will be very glad.

 

Thank you all for attention. Best regards!

Hi guys. I am learning force.com and currently  i am using developer account so I necessarily don't have to write testclass for a now but when i will be on project i have to write down test method to deployee it to production envirionment from developer environment. I have written some test classes for triggers but i don't know how to write testmethod for visualforce custome controller class. my code is successfully working but I also want to write test class with cover more than 75%. i am pasting my code bellow can you guys help me out with its test class.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

public with sharing class searchPatientAccount {
// the soql without the order and limit
  private String soql {get;set;}
  // the collection of contacts to display
  public List<Account> accounts {get;set;}
 
  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }
 
  // the current field to sort by. defaults to last name
  public String sortField {
    get  { if (sortField == null) {sortField = 'name'; } return sortField;  }
    set;
  }
 
  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }
 
  // init the controller and display some sample data when the page loads
  public searchPatientAccount() {
    soql = 'select a.id, a.name, a.accountnumber,a.phone from account a where a.name != null';
    runQuery();
  }
 
  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }
 
  // runs the actual query
  public void runQuery() {
 
    try {
      accounts = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }
 
  }
 
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
 
    String accountname = Apexpages.currentPage().getParameters().get('accountname');
    String accountnumber = Apexpages.currentPage().getParameters().get('accountnumber');
    String phone = Apexpages.currentPage().getParameters().get('phone');
   // String technology = Apexpages.currentPage().getParameters().get('technology');
 
    soql = 'select a.id, a.name, a.accountnumber,a.phone from account a where a.name != null';
    if (!accountname.equals(''))
      soql += ' and a.name LIKE \''+String.escapeSingleQuotes(accountname)+'%\'';
    if (!accountnumber.equals(''))
      soql += ' and a.accountnumber LIKE \''+String.escapeSingleQuotes(accountnumber)+'%\'';
    if (!phone.equals(''))
      soql += ' and a.phone LIKE \''+String.escapeSingleQuotes(phone)+'%\'';  

 
    // run the query again
    runQuery();
 
    return null;
  }
 
  // use apex describe to build the picklist values
  public List<String> technologies {
    get {
      if (technologies == null) {
 
        technologies = new List<String>();
        Schema.DescribeFieldResult field = Contact.interested_technologies__c.getDescribe();
 
        for (Schema.PicklistEntry f : field.getPicklistValues())
          technologies.add(f.getLabel());
 
      }
      return technologies;          
    }
    set;
  }
}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Hello I have PageBlockTable with in line editing and a link to delete the selected row.
The delete works fine, however I cannot figure our how to refresh the page or even just the
pageblocktable to show that the row has been deleted.

 

Thanks in Advance

 

Delete method:

public string SelectedDetailId { get; set; }
public void DeleteDetail()
{
if (SelectedDetailId == null) {
return;
}
Product_Detail__c toBeDeleted = [SELECT name FROM Product_Detail__c WHERE Name = :SelectedDetailId LIMIT 1];
if (toBeDeleted != null) delete toBeDeleted;
//refreshTable();

}

 

 

Apex Code:

<apex:pageBlockTable id="annTable" value="{!AnnuityProducts}" var="item" Title="Annuity Detail">

<apex:column >
<a href="javascript&colon;if (window.confirm('Are you sure?')) DeleteDetail('{!item.name}');" style="font-weight:bold">Del</a>
</apex:column>

<apex:column headerValue="Carrier">
<apex:outputField value="{!item.Name__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>

<apex:column headerValue="Type">
<apex:outputField value="{!item.Type__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>

<apex:column headerValue="Verified Assets">
<apex:outputField value="{!item.Asset_Total__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>

<apex:column headerValue="Portability">
<apex:outputField value="{!item.Portability__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>

<apex:column headerValue="Product Detail Name">
<apex:outputField value="{!item.Name}">

</apex:outputField>
</apex:column>
</apex:pageBlockTable>

<apex:actionFunction action="{!DeleteDetail}" name="DeleteDetail" reRender="test" >
<apex:param name="name" value="" assignTo="{!SelectedDetailId}"/>
</apex:actionFunction>

The code below rerenders the time on the "randompanel" but it doesn't shows the new value of the case status when clicking on the Reopen case button. The random panel and the NOW function were added just to test. The action {!ReOpenCase} sets the status of the case to "reopened" and this is happening but the rerender doesn't display that value. I opened a case with salesforce about this and is escalated to tier 3.....any ideas?

 

 

<apex:outputPanel id="randompanel" >
<apex:outputtext value="{!NOW()}"/>
<apex:outputtext value="{!case.status}"></apex:outputtext>

</apex:outputPanel>
<apex:form >

<apex:commandButton action="{!ReOpenCase}" value="Reopen Case" id="ReopenCaseButton" reRender="randompanel" rendered="{!IF(case.Status == 'Resolved' || case.Status == 'Closed',true,false)}"/>


</apex:form>

 

Thanks in advance for any help on this. I have spent a lot of time trying to make it work :(

Hi All,

 

Is there an alternate way to create columns in visual force page apart from using <apex:columns>?

 

Thanks and Regards,

Vijay

 

 

I really hope someone can help me because I have been banging my head over this one for far too long.  I have a VF page to override the contact view.  Its tabbed and most tabs are made of their own cutom component.

 

On this particular component, I have a list of wrapperClass custom objects so users can mass copy Insurances (custom object).  The popup allows them to choose which contact to copy the insurances to, and when you click select, the JS calls a function on the parent page that simply calls an actionFunction to insert the new records, and refreshes the list and adds a page message.  Works great with every browser except IE.  I really wish I could just force users to not use IE, but not an option at this point.

 

I have looked over the boards and tried every suggestion I could find from previous posts.  I have taken out the showHeader="false", I have tried nesting the entire page in <body> tags, I tried immediate="true" in the actionFunction, I have added the following to the controller

 

Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8'); 

 

 

Nothing seems to work.  It is actually closing the window, but it is not calling the actionFunction and rerendering the page at all.  I just dont know how to fix this   please help

 

Popup VF Page

 

<apex:form id="form">

<table cellpadding="5px" cellspacing="0" style="margin: 10px;">
    <tr>
        <td colspan="3" align="center"><apex:commandButton value="Select" action="{!save}" oncomplete="fun();" rerender="panel1,panel2"/>&nbsp;<apex:commandButton value="Cancel" onclick="window.top.close();" /></td>
    </tr>
    <tr>
        
    </tr>
        <tr>
            <td width="50px"></td>
            <td width="400px" class="cts_th">Which Family Member(s) would you like to copy selected Insurances to?</td>
            <td width="50px"></td>
        </tr>
        <tr>
            <td width="20px"></td>
        </tr>
        <tr>
            <td width="20px"></td>
        </tr>    
    <tr></tr>
    </table>
    
    <table cellpadding="5px" cellspacing="0" style="margin: 10px;">
    <apex:repeat value="{!conWrappers}" var="con">
        <tr>
            
            <td width="50px" align="right"><apex:inputCheckbox value="{!con.checked}" id="check"/></td>
            <td width="200px">{!con.cntact.Full_Name__c}</td>
            
        </tr>
    </apex:repeat>
    </table>
    <apex:outputpanel id="panel2">
    <apex:pageblock id="block">
	    <apex:inputHidden value="{!saved}" id="saved"/>
	    <apex:inputHidden value="{!sel}" id="sel"/>
	    
	</apex:pageblock>    
    </apex:outputpanel>
</apex:form>


<script>
function fun() {
	var item = document.getElementById('page:form:block:saved');
    if(item.value == 'false'){
    	alert('You didn\'t choose anyone');
    }
    if(item.value == 'true') {          
		
    	Close();
    }
}

function Close() {	 
   
      var winMain=window.opener;
      if (null==winMain)
      {
         winMain=window.parent.opener;
      }
      item = document.getElementById('page:form:block:sel');
      var sel = item.value;
      winMain.userSelected(sel);     
   
}
</script>

 

Snippets from Parent Page

<apex:actionfunction name="copyInsurance" action="{!copyInsurance}" immediate="true" rerender="insurances,table,dataTable"/>

<apex:inputhidden value="{!sel}" id="selected"/>

<script>
function userSelected(sel) {
	
    var tag = document.getElementById('{!$Component.com.block.section.selected}');
    tag.value = sel;
    copyInsurance();
    closePopup();
}

function closePopup() {
	if (null!=newWin) {
    	newWin.close();
    }  
}
</script>

 

Its pretty straight forward and works perfectly on every other browser.  Just dont get it.  Please help

 

Chris

 

 

Hello,

 

   I have created a page that is really just a big list of Processes (custom object) where the user can go and take ownership of the process, it is then removed from the master queue.

 

The page has 5 buttons to change the view View All, View Mine (open), View Mine (Completed), View Oither (open), View Others (Completed).  All this is really doing is changes a controller property that sets the visibility of my tables.

 

The problem is it takes FOREVER to render the different lists when pressing buttons.  It works fine testing in the sandbox with only a few dummy processes, but in production with 1000 or so, it takes forever.  I think I am doing something wrong with the SOQL queries perhaps.  Is there a more efficient way of accomplishing this?  

 

VF 

 

<apex:sectionHeader title="Insurance Profile Campaign" subtitle="Master List"/>
	<apex:form >
	<apex:outputpanel id="container">
	<apex:outputpanel id="table">	
	<apex:pageblock >
	<apex:pageBlockButtons location="top">
		<apex:commandLink action="{!viewAll}" value="View All Unassigned" styleClass="btn" style="text-decoration:none" id="all" rerender="table,mine,container"/>
		<apex:commandLink action="{!viewMine}" value="View Mine (Open)" styleClass="btn" style="text-decoration:none" id="viewMine" rerender="table,mine,container"/>
		<apex:commandLink action="{!viewOthers}" value="View Others (Open)" styleClass="btn" style="text-decoration:none" id="others" rerender="table,mine,container"/>
		<apex:commandLink action="{!viewMyCompleted}" value="View Mine (Completed)" styleClass="btn" style="text-decoration:none" id="myComp" rerender="table,mine,container"/>
		<apex:commandLink action="{!viewOtherCompleted}" value="View Others (Completed)" styleClass="btn" style="text-decoration:none" id="otherComp" rerender="table,mine,container"/>	
	</apex:pageBlockButtons>
	
	<apex:pageBlockTable value="{!allProcesses}" var="pro" style="width:100%; border:1px solid #D4DADC;" rendered="{!Filter == 'Show All'}">
      
		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>	
	
	</apex:pageBlockTable>
	
	<apex:pageBlockTable value="{!myProcesses}" var="pro" style="width:100%; border:1px solid #D4DADC;" rendered="{!Filter == 'Show Mine'}">
		
		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>
		
	</apex:pageBlockTable>
	
	<apex:pageBlockTable value="{!otherProcesses}" var="pro" style="width:100%; border:1px solid #D4DADC;" rendered="{!Filter == 'Show Others'}">		
        
		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>
	
	</apex:pageBlockTable>
	
	<apex:pageBlockTable value="{!myCompletedProcesses}" var="pro" style="width:100%; border:1px solid #D4DADC;" rendered="{!Filter == 'Show My Completed'}">
		
		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>	
	
	</apex:pageBlockTable>
	
	<apex:pageBlockTable value="{!otherCompletedProcesses}" var="pro" style="width:100%; border:1px solid #D4DADC;" rendered="{!Filter == 'Show Other Completed'}">
		
       		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>
		
	</apex:pageBlockTable>
	
	</apex:pageblock>	
	</apex:outputpanel>
	
	</apex:form>

</apex:page>

 

Controller

List<Process__c> allPros;
	List<Process__c> myPros;
	List<Process__c> otherPros;
	List<Process__c> myCompletedPros;
	List<Process__c> otherCompletedPros;
	Transient List<Task> acts;
	Public Process__c selectedProcess {get;set;}
	Public String Filter {get;set;}
	Public boolean showStep {get;set;}
	Public Process_Step__c step;
	Public Contact con {get;set;} 	

	public InsuranceCampaignMasterController() {
		
		acts = new List<Task>();
		selectedProcess = new Process__c();
		step = new Process_Step__c();
		Filter = 'Show All';
		ShowStep = false;
		con = new Contact();
	}

	public List<Process__c> getAllProcesses() {

		if(allPros == null) {
			allPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c From Process__c 
				Where Process_Template__r.Name = 'Insurance Profile Campaign' and Process_Owner__r.Name = 'Chris Duncombe' and Status__c != 'Completed' 
				Order By Contact__r.MailingCity ASC];
									
		}return allPros;
	}
	
	public List<Process__c> getMyProcesses() {		
		
		if(myPros == null) {
			myPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c From Process__c 
				Where Process_Template__r.Name = 'Insurance Profile Campaign' and Process_Owner__c =: userinfo.getUserId() 
				and Status__c != 'Completed' Order By Start_Date__c ASC];
		
		}return myPros;
	}
	
	public List<Process__c> getOtherProcesses() {		
		
		if(otherPros == null) {
			otherPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c From Process__c 
				Where Process_Template__r.Name = 'Insurance Profile Campaign' and Process_Owner__c !=: userinfo.getUserId() 
				and Process_Owner__r.Name != 'Chris Duncombe' and Status__c != 'Completed' Order By Process_Owner__r.Name, Start_Date__c ASC];
		
		}return otherPros;
	}
	
	public List<Process__c> getMyCompletedProcesses() {
		
		if(myCompletedPros == null) {
			myCompletedPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c, Completion_Date__c,
				Total_Process_Time__c, Outcome__c From Process__c Where Process_Template__r.Name = 'Insurance Profile Campaign' 
				and Process_Owner__c =: userinfo.getUserId() and Status__c = 'Completed' Order By Completion_Date__c];
		
		}return myCompletedPros;
	}
	
	public List<Process__c> getOtherCompletedProcesses() {
		
		if(otherCompletedPros == null) {
			otherCompletedPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c, Completion_Date__c,
				Total_Process_Time__c, Outcome__c From Process__c Where Process_Template__r.Name = 'Insurance Profile Campaign' 
				and Process_Owner__c !=: userinfo.getUserId() and Process_Owner__r.Name != 'Chris Duncombe' and Status__c = 'Completed'
				Order By Process_Owner__r.Name, Completion_Date__c ASC];
		
		}return otherCompletedPros;
	}
	
	public void takeOwnership() {
		
		selectedProcess = [Select Id, Name, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c 
									From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
									
		step = [Select Id, Name, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
		
		selectedProcess.Process_Owner__c = userinfo.getUserId();
		selectedProcess.Start_Date__c = system.today();
		step.Assigned_To__c = userinfo.getUserId();
		update selectedProcess;
		update step;
		myPros = null;		
	}
	
	public void setStep() {
		
		showStep = true;
		selectedProcess = [Select Id, Name, Contact__c, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c
				 					From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
										
		step = [Select Id, Name, Process__c, Complete_Step_From_Process__c, Log_Activity_From_Process__c, Create_Task_From_Process__c, Status__c,
								Completed_By__c, Date_Completed__c, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
		con = [Select Id, Name From Contact Where id =: SelectedProcess.Contact__c];		
	}  
	
	public process_Step__c getMyStep() {
		return step;
	}
	
	public List<Task> getStepActivities() {
		acts = [Select Id, Subject, Navigator_Subject__c, ActivityDate, Description, WhoId, OwnerId, WhatId From Task Where WhatId =: step.id];
		return acts;
	}
	
	public void saveProcessChanges() {
		update selectedProcess;
	}
	
	public void viewMine() {
		Filter = 'Show Mine';
		showStep = false;
		
	}
	public void viewAll() {
		Filter = 'Show All';
		showStep = false;
		
	}
	public void viewOthers() {
		Filter = 'Show Others';
		showStep = false;
		
	}	
	public void viewMyCompleted() {
		Filter = 'Show My Completed';
		showStep = false;
		
	}
	public void viewOtherCompleted() {
		Filter = 'Show Other Completed';
		showStep = false;
		
	}
}

 

Any help would be greatly appreicated

 

Chris

Hello all,

 

     So I have a simple trigger that does not work for bulk inserts because I have a SOQL statement inside of a for loop.  I know this is the reason, I just can't figure out how to accomplish it without the SOQL in the FOR loop.

 

I have created a few custom objects to create repeatable processes.  There are Process Templates, Process Template Steps, Processes, and Process Steps.  As you can guess, you create a process Template, which has process template steps, so you can then create processes that are based on those templates.  

 

I have wrote a simple trigger that each time you create a process, it creates the process steps based on the template steps.

 

trigger CreateStepsForProcess on Process__c (after insert) {

	List<Process_Step__c> StepList = new List<Process_Step__c>();
	Process_Template__c proTemp = new Process_Template__c();
    For (Process__c pro: trigger.new){    	
    	
    	proTemp = [Select Id, Name From Process_Template__c Where id =: pro.Process_Template__c];
    	For (Process_Template_Step__c tempStep: [Select Id, Name, Sequence__c, Process_Template__c, Details__c, 
    													Assign_To__c From       Process_Template_Step__c Where Process_Template__c =: proTemp.id])
    													
    	{
    		Process_Step__c step = new Process_Step__c(
    			Name = tempStep.Name,
    			Step_Details__c = tempStep.Details__c,
    			Process__c = pro.Id,
    			Sequence__c = tempStep.Sequence__c,
    			Task_Created__c = 'N'    			
    		);
    		if(step.Sequence__c == 1){
    			step.Status__c = 'Open';
    		} else {
    			step.Status__c = 'Not Started';
    		}
    		StepList.add(step);
    	}
	}
	insert StepList;
}

 

I'm sure this can be accomplished with a few different Lists and/or Maps outside of the FOR loop, I have just had no luck in accomplishing this.  Any help is greatly appreciated.  Thanks so much

 

Chris