• elnombre
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Hi there,

 

I am trying to assign cases generated by a portal user (from child account) to another portal user (from parent account).

 

From what I have read in these boards, changing ownership of cases is different from changing ownership of any other type of record (standard or custom).

 

BTW, I am not a pro by any means but slowly getting confident at coding triggers.

 

Any help will be appreciated.

 

Cheers

 

 

This is the trigger:

 

 

 trigger AssignCasesCreatedByCustPortUsers on Case (before insert) {

List<ID> ParentIdsofCases = new List<ID> (); // List of ParentIds of cases


// From the list of trigger records (in memory), build the list of ParendIds for those cases that need to be assigned to a portal user
for (Case c: trigger.new){
    if (c.account.parentid!= null){
        ParentIdsofCases.add (c.account.parentid);
    }
}
// Retrieve the list of users that are associated with the parentIds

List<Case> UpdatedCases = new List<Case> ();
List<user> UsersofParentIds = [Select id,contact.accountid From User Where contact.accountid IN:ParentIdsofCases];

//for (List<user> U: [Select id,contact.accountid From User Where contact.accountid IN:ParentIdsofCases])

for (Case C:Trigger.new){
  for (User U:UsersofParentIds) {
        If(c.account.parentid == u.contact.accountid){
            // assign case to user
            Case CaseToUpdate = C;
            CaseToUpdate.ownerid = u.id;
            UpdatedCases.add(CaseToUpdate);
        }
    }
}
update UpdatedCases;


}

Hi there,

 

I am a beginner with Apex... so do not be shocked, please.

 

 

I have this trigger:

 

 

 trigger PreventCustomerAccountDeletion on Account (before delete) {

for (Account CustAcc : Trigger.old) {
    if (CustAcc.Debtor_Code__c != null) {CustAcc.addError ('This account can not be deleted, it is an existing customer');
    }
    
}

}

 

 

And I have this class for unit testing:

 

 @isTest
private class PreventCustAccDeletionTest {

    static testMethod void CustAccDeletionTest () {
    
    Account CustAccTest = new Account (name='DTS',type='Other',RecordTypeId='01260000000DZLZ');
    
    insert CustAccTest;
    CustAccTest.Debtor_Code__c='10-44100';
    update CustAccTest;
    
        
    delete CustAccTest;
    
     
    System.assertEquals (CustAccTest.IsDeleted,False);

}

}

 

According to the IDE, the class runs succesfully and gives 100% coverage.

 

But it seems there is a problem with the trigger.  The error message says:  Unable to perform save on all files: An unexpected error has ocurred.  Please  try again or check the log file for details.

 

The log files is:

 

 Value(s) Found: Name=DTS , Debtor_Code__c=10-44100
Result: PASS - Continue
End Time: 20100110032114.297
*** Ending Account Validation Rule Evaluation for 0016000000NFDkp
20100110032114.014:Class.PreventCustAccDeletionTest.CustAccDeletionTest: line 31, column 2:     DML Operation executed in 60 ms
20100110032114.014:Class.PreventCustAccDeletionTest.CustAccDeletionTest: line 36, column 2: Delete: SOBJECT:Account
20100110032114.014:Class.PreventCustAccDeletionTest.CustAccDeletionTest: line 36, column 2:     DML Operation executed in 115 ms
20100110032114.014:Class.PreventCustAccDeletionTest.CustAccDeletionTest: line 40, column 5: System.assertEquals(Boolean, Boolean)
20100110032114.014:External entry point:     returning from end of method static testMethod void CustAccDeletionTest() in 428 ms

Cumulative resource usage:

Resource usage for namespace: (default)
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 500
Number of SOSL queries: 0 out of 20
Number of DML statements: 3 out of 100
Number of DML rows: 3 out of 500
Number of script statements: 6 out of 200000
Maximum heap size: 0 out of 1000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 10
Number of record type describes: 0 out of 10
Number of child relationships describes: 0 out of 10
Number of picklist describes: 0 out of 10
Number of future calls: 0 out of 10
Number of find similar calls: 0 out of 10
Number of System.runAs() invocations: 0 out of 20

Total email recipients queued to be sent : 0
Stack frame variables and sizes:
  Frame0

*** Ending Test PreventCustAccDeletionTest.static testMethod void CustAccDeletionTest()

Cumulative profiling information:

No profiling information for SOQL operations.

No profiling information for SOSL operations.

No profiling information for DML operations.

No profiling information for method invocations.

 

 

Any help will be highly appreciated.

 

Cheers,

 

David

I've searched here and seen a number of posts with the above error, but I haven't found anything that addresses my issue with it.  When Customer Portal users create a case and select a contact for the case from their account, the case will not save and gives the error, "insufficient access rights on cross-reference id".

The system will only let them create cases with themselves as the ContactName (and owner).  If I then try to reassign within SF (Sys Admin) I cannot change the contactname to anything other than the Customer Portal owner.  If I do and save it, the system changes name right back.  The Customer Portal profiles have read/edit permissions.  I've also looked through the Field security and don't see anything at all.  Help!?