• PreussenBlau
  • NEWBIE
  • 25 Points
  • Member since 2007

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 8
    Replies

I have a simple visual force page and controller for displaying an image within a custom object page layout.  The only issue is that I want to be able to display a generic image if the dynamic image is not available.  For example, I'm displaying inventory images.  If some inventory items have no image, then I'll display a "No Image Available" image.

 

I could add a checkbox to the custom inventory object and set it to true when there is an image or else leave it false when there won't be an image in my zip file.  But it would be easier if I could simply identify within the VF page or the controller whether the image was brought back so that I could determine whether to display the generic image or not..

public with sharing class InventoryImageController {
      public SPECIALTY_ITEM__c specialtyItem;
      public String Name       {get;set;}       
      public String ImageName  {get;set;}         

public InventoryImageController(ApexPages.StandardController controller)           
  { if (ApexPages.currentPage().getParameters().get('id')!= null) {       specialtyItem = [SELECT Id, Name
                    FROM SPECIALTY_ITEM__c                               WHERE Id = :ApexPages.currentPage().getParameters().get('id')];           }                         
 ImageName = specialtyItem.name + '_s.jpg';      
}
}

 I was trying to play around with rendered and an output panel but I'm not sure that's the route to take.  Is there an easy solution to this besides adding custom field to the custom object to set whether there will be an image in the zip file or not?

 

<apex:page standardController="SPECIALTY_ITEM__c" extensions="InventoryImageController">
<apex:variable var="imageVar" value="{!ImageName}"/>

<apex:outputPanel id="itemImagePanel" rendered="true">
<apex:image url="{!URLFOR($Resource.Inventory_Images, imageVar)}" id="itemImage" width="100" height="100" style="position:relative;left:235px"/>
<apex:image url="{!URLFOR($Resource.Inventory_Images, "NoImage_s.jpg")}" rendered="false" id="noImage" width="100" height="100" style="position:relative;left:235px"/>
</apex:outputPanel>
</apex:page>

 

 

In Java using a partner WSDL for the API:

 

I'd like to run a query, selecting several accounts based on the value of a particular field and then clear a few fields on the Account object for that list of accounts that was previously selected. 

 

Do I need to iterate through the list of accounts and update them one at a time or can I code something similar to the Apex language that allows me to update all the accounts with one line of code? 

 

APEX Example

global void execute(Database.batchableContext info, List<Account> scope){

List<Account> accsToUpdate = new List<Account>();

for(Account a : scope){

a.name = 'true';

a.numberOfEmployees = 69;

accsToUpdate.add(a);

}

update accsToUpdate;

}

The datatable of contacts is not displaying the new sort order after the group of contacts is changed due to the user changing the Account.

 

A user creates a new material orders record based on our custom object.  The VF page displays the Account name and the associated contacts tied to the account from where the user clicked the new material orders record button.  The contacts tied to the account are displayed in a datatable.  The user can sort the contacts by one of several columns related to contact data.  In addition, the contacts are contained within a wrapper class for the purpose of adding a select checkbox next to each contact.  Everything works fine, both the selection and the sorting of contacts.

 

But the user also has the option of selecting a different account.  If the user selects a new Account from the Account lookup field on the custom object, I do a PageReference which calls a few methods to pull the contacts associated with the new account.  The Contact table displays the new group of contacts without a problem.  However, when the user tries sorting the contacts for the new account, the contact datatable does not display the new sort order.  The View State indicates that the new group of contacts have not been sorted.  But my debug variable in the System Log shows me that in fact the contacts were sorted on the back end.  And in fact the response time from when the user clicks the column to sort and when the display changes would suggest that sorting is occuring.  Selecting the contact checkbox also does not appear to work in the View State (boolean remains false) though the display on the VF page shows the contact selected.

 

The sort functionality is an algorithym which is rather lengthy so I'd rather avoid adding it here.  I've tried using an actionFunction and actionSupport but I cannot get the VF page to display the new sort order of the contacts after I've changed the Account and refreshed the datatable of contacts.  The database displays the new group of contacts but clicking on columns does not display a new sort order as it did with the initial account.  Again, I'm certain from what I've seen in the System Log that the contacts are sorting properly.   The new sort order just doesn't render or show on the VF page.  Any help would be greatly appreciated. 

 

