• donr
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Below is a simple test I have written, all it suppose to do is a select an account and upsert it. No matter what I try I cannot get the select statement to any return values. I've opened it up to accept anything but it seems no matter what I do and not matter what object I try no records are returned. 

 

I'm at a loss to why no values are returned when I am certain there are many rows. I am logged in as Platform sys admin when running these tests. I'm using force.com development environment. 

 

Is there a limit or something in SF I'm running into or ??

 

Help me.. Will Robinson

 

public class ShareTriggerTestMethod 
  {
    static testMethod void MySharingTest()
      {    
         
        //get a acount to update

        account acc = [select Id, name, comment__c from account limit 1];

     

         acc.comment__c = 'test';
         
         // upsert data causing the trigger to fire.
         Test.startTest();
           upsert acc;
         Test.stopTest();
      }
  }

  • August 08, 2012
  • Like
  • 0

Below is a simple test I have written, all it suppose to do is a select an account and upsert it. No matter what I try I cannot get the select statement to any return values. I've opened it up to accept anything but it seems no matter what I do and not matter what object I try no records are returned. 

 

I'm at a loss to why no values are returned when I am certain there are many rows. I am logged in as Platform sys admin when running these tests. I'm using force.com development environment. 

 

Is there a limit or something in SF I'm running into or ??

 

Help me.. Will Robinson

 

public class ShareTriggerTestMethod 
  {
    static testMethod void MySharingTest()
      {    
         
        //get a acount to update

        account acc = [select Id, name, comment__c from account limit 1];

     

         acc.comment__c = 'test';
         
         // upsert data causing the trigger to fire.
         Test.startTest();
           upsert acc;
         Test.stopTest();
      }
  }

  • August 08, 2012
  • Like
  • 0

