• SeattleSFDC
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
I used json2Apex to create the wrapper class, and I was able to get it displayed on my Visualforce page.  But now i want to add a radio button selection next to each row.  So that i user can select one record and have the passed back to a Salesforce custom object.  There's no Salesforce object in this wrapper class because it's based on the json reponse.  Is there a way to wrap my data in Visualforce if the response I'm using is not tied to a Salesforce object?  Documentation I'm finding online are for wrapper classes for Accounts, Contacts, etc.


VF:
            <apex:pageblockTable value="{!jsonRecords}" var="accWrap" rendered="{!jsonRecords.size != NULL}"> 
                <apex:column width="50px">
                <input type="radio" name="group1" value="{!accWrap.selected}"/>           
                </apex:column>            
                <apex:column value="{!accWrap.PARTY_NAME}" headerValue="Account Name"/>
               </apex:pageBlockTable>

Wrapper Class:
public class JsonWrapper {

        public class P_CUSTOMER_TBL_ITEM {
            public Boolean selected{get;set;} 
            public String PARTY_NAME{get;set;}

            public P_CUSTOMER_TBL_ITEM(string PARTY_NAME) {
                this.selected = false;
                this.PARTY_NAME = PARTY_NAME;

            }            

        }
  }
I'm trying to make an InputTextArea required based on a previous response.  To be specific, if the onSiteSupport radiobutton selection = 'Yes' then make onSiteSupportCoverage InputTextArea required, if the response is 'No' then onSiteSupportCoverage is not required.  What's the easiest way to accomplish this?  I tried an inline IF statement, but it's not working.

<div class="questionRadio"><span class="required">*</span> Onsite customer support?</div>
                    <div class="questionRadioInput">
                        <apex:selectRadio value="{!onSiteSupport}" id="onsite" required="true">
                            <apex:selectOption itemValue="Yes" itemLabel="Yes"/>
                            <apex:selectOption itemValue="No" itemLabel="No"/>
                        </apex:selectRadio>
                        <apex:message styleClass="customError" for="onsite"/>
                    </div>
                    
                    <div class="question"> If yes, then where?</div>
                    <div class="longInputWrapper">
                        <apex:inputTextArea value="{!onSiteSupportCoverage}" styleClass="longInput" id="onSiteSupportCoverage" required="{!If(onSiteSupport == 'Yes',true,false)}"/>
                        <apex:message styleClass="customError" for="onSiteSupportCoverage"/>
                    </div>


Hello,

 

I'm having issues with deploying changes to Production, and the error messages I'm recieving is "System.NullPointerException: Attempt to de-reference a null object".  Any ideas how to fix?

 

 

Test Failures:
Hide Section - approveDealRegVFTESTapproveDealRegVFTEST
Method NameTotal Time (ms)MessageStack Trace
approveDealRegVFTEST.siApprove3818.0System.NullPointerException: Attempt to de-reference a null objectClass.approveDealRegVFTEST.siApprove: line 482, column 1
approveDealRegVFTEST.productApprove4964.0System.NullPointerException: Attempt to de-reference a null objectClass.approveDealRegVFTEST.productApprove: line 252, column 1
Hide Section - RenewalNotificationControllerTEST
 
 RenewalNotificationControllerTEST
Method NameTotal Time (ms)MessageStack Trace
RenewalNotificationControllerTEST.testRenewalNotifications11992.0System.NullPointerException: Attempt to de-reference a null objectClass.RenewalNotificationController.mergeExistingFields: line 321, column 1 Class.RenewalNotificationController.mergeAndCreateMail: line 227, column 1 Class.RenewalNotificationController.sendMail: line 177, column 1 Class.RenewalNotificationControllerTEST.testRenewalNotifications: line 71, column 1

 

approveDealRegVFTest class Line 252:

 

String retURL = controller.save().getUrl();

 

approveDealRegVFTest class Line 482:

 

String retURL = controller.save().getUrl();

 

RenewalNotificationController class line 321:

    private String mergeExistingFields(String text, Opportunity opp) {
            Set<String> existingFields = opportunityFields.keySet();
            for (String mergeField : existingFields) {
                System.debug('mergeField = ' + mergeField);
                Integer index = text.indexOf(mergeField);
                while (index != -1) {
                    String fieldSoqlName = opportunityFields.get(mergeField);
                    String value = '';

                    if (fieldSoqlName.startsWith('Account')) {
                        Account a = opp.Account;
                        fieldSoqlName = fieldSoqlName.substring(8);
                        value = (String) a.get(fieldSoqlName); <-------LINE 321
                    }

 

RenewalNotificationController Class line 227:

        //merge existing fields
        String subject = emailTemplate.Subject;
        subject = mergeExistingFields(subject, opp);       <-----LINE 227

 

RenewalNotificationController Class line 177:

                //create the merged email and add it array
                Messaging.SingleEmailMessage mail = mergeAndCreateMail(templateDetails, wrapper.getOpportunity());     <------LINE 177
                mails.add(mail);

 

RenewalNotificationControllerTEST Test Class line 71:

 

    controller.sendMail();

 

 

 

So I'm trying to execute Javascript from a custom button on the Event object.  The alert(result) is coming back with nothing even though it should be returning my oppResult object with the oppId and errormessage.  Any ideas what I'm missing, or what needs to change?

 

 

The custom button:

 

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")} 

var meetingID = '{!Event.Id}'; 

var agree = confirm("Are you sure you want to create an opportunity?"); 
if(agree){ 

var result = sforce.apex.execute("MeetingOpportunity","createOpportunity",{meetingID: meetingID}); 

alert(result); 

}

 

 

Class:

global class MeetingOpportunity {

    webservice static OppResult createOpportunity(ID meetingID){
        
        OppResult res = new OppResult();
        
        //based on logic set variables in the result object
        res.errorMsg = 'oh no something broke';
        res.oppId = '01pW00000000000';
        
        system.debug(res);
        return res;
    }
    
    global class OppResult{
        global String errorMsg;
        global Id oppId;
    }
}

 

So I'm trying to execute Javascript from a custom button on the Event object.  The alert(result) is coming back with nothing even though it should be returning my oppResult object with the oppId and errormessage.  Any ideas what I'm missing, or what needs to change?

 

 

The custom button:

 

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")} 

var meetingID = '{!Event.Id}'; 

var agree = confirm("Are you sure you want to create an opportunity?"); 
if(agree){ 

var result = sforce.apex.execute("MeetingOpportunity","createOpportunity",{meetingID: meetingID}); 

alert(result); 

}

 

 

Class:

global class MeetingOpportunity {

    webservice static OppResult createOpportunity(ID meetingID){
        
        OppResult res = new OppResult();
        
        //based on logic set variables in the result object
        res.errorMsg = 'oh no something broke';
        res.oppId = '01pW00000000000';
        
        system.debug(res);
        return res;
    }
    
    global class OppResult{
        global String errorMsg;
        global Id oppId;
    }
}