----------------------

<!-- ACCOUNT LOOKUP PANEL--> 
         <apex:pageBlockSectionItem >
            <apex:outputPanel id="AccountLookUp" title="AccountLookUp" rendered="{!searchOptions=='ByAccount'}">
               <div style="font-weight:bold;color:black;position:relative;left:350px;margin-top:0px;margin-bottom:3px"> Account &nbsp;         
                  <apex:inputField id="MO_Account"  value="{!Material_Order__c.Account__c}" style="font-weight:normal;width:400px;color:black;margin-                     top:15px;margin-bottom:3px">
                   </apex:inputField>    
                     <br/>
                  <apex:commandButton value="Lookup Contacts for this Account" action="{!refreshContacts}" reRender="contactPanel" style="position:relative;left:50px;margin-top:1px;margin-bottom:1px" status="status">
                  </apex:commandButton>
               </div>
            </apex:outputPanel>
         </apex:pageBlockSectionItem>

 

---------------------

 

 

<apex:outputPanel layout="block" id="contactPanel" style="position:relative;width:50%;left:200px">

   <apex:actionStatus id="contactStatus">
      <apex:facet name="stop">

         <apex:pageBlock title="Contacts for {!AccountName}"  rendered="{!AND(searchOptions=='ByAccount',ShowContacts==true)}">
<!--CONTACT DATA TABLE -->                       
       <apex:dataTable value="{!Contacts}" id="contactDataTable" var="listContacts" rows="{!ContactRowInc}" first="{!ContactRowMin}" width="100%">
<!--   CONTACT SELECT CHECKBOX COLUMN -->
             <apex:column >
                <apex:facet name="header"/>          
                    <apex:inputCheckbox value="{!listContacts.selected}" onclick="deSelectOthers(this)"/>
                    <apex:actionSupport event="onclick" reRender="refreshSelected"/>
             </apex:column>          

 

<!--   CONTACT NAME COLUMN -->
             <apex:column >
                <apex:facet name="header">
                   <apex:commandLink action="{!sortContactsByName}" onclick="deSelectAll(this)" reRender="contactPanel" status="nameCSortStatus">
                      <apex:actionStatus id="nameCSortStatus" startText="(Sorting...)">
                         <apex:facet name="stop">
                            Contact Name {!IF(ConSortBy == 'Name', IF(ConSortAsc,'▼','▲'),'')}
                         </apex:facet>
                      </apex:actionStatus>
                   </apex:commandLink>
                </apex:facet>

<!--   URLFOR allows us to display a single contact in a new Window.  -->
                   <apex:outputLink value="{!URLFOR($Action.Contact.View, listContacts.contact.Id)}" target="_blank">
                          {!listContacts.contact.Name}
                    </apex:outputLink>
             </apex:column>

 

<!--   CONTACT TITLE COLUMN -->
             <apex:column >
                <apex:facet name="header">
                   <apex:commandLink action="{!sortContactsByTitle}" onclick="deSelectAll(this)" reRender="contactPanel" status="titleCSortStatus">
                      <apex:actionStatus id="titleCSortStatus" startText="(Sorting...)">
                         <apex:facet name="stop">
                            Title {!IF(ConSortBy == 'Title', IF(ConSortAsc,'▼','▲'),'')}
                         </apex:facet>
                      </apex:actionStatus>
                   </apex:commandLink>
                 </apex:facet>
                 {!listContacts.contact.Title}
             </apex:column>

 

<!--   CONTACT FUNCTIONAL ROLE COLUMN -->            
             <apex:column >
                <apex:facet name="header">
                   <apex:commandLink action="{!sortContactsByRole}" onclick="deSelectAll(this)" reRender="contactPanel" status="roleCSortStatus">
                      <apex:actionStatus id="roleCSortStatus" startText="(Sorting...)">
                         <apex:facet name="stop">
                            Functional Role {!IF(ConSortBy == 'Role', IF(ConSortAsc,'▼','▲'),'')}
                         </apex:facet>
                      </apex:actionStatus>
                   </apex:commandLink>
                </apex:facet>
                {!listContacts.contact.FUNCL_ROLE_DESC__c}
             </apex:column>

 

