0

Trying to build a webpage for teams to be able to submit cases and attachments. For some reason I am getting a "Could not resolve field 'Name' from value binding '{!cs.Name}' in page ProductCaseExternal" error and even though I add the standard set controller I am still getting an error. Am I missing something on this for where I need to be adding this?

VF => ProductCaseExternal:

<apex:page Standardcontroller="Case" extensions="attachController3" showheader="false" >
<html lang="en">
    <head>
        <link href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" rel="stylesheet" media="screen"/>

        <!-- Bootstrap -->
        <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/bootstrap.min.css" rel="stylesheet" media="screen"/>
        <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/now-ui-kit.min.css?v1.2.0" media="screen"/>
        <title>Submit a Case</title>
        <style>

            p, li, .description{
            font-weight: 400;
            line-height: 1.8rem;
            }

            .paddingTop{padding-top: 2rem;}
            }

            .background-black{background: #2196f3;}

            .background-black:hover, 
            .background-black:focus{background: #2386d3 !important;}      

            section .section-inner h2{color: #fff;}

            .round {
            border-radius: 100px;
            margin: 0;
            color: #9a9a9a
            }

            .longBox{height: 100px;}


            @media screen and (max-width: 500px){
            .brand .h1-seo{
            font-size: 2.2rem;
            }

            }

        </style>
    </head>
    <body>
        <div class="container">
            <apex:form >
                <form class="form-signin"><br/><br/><br/>
                    <br/><h2 class="form-signin-heading">Create a Ticket</h2><br/><br/>
                    <h5 class="form-signin-heading">Email</h5><br/>
                    <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Email__c}" required="true"/>
                    <br/><h5 class="form-signin-heading">Subject</h5><br/>
                    <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Subject}" required="true"/>
                    <br/><h5 class="form-signin-heading">What are you experiencing?</h5><br/>
                    <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.What_are_you_experiencing__c}" required="true"/>
                    <br/><h5 class="form-signin-heading">Where is the location of your issue?</h5><br/>
                    <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Location_of_issue__c}" required="true"/>
                    <br/><h5 class="form-signin-heading">Source Type</h5><br/>
                    <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Source_Type__c}" required="true"/>
                    <br/><h5 class="form-signin-heading">Description</h5><br/>
                    <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control longBox" value="{!case.Description}" required="true"/><br/>
                    <button class="btn btn-primary btn-block btn-lg background-black btn-round round " type="submit">Submit</button><br/><br/><br/>
                    <apex:pageBlock >

                        <apex:pageBlockButtons location="top">
                            <apex:commandButton id="uploadAttachment" value="Upload" action="{!uploadAttachment}"/>
                        </apex:pageBlockButtons>

                        <apex:pageBlockSection columns="1" id="theBlock">

                            <apex:inputField value="{!CS.CaseNumber}" id="bname"/>

                            <apex:repeat value="{!fileList}" var="fl">

                                <apex:pageBlockSectionItem >
                                    <apex:outputLabel >Attachment</apex:outputLabel> 
                                    <apex:inputFile value="{!fl.body}" filename="{!fl.Name}" id="file" accept="docx, txt, xlsx, pdf" filesize="800" size="50" /> 
                                </apex:pageBlockSectionItem>
                            </apex:repeat>

                        </apex:pageBlockSection><br/>
                        <apex:outputLabel >Please before you attach, click "Add File" to add the number of files you want to upload:&nbsp;&nbsp;</apex:outputLabel>
                        <apex:commandButton id="AddAtt" value="Add File" action="{!AddAttachs}"/>

                    </apex:pageBlock>
                </form>
            </apex:form>
        </div>
        <!-- /container -->
        <!-- Bootstrap core JavaScript
================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
    </body>
</html>
</apex:page>

Apex:

public class attachController3 {

public List<Attachment> fileList {get; set;}
public Case cs {get; set;}
public Attachment attach {get; set;}
public ApexPages.StandardSetController stdCntrlr {get; set;}
public attachController3(ApexPages.StandardController std){

}

public attachController3() {
    cs = new Case();

    attach = new Attachment();
    fileList = new List<Attachment>();
    fileList.add(attach);
    //AddAttachs();
}

public Case getCS(){
    if(cs == null) 
        cs = new Case();
    return cs; 
}

public List<Attachment> getAttachments(){
    if(fileList == null) 
        fileList = new List<Attachment>();
    return fileList; 
}

public PageReference AddAttachs() {
    fileList.add(new Attachment());
    return null;
}

public PageReference uploadAttachment() { 
    insert cs;

    if(cs != null) {            
        List<Attachment> attachments = new List<Attachment>();                               

        for(Attachment att : fileList)              
        { 
            if(att.name != null && att.body != null)
                attachments.add(new Attachment(parentId = cs.Id, name = att.name, body = att.body)) ;                
        }
        if(attachments != null){
            upsert attachments;                 
            ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.INFO, attachments.size() + ' file(s) uploaded successfully'));                                              
        }else {
            ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, 'Error uploading file'));
        }              
    }                    

    return null;      
}   

}
1

You are using Case object and Case don't have Name field. You need to use CaseNumber instead. CaseNumber is an AutoNumber field so you won't edit it either.

  • I updated that to CaseNumber but I am now getting an error "Unknown property 'CaseStandardController.contentType'" – Joshua Anderson Feb 1 at 8:50
  • @JoshuaAnderson because you are using contentType on VF page but you have not declared it. Declare a public [property in class name contentType – Tushar Sharma Feb 1 at 8:51
  • I updated the code above and I am getting no errors but it also doesn't seem to be working. The code that I found online that I was trying to use was supposed to allow an external user on a site be able to add however many files that they are wanting and then submit a case after that. When I go to select add it errors out and when I go to submit the case it is not creating the case. Is there anything on this code that you might see that is causing this issue? – Joshua Anderson Feb 5 at 21:29

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.