• carloe
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 11
    Replies

Hello,

Hope someone could assist me with this. 

 

I have a component which I'd like to be reusable.

 

The only purpose of this component is to find a record (through a series of picklist values) and return the matching record from the list  when the button is clicked (there's only going to be one record always). 

 

The component should be able to get the record ID and pass it on to the page where the component is used.

 

The vf page where the controller is used uses another controller.

 

 

1. How can I pass the record ID found in the component to the page's controller without using a URL parameter? I do not want the ID to be seen in the URL where it can be edited or removed.

 

2. To make the vfp reusable, what code should I use so that the PageReference value is dynamic instead of hardcoding the actual page names where the ID will be used?

 

 

I'm still trying to learn a lot from Apex/VFP but if anyone could point to the right direction it would be very helpful.

 

Thanks

 

 

  • October 10, 2012
  • Like
  • 0

Hi there,

I'm looking for a suggestion or a better way that we can implement this requirement:

 

 

We have a picklist of our products and they will be displayed on a customer facing visualforce page with a "next" button. Let's say the picklist values are:

 

Product A

Product B 

Product C

 

Product A is the most recent version and therefore we wanted to display a 'premium' content page when the "Next" is clicked. Products B and C are considered obsolete will go to another page that is more of a common page than what Product A has.

 

Now, this is not a problem to simply redirect to a different page based on the picklist value, we can use JS to accomplish that or rendered outputpanels.

 

Our challenge is to make this scallable since Product A may become obsolete in the future and we will add another product in the list (say, Product X)

 

What we dont want to end up with is to edit the pages every time we release a new product just in order to redirect it to the premium page. Not to mention doing this for multiple "latest version" products in different product lines.

 

 

Is there a way that we could tag particular products (using maybe another field) and just use that to reference in our pages to display our premium pages? The goal is to have something that we can edit in the object level (for us it's Case) rather than edit the visualforce pages every time we launch a new product.

 

Hope that make sense.

Thanks

 

 

 

 

 

 

  • September 28, 2012
  • Like
  • 0

Hi there,

I am new to writing triggers (in fact, havent written anything yet) but I am fairly familiar with custom controllers and visualforce pages.

 

recently we have a requirement to count the number of cases related to an asset. There's already a built-in relationship and the detail page of the asset displays the number of cases in one of the links at the top "Cases [1]".

 

I'm wondering how I can put this number in a custom number field so we can run our own asset validations through this field?

 

Any help in getting started is greatly appreciated.

 

 

 

 

  • September 12, 2012
  • Like
  • 0

Hi there,

We're have written an apex controller for vfp and the test coverage is 100%. However the average across all class/trigger is only at 55% because of some Triggers pulling it down. Is there a way we could exclude these triggers from being fired in our test class?

 

  • August 30, 2012
  • Like
  • 0

Hi there,

We are trying to create a w2c form with the ability to attach an asset to the case being generated.

 

We have an external system that imports assets and it generates a unique code. What we'd like to do is for the customer to enter that unique code in the form, find the asset, get the ID, then be able to submit a w2c.

 

We are able to run a query and display the asset in a vfp page but we are unable to attach the asset to the case itself. There is only one asset field in the case object and that is a lookup which we dont want to display on the page as this requires end-user searching through a list of records.

 

I'm wondering whether it is possible to assign the asset before the case gets inserted (in the custom controller) and if so, what are the fields in involve?

 

Thanks a lot for any help

Hello,

Hope someone could assist me with this. 

 

I have a component which I'd like to be reusable.

 

The only purpose of this component is to find a record (through a series of picklist values) and return the matching record from the list  when the button is clicked (there's only going to be one record always). 

 

The component should be able to get the record ID and pass it on to the page where the component is used.

 

The vf page where the controller is used uses another controller.

 

 

1. How can I pass the record ID found in the component to the page's controller without using a URL parameter? I do not want the ID to be seen in the URL where it can be edited or removed.

 

2. To make the vfp reusable, what code should I use so that the PageReference value is dynamic instead of hardcoding the actual page names where the ID will be used?

 

 

I'm still trying to learn a lot from Apex/VFP but if anyone could point to the right direction it would be very helpful.

 

Thanks

 

 

  • October 10, 2012
  • Like
  • 0

Hi there,

I'm looking for a suggestion or a better way that we can implement this requirement:

 

 

We have a picklist of our products and they will be displayed on a customer facing visualforce page with a "next" button. Let's say the picklist values are:

 

Product A

Product B 

Product C

 

Product A is the most recent version and therefore we wanted to display a 'premium' content page when the "Next" is clicked. Products B and C are considered obsolete will go to another page that is more of a common page than what Product A has.

 

Now, this is not a problem to simply redirect to a different page based on the picklist value, we can use JS to accomplish that or rendered outputpanels.

 

Our challenge is to make this scallable since Product A may become obsolete in the future and we will add another product in the list (say, Product X)

 

What we dont want to end up with is to edit the pages every time we release a new product just in order to redirect it to the premium page. Not to mention doing this for multiple "latest version" products in different product lines.

 

 

Is there a way that we could tag particular products (using maybe another field) and just use that to reference in our pages to display our premium pages? The goal is to have something that we can edit in the object level (for us it's Case) rather than edit the visualforce pages every time we launch a new product.

 

Hope that make sense.

Thanks

 

 

 

 

 

 

  • September 28, 2012
  • Like
  • 0

Hi there,

We're have written an apex controller for vfp and the test coverage is 100%. However the average across all class/trigger is only at 55% because of some Triggers pulling it down. Is there a way we could exclude these triggers from being fired in our test class?

 

  • August 30, 2012
  • Like
  • 0

Recently I was working on a requirement which required overriding the Case detail page with a visualforce page. Problem crept when the related list comonent didnt worked for Case Comments and History. So I decided to write my own code to display the related lists.

I was finally able to write my own code to display the related list. It implements all the function that standard related list of Case Comments provide. In order to make it reusable, I made it as a component so that in other pages I just need to pass the Case Id and I will get the complete list of Case Comments.

 Heres the code finally :

 1. Component Code

 

<apex:component controller="CaseCommentsComponentController" allowDML="true">
<!-- Attribute Definition -->
<apex:attribute name="CaseId" description="Salesforce Id of the Case whose Case Comments needs to be rendered" type="Id" required="true" assignTo="{!caseId}" />

<!-- Component Body -->
<apex:componentBody >
<apex:form >
<apex:pageBlock title="Case Comments" >
<apex:pageBlockButtons location="top">
<apex:commandButton action="{!NewComment}" value="New"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!Comments}" var="comment">
<apex:column headerValue="Action">
<apex:outputLink value="/{!comment.cComment.Id}/e?parent_id={!caseId}&retURL=/{!caseId}">Edit</apex:outputLink>&nbsp | &nbsp
<apex:commandLink action="{!deleteComment}" value="Del">
<apex:param name="CommentId_d" value="{!comment.cComment.Id}"/>
</apex:commandLink>&nbsp | &nbsp
<apex:commandLink action="{!makePublicPrivate}" value="{!comment.PublicPrivateAction}">
<apex:param name="CommentId_p" value="{!comment.cComment.Id}" />
</apex:commandLink>
</apex:column>
<apex:column headerValue="Public" value="{!comment.cComment.IsPublished}" />
<apex:column headerValue="Comments">
<apex:outputText escape="false" value="{!comment.commentText}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:componentBody>
</apex:component>

 

 2. Apex Code

public with sharing class CaseCommentsComponentController {

public Id caseId {get; set;}
public cComments[] comments{
get{
List<cComments> comments = new List<cComments>();
for(CaseComment comment : [Select LastModifiedDate, LastModifiedBy.Id, LastModifiedBy.Name, IsPublished, CreatedDate, CreatedBy.Id, CreatedBy.Name, CommentBody From CaseComment c where ParentId = :caseId order by c.LastModifiedDate desc])
{
cComments tempcComment = new cComments();
tempcComment.cComment = comment;

// Build String to display.
tempcComment.commentText = '<b>Created By: <a href=\'/' + comment.CreatedBy.Id + '\'>' + comment.CreatedBy.Name + '</a> (' + comment.CreatedDate.format() + ') | ';
tempcComment.commentText += 'Last Modified By: <a href=\'/' + comment.LastModifiedBy.Id + '\'>' + comment.LastModifiedBy.Name + '</a> (' + comment.LastModifiedDate.format() + ')</b><br>';
tempcComment.commentText += comment.CommentBody;

if(comment.IsPublished)
tempcComment.PublicPrivateAction = 'Make Private';
else
tempcComment.PublicPrivateAction = 'Make Public';
//Add to list
comments.add(tempcComment);
}
return comments;
}

set;
}

public PageReference NewComment()
{
PageReference pr = new PageReference('/00a/e?parent_id='+ caseId + '&retURL=%2F' + caseId);
pr.setRedirect(true);
return pr;
}

public PageReference deleteComment()
{
Id commentId = ApexPages.currentPage().getParameters().get('CommentId_d');

for(cComments Comment : comments)
{
if(Comment.cComment.Id == commentId)
{
delete Comment.cComment;
break;
}
}

PageReference pg = new PageReference('/' + caseId);
pg.setRedirect(true);
return pg;
}

public PageReference makePublicPrivate()
{
Id commentId = ApexPages.currentPage().getParameters().get('CommentId_p');
for(cComments Comment : comments)
{
if(Comment.cComment.Id == commentId)
{
Comment.cComment.IsPublished = !Comment.cComment.IsPublished;
if(Comment.cComment.IsPublished)
Comment.PublicPrivateAction = 'Make Private';
else
Comment.PublicPrivateAction = 'Make Public';

update Comment.cComment;
break;
}
}
PageReference pg = new PageReference('/' + caseId);
pg.setRedirect(true);
return pg;
}

public class cComments {

public CaseComment cComment {get; set;}
public String commentText {get; set;}
public String PublicPrivateAction {get; set;}
}
}

 Hope it is helpful to you.

 Let me know your views on the code above or if you have any questions

Message Edited by Rajesh Shah on 10-16-2009 08:03 PM