<!--   CONTACT EMAIL ADDRESS COLUMN -->            
             <apex:column >
                <apex:facet name="header">
                   <apex:commandLink action="{!sortContactsByEmail}" onclick="deSelectAll(this)" reRender="contactPanel" status="emailCSortStatus">
                      <apex:actionStatus id="emailCSortStatus" startText="(Sorting...)">
                         <apex:facet name="stop">
                            Email {!IF(ConSortBy == 'Email', IF(ConSortAsc,'▼','▲'),'')}
                         </apex:facet>
                      </apex:actionStatus>
                   </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!listContacts.contact.Email}" />
             </apex:column>
            
<!--   CONTACT PHONE COLUMN -->
             <apex:column >
                <apex:facet name="header">
                   <apex:commandLink action="{!sortContactsByPhone}" onclick="deSelectAll(this)" reRender="contactPanel" status="phoneCSortStatus">
                      <apex:actionStatus id="phoneCSortStatus" startText="(Sorting...)">
                         <apex:facet name="stop">
                            Phone {!IF(ConSortBy == 'Phone', IF(ConSortAsc,'▼','▲'),'')}
                         </apex:facet>
                      </apex:actionStatus>
                   </apex:commandLink>
                </apex:facet>
                {!listContacts.contact.Phone}
             </apex:column>

             <apex:outputText id="refreshSelected" value="{!selectedContact.name}" />      
     
       </apex:dataTable>

 

---------------------------------

 

We have an apex trigger that updates account records with some contact data.  We also have a validation rule on the account record which prevents users from updating one field based on the absence of a value in another field.  Some of our account records are already in violation of the validation rule since the user area didn't want us removing data to comply with the rule but instead wanted to force users to enter more data when the go to update an account via the gui.

The issue occurs when a user updates a contact.  The apex trigger is activated on the contact update and tries to update the corresponding account record with data.  But the update fails if the validation rule kicks in and the existing account data is in violation of the validation rule.

Is it possible to add a line of formula code to a validation rule to recognize a trigger (as one would recognize a user profile NOT($Profile.Name = "System Administrator"), or role) and thereby avoid activating the validation rule?
We have an outbound message triggered by a workflow and based on the Account object.  The outbound XML message is sent to our url where our web services program parses it and sends it to a queue.  There it is picked up by another program, parsed and processed (java programs) updating  records via the SF API.

Here's the update flow:  A Parent Account is updated.  The outbound message based on the account sends several fields of data.  Our java programs update the contacts for that Parent Account using the XML message without issue.  The Branch Accounts are then updated using the same message, also without issue.

However, once the Branch (or child) accounts are updated, they in turn generate the same outbound message based on the account object's workflow which recognizes the changes.  Another XML message is sent to process and update the corresponding contacts for those Branch (child) Accounts.  This is where the error above occurs.  It is not consistent.  Sometimes the messages are retried and processed.  Most often they retry but don't complete.




I'd like to be able to update the owner field on account records via the Data Loader without affecting the Last Modified and Last Modified By fields.  Is this possible?

In Java using a partner WSDL for the API:

 

I'd like to run a query, selecting several accounts based on the value of a particular field and then clear a few fields on the Account object for that list of accounts that was previously selected. 

 

Do I need to iterate through the list of accounts and update them one at a time or can I code something similar to the Apex language that allows me to update all the accounts with one line of code? 

 

APEX Example

global void execute(Database.batchableContext info, List<Account> scope){

List<Account> accsToUpdate = new List<Account>();

for(Account a : scope){

a.name = 'true';

a.numberOfEmployees = 69;

accsToUpdate.add(a);

}

update accsToUpdate;

}

Hi,

 

I just have a test method best practice questions.

I have five Apex classes in my Dev environment length of the classes is around 500 lone of code each and they the SOQL and DML in classes are not touching the Apex governor limits as well.