Hello.  I have a VF page where a user can enter search parameters for a PersonAccount.  In the controller, i instantiate a dummy Account - and use that for the inputField info (apex:InputField value="{!patientSearchAccount.LastName}".  The issue is that on the VF page, the firstname and lastname fields are "disabled" - presumably because the system doesn't know it's a person acct.  How do i make this work?

 

Note, i found a similar thread (http://boards.developerforce.com/t5/Visualforce-Development/Creating-a-Person-Account-with-Visualforce-and-a-Custom/m-p/137953) - but this question is never answered there. 

 

Thanks for your time.

chris

 I'm getting the same error both in the test class and while inserting a record from the user interface:

 

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_PARTNER_NETWORK_STATUS, invalid status for partner network operation

 

The trigger is to forward custom object SSV to a connection on insert. The connection is found on related object. It has "aceepted" status and the SSV is published and subscribed. The test class queries the data base for an accepted connection so it cannot have other status. I also checked the status in the date base, querying by the connectionId and it is for sure accepted.

 

What's more interested the behaviour had been already tested and the error didn't occur before.

 

The trigger is:

 

    List<String> SSV_ID = new LIst<String>();
    List<SSV__c> visits = new List<SSV__c>();

   
   
   
    for (SSV__c ssv: trigger.new)   {
        SSV_ID.add(ssv.id);
    }
   
    visits = [select id, Case__r.Network__c, case__r.Network__r.Organizer__c, case__r.Network__r.Member__c,
            Landmark__c, case__r.Network__r.Organizer__r.BAW__c, case__r.Network__r.Organizer__r.AAW__c,
            Visit_Start__c, Visit_End__c from SSV__C where id in: SSV_ID];
   
    system.debug('ssv, i.e. visits: ' + visits.size());
   
    if (trigger.isInsert) {
       
        List<String> accid = new List<String>(); //related accounts id
        Map<String, String> SSVAccount = new Map<String, String>();
        Map<String, String> AccountSSV = new Map<String, String>();
        List<VSV__c> RelatedVSV = new List<VSV__c>();

       
        //RelatedVSV = [select id, SSV__c from VSV__c where SSV__c in: SSV_ID for update];
       
        system.debug('Organizer ' + visits[0].case__r.Network__r.Organizer__c);
   
        for (SSV__c v: visits) {
            accid.add(v.case__r.Network__r.Organizer__c);
            SSVAccount.put(v.id, v.case__r.Network__r.Organizer__c);
            AccountSSV.put(v.case__r.Network__r.Organizer__c, v.id);
        }
    
   
        List<PartnerNetworkConnection> connections = new List<PartnerNetworkConnection>();
       
        connections = [select Id, ConnectionStatus, AccountId, ConnectionName from PartnerNetworkConnection
        where AccountId in: accid];
       
        if (connections.size()<1) {
            for (SSV__c ssv: trigger.new)   {
                ssv.adderror('No S2S connection found to the related Organizer. Please, establish connection, publish necessary data and try again!');
            }
        } else {
            system.debug('Jestem w else');
            List<PartnerNetworkRecordConnection> forwardedSSV = new List<PartnerNetworkRecordConnection>();
            List<SSV__c> VIS = new List<SSV__c>();
           
            for(PartnerNetworkConnection network : connections) { //for All partner accounts whose SSVs have been modified
                PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
                system.debug('network.id: ' +network.id);
               
               
                newrecord.ConnectionId = network.Id;   
               
                system.debug('partner network status is: ' +network.ConnectionStatus);
                system.debug('parnter connection name ' + network.connectionName);
              
                for (SSV__c v: trigger.new) {
                    if (network.AccountId == SSVAccount.get(v.id)) {
                        if (network.connectionStatus!='Accepted') {
                            v.adderror('No accepted connection found to the related Organizer. Please, establish connection, publish necessary data and try again');
                        } else {
                            VIS.add(v); // only SSV under current AccountId
                        }
                       
                    }
                }
               
                for (SSV__c v1 : VIS) {
                    newrecord.LocalRecordId = v1.id;
                    newrecord.SendEmails = true;
                    //newrecord.RelatedRecords = 'VSV__c';
                    forwardedSSV.add(newrecord);
                }
            }
                   
            try {          
                insert forwardedSSV;
            } catch (exception e) {
                for (SSV__c s: trigger.new) {
                    //s.adderror('The record(s) cannot be saved! Please check that the SSV is published to the related account and subscribed by it.');
                    system.debug('Im the error: ' +e);
                    system.debug('forwardedSSV[0].ConnectionId: ' +forwardedSSV[0].ConnectionId);
                }
               
            }

        }

 

 

 ------------The test method is:--------------

 

 static testMethod void test_ssvCreate() {
        
        Account a = new Account(Name = 'Test');
        
        Account org2 = new Account(Name = 'ABC', BAW__c =120, AAW__c=60 );
        
        //Test.startTest();
        List<PartnerNetworkConnection> connections = [select id, AccountId, ConnectionStatus
            from PartnerNetworkConnection where  (connectionStatus='Accepted' and AccountId!=null)];

        
        system.debug('connection ' + connections.size());
        
        if (connections.size()>0) {
        
            Account organizer = [select id, name from Account where id = :connections[0].AccountId];
            
            system.debug('organizer name ' + organizer.name);
            
            if (organizer!=null) {
                
            
                Account member = new Account(
                    Name = 'member1');
                
                insert member;
                
                
                Network__c n = new Network__c(
                    Organizer__c = organizer.id,
                    Member__c = member.id);
                    
                insert n;
                
                system.debug('Organizer on the network ' + n.Organizer__c);
                
                Case c = new Case(
                    Status ='New',
                    Origin = 'Phone',
                    Network_ID__c = n.id,
                    Ext_Contact_ID__c = '123c',
                    Ext_Account_ID__c = '456a');
                
                insert c;
                
                Case testc = [select id, Network__c, Network__r.Organizer__c from case where id= : c.id];
                
                system.debug('case id ' + c.id);
                system.debug('Network on the case ' + c.Network__c);
                system.debug('Organizer on the case ' + testc.Network__r.Organizer__c);
                
                Landmark__c l = new Landmark__c(
                    Name = 'test',
                    countrycode__c = 'pl',
                    DisplayName__c = 'displaytest',
                    Account__c = Member.id);
                
                insert l;
                
                SSV__c s1 = new SSV__c(
                    Visit_Start__c = datetime.now(),
                    Visit_End__c = datetime.now(),
                    Case__c = c.id,
                    Landmark__c = l.id
                    );
                
                insert s1;
               

 

 

 

 --------- The test result is: ------------------------

 

 

20090921204715.339:Trigger.SSV_share: line 58, column 17: network.id: 04P800000009ZtCEAU
20090921204715.339:Trigger.SSV_share: line 63, column 17: partner network status is: Accepted
20090921204715.339:Trigger.SSV_share: line 64, column 17: parnter connection name ABC Manufacturing Corporation
20090921204715.339:Trigger.SSV_share: line 66, column 17: SelectLoop:LIST:SOBJECT:SSV__c
20090921204715.339:Trigger.SSV_share: line 77, column 17: SelectLoop:LIST:SOBJECT:SSV__c
20090921204715.339:Trigger.SSV_share: line 86, column 17: Insert: LIST:SOBJECT:PartnerNetworkRecordConnection
20090921204715.339:Trigger.SSV_share: line 86, column 17: DML Operation executed in 38 ms
20090921204715.339:Trigger.SSV_share: line 88, column 14: SelectLoop:LIST:SOBJECT:SSV__c
20090921204715.339:Trigger.SSV_share: line 90, column 18: Im the error: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_PARTNER_NETWORK_STATUS, invalid status for partner network operation
20090921204715.339:Trigger.SSV_share: line 91, column 18: forwardedSSV[0].ConnectionId: 04P800000009ZtCEAU

  • September 21, 2009
  • Like
  • 0

I'm having a problem with the firstname and lastname inputField on my visualforce page designed to create a new Person Account. The input field for the first and last name fields are showing up as non-editable. I have read several posts and am attempting to set the recordTypeID in the controller, but as you will see in my simple example it does not appear to be setting properly.  Any help with the following greatly appreciated.

 

Page:

<apex:page controller="newPersonAccountController" tabStyle="Contact">
<apex:sectionHeader title="New Person Account Header"/>
<apex:form >
<apex:pageBlock title="New Person Account Block">

<apex:facet name="footer">
<apex:commandButton action="{!save}" value="Save" styleClass="btn"/>
</apex:facet>

<apex:pageBlockSection title="Person Account Section">
<apex:panelGrid columns="1">
<apex:inputField value="{!PersonAccount.phone}"/>
<apex:inputField value="{!PersonAccount.firstname}"/>
<apex:inputField value="{!PersonAccount.lastname}"/>

<apex:outputLabel value="{!PersonAccount.RecordTypeID}"/>
<apex:outputLabel value="{!PersonAccount.isPersonAccount}"/>
</apex:panelGrid>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Controller:

 

/*
* This class is the controller behind the New PersonAccount
* wizard.
*/

public class newPersonAccountController {

// Variables
account PersonAccount;

// Get methods.

public account getPersonAccount() {
if(PersonAccount == null) PersonAccount = new account(RecordTypeId='012A000000006JQ', firstname='Sammy', lastname='Snead');
return PersonAccount;
}

// This method performs the save for both objects, and
// then navigates the user to the detail page.
public PageReference save() {

// Create the account.
insert PersonAccount;

// Finally, send the user to the detail page

PageReference providerPage = new PageReference('/' + PersonAccount.id);

providerPage.setRedirect(true);
return providerPage;
}
}

 

Results:

 

The vf page displays with phone as an editable field and firstname and lastname as non-editable fields.  The recordtypeID is displayed, the isPersonAccount field shows as false.  The record DOES save correctly and creates the person account with the correct record type. 

 

Any thoughts on how to get the firstname and lastname fields to be editable fields, or any relavent sample code greatly appreciated.

 

 

Thanks!
Message Edited by ocsden1 on 07-14-2009 09:39 AM