function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nwingnwing 

Simple Display Of Matching Document Name On Case

 

 

I am trying to do something I thought would be fairly simple, but I have hit a bump.  I am simply trying to display a list of Documents (and eventually use it as a direct link to view them) that have the case number being viewed in their name.  I am getting a 'list index out of bounds: 0' error on the layout when i refresh the page.  I have done something like this before without issue, but I apparently I am missing something....

 

Any advice appreciated....

 

Here is the controller...

 

public class RequestICBDocument_cls {
	public static List<Document> getLinkList()
	{
		String DocName = 'ICB_' + ApexPages.currentPage().getParameters().get('CaseNumber');
		
		List<Document> CurrentDoc =  [SELECT Id, Url FROM Document WHERE Name = :DocName]; 
		
		return CurrentDoc;
		
	}
}

 

 

 

Here is the Component  "ICB_Doc_List"

 

<apex:component Controller="RequestICBDocument_cls">

    <apex:repeat value="{!LinkList}" var="d" id="theRepeat">
        <apex:outputText value="{!d.Url}" id="theValue"/>
        <br/>
    </apex:repeat>
 
                
</apex:component>

 

 

 

Here is the VF Page that I place on the Layout...

 

<apex:page standardController="Case" tabStyle="Case" >
    <div style="background-color:#F3F3EC; height: 50px;">
        <c:ICB_Doc_List />
    </div>
</apex:page>

 

incuGuSincuGuS

Hello nwing,

 

I recommned you use the LIKE statement.

 

List<Document> CurrentDoc =  [SELECT Id, Url FROM Document WHERE Name LIKE :DocName]; 

 

Also i would code it like this to avoid certain errors, and to make it easier to make modifications:

 

 

public class RequestICBDocument_cls {
	public static List<Document> getLinkList()
	{
		String caseN = ApexPages.currentPage().getParameters().get('CaseNumber');
		List<Document> CurrentDoc = new List<Document>();		
		
		if(caseN != null){
			String filter = 'ICB_' + caseN;
			List<Document> docs =  [
			  SELECT Id, Url FROM Document WHERE Name LIKE :filter
			];
		}
		return CurrentDoc;
		
	}
}

 

 

Hope this helps, let me know how it works out.

Gaston.

 

nwingnwing

 

Thanks much for the suggestions on the apex code.  I am not getting an error anymore, however I am not getting any display either.  I have a document in there that should match the name search criteria, and I have even hardcoded the query so it should pull that record out, but the display is not working.  I am much better at the apex code side than the visualforce side, so I am not sure on where to go with that.

 

Any further help on that is much appreciated.  I keep troubleshooting, but I am missing something....

nwingnwing

incu,

 

After going through just about everything involved, it came back to the simple 'getParameters' call......  As in, get('CaseNumber') is apparently not a valid request from the Current Page..... 

 

I had to get the Id, requery for the Case Number, and then move on......

 

Other than that, everything was pretty good......

 

Thanks for the code tweak.....

incuGuSincuGuS

Happy to hear you got it working!

nwingnwing

 

As an update on this same topic, I would like to check a field on the case record IF it finds a relevant document upon the load of the case page. 

 

I am trying to put this together, but it isn't updating the record as I hoped.