• Alibaba1
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies

Hi,

I have a strange issue with creating chatter group with my Apex code.

Simple code for creating CollaborationGroup works fine in development environment, but raises NinjaValidationException when installing uploaded package.

I didn't find any documentation about this exception and neither any information about what is wrong with the code.

 

Code:
CollaborationGroup grpRec = new CollaborationGroup();

grpRec.Name = 'New';

grpRec.CollaborationType = 'Public';

insert grpRec;

 

This code fails in insert statement
Exception log:

Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, com.ninja.common.exception.NinjaValidationException: workspaceId - This field is required: []

 

As you can see, it says that some field is required, but instead of required field names there is an empty list.

 

Can anybody advice what is wrong here, or is there any workaround for the issue?

I have a field set (LILLY_QR_OL_SR) setup for a custom object (Standing_Request__c) and want to iterate through that set displaying the label for the field and then the value in table format.  This works great until I attempt to us a lookup.  I want to display the Owner's first name and last, owner is a lookup to a user.  When I add in the lookup fields for first name and last I get this error....

Unknown property '$ObjectType.Standing_Request__c.fields.User__r'

 

Here is the section of the VF page that is relevant...

 

<table>
<apex:repeat value="!$ObjectType.Standing_Request__c.FieldSets.LILLY_QR_OL_SR}" var="f">
 <tr>
  <td>
   <apex:outputText value="!$ObjectType.Standing_Request__c.Fields[f].label}" />
  </td>     	
  <td>
   <apex:outputText value="{!obj[f]}"/>
  </td>
 </tr>
</apex:repeat>
</table>

 

 

We use Visualforce binding to display results from different object queries based on user selection. An admin can dynamically define the query we run so Visualforce binding is perfect for this.

 

Our code has broke in Summer 11. We get errors whenever results for a different object are retrieved. The new field change does not appear to be respected by Visual Force.

 

I was able to write the following test code to illustrate. When you run you will see 10 accounts in your org. Now change the dropdown to contacts, and you see a binding error.  It looks like Visualforce isn’t refreshing the QueryViewDisplayFields as expected. As mentioned, this functionality worked before but is broken in the Summer release.  If you change the selected option to ‘Contacts’ in the constructor, you’ll see that the contacts display fine. Now if the user changes the options to accounts the binding breaks.

 

<apex:page controller="BindingTest">
<apex:form >

<apex:outputLabel dir="" value="Showing: " />
                &nbsp;&nbsp;&nbsp;
<apex:selectList multiselect="false" value="{!SelectedOption}" size="1">    
        <apex:selectOptions value="{!OptionsList}" id="recordOptions" />
        <apex:actionSupport event="onchange" status="counterStatus"
            oncomplete="ReadData();" rerender="none"  />                
</apex:selectList>

<apex:actionFunction name="ReadData"
    action="{!ReadData}" rerender="SearchResults" />

<apex:pageBlock id="SearchResults" >
     
        <apex:pageblocktable value="{!QueryViewRecords}" var="viewRow">

        <apex:repeat value="{!QueryViewDisplayFields}" var="myfield" id="innerset">
        <apex:column value="{!viewRow[myfield]}" />
        </apex:repeat>
                                        
        </apex:pageblocktable>                

</apex:pageBlock>

</apex:form>
</apex:page>

 

 

public with sharing class BindingTest
{
    public String SelectedOption {get; set;}

    public List<SelectOption> OptionsList {get; set;}
    public List<SObject> QueryViewRecords {get; set;}
    
    public List<String> QueryViewDisplayFields
    {
        get
        {
            List<String> returnResults = new List<String>();    
            
            if( SelectedOption == 'Accounts' )
            {            
                returnResults.add('name');
                returnResults.add('phone');
                returnResults.add('annualrevenue');
            }
            else
            {            
                returnResults.add('firstname');
                returnResults.add('lastname');
            }

            return returnResults;            
        }
    }
    
    public BindingTest()
    {
        OptionsList = new List<SelectOption>();
        OptionsList.add(new SelectOption('Accounts', 'Accounts'));
        OptionsList.add(new SelectOption('Contacts', 'Contacts'));
        
        SelectedOption = 'Contacts';
        ReadData();
    }

    public void ReadData()
    {
         if( SelectedOption == 'Accounts' )
         {
             QueryViewRecords = [select name, phone, annualrevenue from account limit 10];
         }
         else
         {
             QueryViewRecords = [select firstname, lastname from Contact limit 10];         
         }
    }
}