0

I have a VFP that displays a list of cases and includes the case number column like this:

<apex:column >
    <apex:facet name="header">
        <apex:commandLink value="Case #" action="{!toggleSortSpecial}" rerender="results,sc,debug" status="busyCursor">
            <apex:param name="sortField" value="CaseNumber" assignTo="{!sortOrderSpecial}"/>
            <apex:outputPanel rendered="{!BEGINS(sortOrderSpecial,'CaseNumber')}">
                &nbsp;<apex:image value="{!IF(sortDirSpecial = 'desc','/img/arrowDown.gif','/img/arrowUp.gif')}"/>
            </apex:outputPanel>
        </apex:commandLink>
    </apex:facet>

    <!-- apex:outputLink value="/{!case.Id}">{!case.CaseNumber}</apex:outputLink -->
    <apex:outputText value="{0}">
        <apex:param value="{!case.CaseNumber}"/>
    </apex:outputText>
</apex:column>

The field displayed comes from a SoQL command that I build inside my Apex code:

soqlSpecial = 'SELECT Id, CaseNumber, Severity__c, Subject, Contact.Email, CreatedDate, OwnerId ' +
    'FROM Case ' +
    'WHERE CaseNumber IN (' + scl + ') ' +
    'ORDER BY ' + genSortOrder(sortOrderSpecial, sortDirSpecial);

This works fine except that the case.CaseNumber field is an eight-character string containing a number that is zero-filled, so the output looks like:

00002700
00002701

Screen space is always at a premium so I want to remove these leading zeros but I cannot find a way of doing it.

There do not seem to be any SOQL functions that I can add in to the SELECT to return a number instead of a string.

outputtext only has formatting options for numbers but not text, and it is smart enough to recognize that {!case.CaseNumber} is a string, so that's not an option either.

I am at a loss. It looks like I need to so the conversion/truncation before it reaches the VFP but I cannot see how.

Please note that I do not want to use RIGHT() to strip the leading zeros since I am egotistical enough to believe that this code will still be in use when we reach case 10,000 :-)

3

It can be done by VALUE function of visualforce:

<apex:outputText value="{!VALUE(case.CaseNumber)}" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.