0

Req is as below: I need to display the variable from the extension class of the Standard controller: Variable name is :

String unreleasedCheck{get;set;}
String unreleasedCertificat{get;set;} 

VF Page `

<apex:page standardController="Case" extensions="SFG_WmgDocController" lightningStylesheets="true">
    <style>
        #editDocs { padding: 4px 3px; text-decoration: none; }
    </style>

    <style type="text/css">
        .col1 {width:80px; text-align:left;}
        .col3 {width:200px; text-align:left;}        
    </style> 


    <apex:pageMessages />
    <apex:form >
        <apex:pageBlock rendered="{!cdocs.size > 0}"  id="pageBlock"> 
            <apex:pageBlockTable value="{!cdocs}" var="d" columnClasses="col1,col1,col1,col1,col1,col1,col1,col1,col3"> 

                <apex:column headerValue="{!$ObjectType.Case_Associated_Document__c.fields.Document_Id__c.label}" >
                    <apex:outputLink value="{!d.sfsImagingUrl}" target="_blank" >{!$ObjectType.Case_Associated_Document__c.fields.Document_Id__c.label}</apex:outputLink>
                </apex:column>

                <apex:dataTable value="{!Case.Associated_Documents__r}" var="c">
                <apex:column headerValue="Document ID" value="{!c.Document_Id__c}" />
                 </apex:dataTable>   
                <apex:column headerValue="Document Type" value="{!d.docTypeDescription}" />
                <apex:column headerValue="Account Number" value="{!d.outsideAccountNumber}" />
                <apex:column headerValue="SSN/TIN" value="{!d.taxId}" />
                <apex:column headerValue="{!$ObjectType.Case_Associated_Document__c.fields.Unreleased_Check__c.label}" >
                    <apex:variable value=""/>
                   <apex:outputText value="{!unreleasedCheck}"></apex:outputText>
               </apex:column>         
                <apex:column headerValue="{!$ObjectType.Case_Associated_Document__c.fields.Unreleased_Certificate__c.label}" ></apex:column>

            </apex:pageBlockTable>
        </apex:pageBlock>

    </apex:form>
    <apex:outputText value="{!$Label.ANN_Err_NoResults}" rendered="{!0 = cdocs.size}" />
</apex:page>`

Controller as below :

    public with sharing class SFG_WmgDocController {

    // Properties
    public SFG_WMGDoc cdoc { get; private set; }
    public String caseAssoDocId { get; set {caseAssoDocId = value;}} 

    // Constructor
    public SFG_WmgDocController(ApexPages.StandardController cDocController) {
        this.caseId = cDocController.getId();


    }
          String unreleasedCheck{get;set;}
          String unreleasedCertificat{get;set;} 


    public SFG_WMGDoc[] cdocs {
        get{
            if (null == cdocs) {
                cdocs = new SFG_WMGDoc[] {};

                    // get the document keys to query Filenet
                    List<SFG_WMGDoc.Key> docTypeCode = new List<SFG_WMGDoc.Key>();
                Case_Associated_Document__c[] a = [SELECT Document_Id__c,Comments__c, System__c, External_Id__c,Unreleased_Check__c,Unreleased_Certificate__c
                                                   FROM Case_Associated_Document__c WHERE Service_Request__r.Id = :caseId];

                for(Case_Associated_Document__c caseDoc : a){
                    unreleasedCheck = String.valueOf(caseDoc.Unreleased_Check__c);
                    unreleasedCertificat= String.valueOf(caseDoc.Unreleased_Certificate__c);
                }
                if (!a.isEmpty()) {
                    for (Case_Associated_Document__c d : a) {
                        docTypeCode.add(new SFG_WMGDoc.Key(d.System__c, d.Document_Id__c));
                    }
                    try {
                        cdocs = SFG_WMGDoc.load(docTypeCode);
                    } catch (MM.HttpException e) {
                        String[] docKeyStrings = new String[] {};
                            for (SFG_WMGDoc.Key k : docTypeCode) {
                                docKeyStrings.add(k.docCategoryCode + ':' + k.docTypeCode);
                            }
                        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 
                                                                   MM.format(Label.ANN_Err_DocPropsRequest, String.join(docKeyStrings, ', '))));
                    } catch (Exception e) {
                        ApexPages.addMessages(e);
                    }

                    // associate the external Ids with the documents
                    for (Case_Associated_Document__c d : a) {
                        for (SFG_WMGDoc i : cdocs) {
                            if (i.docTypeCode == d.Document_Id__c) {
                                  i.docNumber = d.External_Id__c;
                                break;
                            }
                        }
                    }
                } 
            }
            return cdocs;    
        }
        private set;
    }
    //--------------------------------------------------------------------------
    // Helpers
    private Id caseId;     
}

Requesting you all to help me in order to display the values of
String unreleasedCheck{get;set;}String unreleasedCertificat{get;set;}

On the VF page under suitable column.

  • Where Unreleased_Check__c and unreleased_Certificat __c are fields on the child object of Case – user74041 Sep 14 '19 at 9:51
1

It appears to me that you're not setting the values of the variables you're asking about in your question following this section of code:

    for(Case_Associated_Document__c caseDoc : a){
        unreleasedCheck = String.valueOf(caseDoc.Unreleased_Check__c);
        unreleasedCertificat= String.valueOf(caseDoc.Unreleased_Certificate__c);
    }

I don't know if your're expecting an array of these or a single value for the entire list you're iterating over.

If it's a single value you need to do something following the for loop like this:

  set {
        unreleasedCheck;
        unreleasedCertificat;
  }

I'd recommend you wait until after the try-catch block before you execute this code if possible. Otherwise, you should do some kind of null check before setting them. If there are multiple values, you'd need to set them inside the for loop and these should really be in a list or array.

| improve this answer | |

Your Answer

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