Now I want to create the Test methods for them so that I can move them into the Production.  My question is, should I create a single test class for all the Apex classes or a different test class for each Apex class and what is the advantage and disadvantages to using the specific approach.

 

Any input is appreciable.

 

Cheers!

Rajan

I am doing a project. where i need to get values using lookup.

The object and the controller are custom. I want to take value to the visualforce page from controller.

We have an apex trigger that updates account records with some contact data.  We also have a validation rule on the account record which prevents users from updating one field based on the absence of a value in another field.  Some of our account records are already in violation of the validation rule since the user area didn't want us removing data to comply with the rule but instead wanted to force users to enter more data when the go to update an account via the gui.

The issue occurs when a user updates a contact.  The apex trigger is activated on the contact update and tries to update the corresponding account record with data.  But the update fails if the validation rule kicks in and the existing account data is in violation of the validation rule.

Is it possible to add a line of formula code to a validation rule to recognize a trigger (as one would recognize a user profile NOT($Profile.Name = "System Administrator"), or role) and thereby avoid activating the validation rule?

Hi

I'm calling my own SOAP web service and it always fails with:

Web service callout failed: Unable to parse callout response. Apex type not found for element =gah

It's a simple web service, with one operation, getInfo, returning a String.  I've added the WSDL below.
I "generate code from WSDL" (code also attached below) and call this code, which then fails. (The code generated fine).

The error occurs when I subsequently execute the code. ie.

Contactz11.ContactInfoImplPort c = new Contactz11.ContactInfoImplPort();
String r = c.getInfo();

This does actually call the SOAP service (I see that in my server log).  The problem appears to be in Apex's conversion of the resulting String.

Any advice gratefully accepted...

Jon


Here's the generated Apex Code:
//Generated by wsdl2apex

public class Contactz11 {
public class getInfo {
private String[] apex_schema_type_info = new String[]{'http://ws.memestorm.com/','false'};
private String[] field_order_type_info = new String[]{};
}
public class ContactInfoImplPort {
public String endpoint_x = 'http://memestorm.dyndns.org:8080/contactz';
private String[] ns_map_type_info = new String[]{'http://ws.memestorm.com/', 'Contactz11'};
public String getInfo() {
Contactz11.getInfo request_x = new Contactz11.getInfo();
Contactz11.getInfoResponse response_x;
Map<String, Contactz11.getInfoResponse> response_map_x = new Map<String, Contactz11.getInfoResponse>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://ws.memestorm.com/',
'getInfo',
'http://ws.memestorm.com/',
'getInfoResponse',
'Contactz11.getInfoResponse'}
);
response_x = response_map_x.get('response_x');
return response_x.gah;
}
}
public class getInfoResponse {
public String gah;
private String[] gah_type_info = new String[]{'gah','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://ws.memestorm.com/','false'};
private String[] field_order_type_info = new String[]{'gah'};
}
}


Here's the WSDL:

<?xml version="1.0" encoding="utf-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://ws.memestorm.com/" xmlns:ns2="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ContactService" targetNamespace="http://ws.memestorm.com/">
  <wsdl:types>
<xsd:schema xmlns="http://ws.memestorm.com/" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://ws.memestorm.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="getInfo" type="getInfo"/>
<xsd:complexType name="getInfo">
<xsd:sequence/>
</xsd:complexType>
<xsd:element name="getInfoResponse" type="getInfoResponse"/>
<xsd:complexType name="getInfoResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="gah" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
  </wsdl:types>
  <wsdl:message name="getInfo">
    <wsdl:part element="ns1:getInfo" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="getInfoResponse">
    <wsdl:part element="ns1:getInfoResponse" name="result">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="ContactInfo">
    <wsdl:operation name="getInfo">
      <wsdl:input message="ns1:getInfo" name="getInfo">
    </wsdl:input>
      <wsdl:output message="ns1:getInfoResponse" name="getInfoResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ContactServiceSoapBinding" type="ns1:ContactInfo">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getInfo">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="getInfo">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="getInfoResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="ContactService">
    <wsdl:port binding="ns1:ContactServiceSoapBinding" name="ContactInfoImplPort">
      <soap:address location="http://memestorm.dyndns.org:8080/contactz"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>