0

I have completed around 100% of the requirement , only part i am struggling to show the correct value of the two boolean field against there Parent

For ex : Parent A : Child 1: (Field -- Unreleasedcheck==True)
                  : Child 2:  (Field -- Unreleasedcheck==False)

In My VF page Both the values are showing as False: Please help me out to put the correct value against each record as they are child of the Same Parent.

Please find the code below: Controller :

    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();



        }

        transient public  boolean unreleasedCheck{get;set;}
        transient public  boolean 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 Id, 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(Integer i=0;i<a.size();i++){
                        unreleasedCheck = a[i].Unreleased_Check__c;
                        unreleasedCertificat = a[i].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;     
}

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" >{!d.docNumber}</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:inputcheckbox value="{!unreleasedCheck}"/>
               </apex:column> 

                <apex:column headerValue="{!$ObjectType.Case_Associated_Document__c.fields.Unreleased_Certificate__c.label}" >
                   <!-- <apex:inputcheckbox value="{!unreleasedCertificat}"/>-->
               </apex:column> 


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

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

The problem with above code is unreleasedCheck is not associated with any record. So will show the last value assigned to it. You can overcome this problem by using a wrapper class. Create a wrapper class, add cdocs list and unreleasedCheck to it and initialize it in your way in APEX code. In VF, iterate the wrapper class list. You will get the output as required.

Your Answer

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