• ne-rm-team
  • NEWBIE
  • 0 Points
  • Member since 2008

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

Hi,

According to Apex-Guide: Can delete original object using a DML operation on trigger after update; According to Test-Method: DML statment cannot operate on trigger.new or trigger.old

that was my previous message subject  but it seems a bit to long ;)

So, why the apex-guide assert that you can delete the original object, when on the other hand I get an error in the test-log.

trigger RunMyJob on myJob__c (after update)

{

myJob__c mjn = new myJob__c();

insert mjn;

SOmyCreateBacklogs.createBack(trigger.new[0]);

myJob__c old = trigger.new[0];

delete old;

}

 

Does anyone knows what I'm doing wrong?

 

Thanks and best regards

Sascha

  



Message Edited by ne-rm-team on 12-05-2008 04:47 AM
Hi,
 
hi have a little Apex program that i wrote and a test class too. Everything works fine in the Sandbox and the testcoverage is 100%. I can run the Test from the Sandbox or from the Ecplise IDE - everything is ok.
 
So when I try to deploy the code to my production environment and run a validation for deployment in the IDE wizard, I get a validation failure because I have only 48% testcoverage with the same code I tested before with a 100% coverage?!?! How can this be??
 
This is my Apex code. I have to triggers and one class for running the code:
Trigger one:

trigger CopyPawUpKV on Komponenten_Version__c (before update)

{

SOmyCopyPawClass.updateValues(trigger.new);

}

 

Trigger two:

trigger CopyPawJoinPVKV on Join_Produkt__c (before insert)

{

SOmyCopyPawClass.createValues(trigger.new);

}

 

Class:

public class SOmyCopyPawClass

{

public static void createValues(Join_Produkt__c[] jpkv)

{

Set<Id> newIds = new Set<Id>();

for(Integer i = 0; i < jpkv.size(); i++)

{

newIds.add(jpkv[i].Komponenten_Version__c);

}

List<Komponenten_Version__c> qr = [select id,Planaufwand_Tage__c,Status__c from Komponenten_Version__c where id in :newIds];

for(Integer i=0; i<jpkv.size(); i++)

{

for(Integer j=0; j<qr.size(); j++)

{

if(jpkv[i].Komponenten_Version__c == qr[j].id)

{

jpkv[i].Planaufwand_Tage__c = qr[j].Planaufwand_Tage__c;

jpkv[i].nextE_Status__c = qr[j].Status__c;

 

}

}

}

}

 

public static void updateValues(Komponenten_Version__c[] kv)

{

Set<Id> upIds = new Set<Id>();

for(Integer i = 0; i < kv.size(); i++)

{

upIds.add(kv[i].id); //Id-Set der Komponentenversionen

}

List<Join_Produkt__c> qr = [select id,nextE_Status__c,Planaufwand_Tage__c,Komponenten_Version__c from Join_Produkt__c where Komponenten_Version__c in :upIds];

for(Integer i=0; i<qr.size(); i++)

{

for(Integer j=0; j<kv.size(); j++)

{

if(qr[i].Komponenten_Version__c == kv[j].id)

{

qr[i].Planaufwand_Tage__c = kv[j].Planaufwand_Tage__c;

qr[i].nextE_Status__c = kv[j].Status__c;

}

}

}

update qr;

}

}

 

And this is my Testclass:

@isTest

private class SOmyCopyPawClass_isTest

{

static testMethod void myUnitTest()

{

Produkt_Version__c pv = new Produkt_Version__c(Name='nextPCM PV1');

insert pv;

 

List<Komponenten_Version__c> kvs = new List<Komponenten_Version__c>();

Komponenten_Version__c kv1 = new Komponenten_Version__c(Name='KV1',Status__c='1 - in Planung');

kvs.add(kv1);

Komponenten_Version__c kv2 = new Komponenten_Version__c(Name='KV2',Status__c='1 - in Planung');

kvs.add(kv2);

insert kvs;

 

List<Join_Produkt__c> joins = new List<Join_Produkt__c>();

Join_Produkt__c join1 = new Join_Produkt__c(Komponenten_Version__c=kv1.id,Produkt_Version__c=pv.id);

joins.add(join1);

Join_Produkt__c join2 = new Join_Produkt__c(Komponenten_Version__c=kv2.id,Produkt_Version__c=pv.id);

joins.add(join2);

insert joins;

 

List<technische_Funktionalitaet__c> tfs = new List<technische_Funktionalitaet__c>();

technische_Funktionalitaet__c tf1 = new technische_Funktionalitaet__c(Name='tf1',Komponenten_Version__c=kv1.id,Doku_Tage__c=2);

tfs.add(tf1);

technische_Funktionalitaet__c tf2 = new technische_Funktionalitaet__c(Name='tf2',Komponenten_Version__c=kv1.id,Doku_Tage__c=3);

tfs.add(tf2);

technische_Funktionalitaet__c tf3 = new technische_Funktionalitaet__c(Name='tf3',Komponenten_Version__c=kv2.id,Doku_Tage__c=4);

tfs.add(tf3);

technische_Funktionalitaet__c tf4 = new technische_Funktionalitaet__c(Name='tf4',Komponenten_Version__c=kv2.id,Doku_Tage__c=6);

tfs.add(tf4);

insert tfs;

 

Join_Produkt__c joins_erg1 = [select id,Planaufwand_Tage__c,nextE_Status__c from Join_Produkt__c where id = :join1.id];

Join_Produkt__c joins_erg2 = [select id,Planaufwand_Tage__c,nextE_Status__c from Join_Produkt__c where id = :join2.id];

 

System.assertEquals(5,joins_erg1.Planaufwand_Tage__c);

System.assertEquals('1 - in Planung',joins_erg1.nextE_Status__c);

System.assertEquals(10,joins_erg2.Planaufwand_Tage__c);

System.assertEquals('1 - in Planung',joins_erg2.nextE_Status__c);

}

}

 

So, can anyone help me out?

Thanks for any help in advance.

 

Best regards

Sascha



Message Edited by ne-rm-team on 11-28-2008 01:59 AM

Message Edited by ne-rm-team on 11-28-2008 02:05 AM

Message Edited by ne-rm-team on 11-28-2008 02:09 AM
Hi,
 
i wrote an apex script that works fine in my sandbox. Even the testMethod displays an 100% test coverage and all system asserts are correct.
 
But when i try to deploy the code to my productional system, i get an error from the deploymend wizard. The values that i try to read are always zero.
 
Can it be, that i'm getting these zero results because the rollup-fields are not so fast updated? This is the only thing I can image, but on the other side, why are the asserts correct in the sandbox?
 
The sandbox update is new and the code not realy complicated. The only thing I do is, to copy a rollup field-value from a master object, when I change a value of one related child object.
 
Hase anyone expirianced the same or any ideas whats going wrong?
 
P.S.
I added some queries to my testMethod and found out, that the master-record "Komponenten_Version__c" hase a amount of zero in the rollup-field "Planaufwand_Tage__c" although there are two child-records "technische_Funktionalitaet__c" related to the master-record which should create a amount of 5 in the roll-up field "Planaufwand_Tage__c".
 
Komponenten_Version__c:{Status__c=1 - in Planung, Name=KV1, Planaufwand_Tage__c=0.0, Id=a0Z200000001j5xEAA}
technische_Funktionalitaet__c:{Komponenten_Version__c=a0Z200000001j5xEAA, Doku_Tage__c=2.0, Name=tf1, Planaufwand_Tage__c=2.0, Id=a0N200000001jr5EAA},
technische_Funktionalitaet__c:{Komponenten_Version__c=a0Z200000001j5xEAA, Doku_Tage__c=3.0, Name=tf2, Planaufwand_Tage__c=3.0, Id=a0N200000001jr6EAA})
Looks like I can't fetch roll-up-fields with testMethods in my production environment?!?!
 
Thanks for any help.
 
Best regards
Sascha


Message Edited by ne-rm-team on 11-28-2008 02:28 AM

Message Edited by ne-rm-team on 11-28-2008 04:39 AM
Hi,
 
I have some classes deployed to my production-system and now I want to delete some of them. When I right-klick on the delete button in my Eclipse project I get a message wich I have to confirm - until there everythin works fine.
 
But after I had confirmed this delete-message I get an Error-Message:
 
"Remote delete failed with the following message. Delete will be aborted. SOmyInitConCalcTrigger_isTest: null package.xml: null"
 
So, can anyone help me out or is there another way do delete the class in the production-system, because in sf I can't find any way to delete this classes?!
 
Thanks in advance for any help
regards
Sascha
Hi,
 
i'm trying to catch the user field $User.Division depending on the owner of the oppotunity. The new cross object formulars doesn't work in this case. So i thought about the possibility to catch this field with an little apex programm.
 
The problem is - i'm totaly new to this programming language. So my question is - where i can find some examples, tutorials or other helpfull stuff?
 
Thanks in advance for any help.
 
With best regards
Sascha
Hi,
 
I have some classes deployed to my production-system and now I want to delete some of them. When I right-klick on the delete button in my Eclipse project I get a message wich I have to confirm - until there everythin works fine.
 
But after I had confirmed this delete-message I get an Error-Message:
 
"Remote delete failed with the following message. Delete will be aborted. SOmyInitConCalcTrigger_isTest: null package.xml: null"
 
So, can anyone help me out or is there another way do delete the class in the production-system, because in sf I can't find any way to delete this classes?!
 
Thanks in advance for any help
regards
Sascha

Hi,

According to Apex-Guide: Can delete original object using a DML operation on trigger after update; According to Test-Method: DML statment cannot operate on trigger.new or trigger.old

that was my previous message subject  but it seems a bit to long ;)

So, why the apex-guide assert that you can delete the original object, when on the other hand I get an error in the test-log.

trigger RunMyJob on myJob__c (after update)

{

myJob__c mjn = new myJob__c();

insert mjn;

SOmyCreateBacklogs.createBack(trigger.new[0]);

myJob__c old = trigger.new[0];

delete old;

}

 

Does anyone knows what I'm doing wrong?

 

Thanks and best regards

Sascha

  



Message Edited by ne-rm-team on 12-05-2008 04:47 AM
Hi all,

I have a set up where Object A is a parent of Object B. There is a trigger on delete of an Object B record to delete a record of type Object C related to the Object B record being deleted (ideally, Object C would be a child of B, but we can't do this unfortunately).

So: A is a parent of B, C is related to B but not via a parent/child relationship. And a trigger on B deletes the relevant C object when B is deleted.

If we delete a record of type A, it will delete B (because of the parent/child relationship) and - what I would expect anyway - the trigger on B will delete the relevant C object.

Except that it doesn't. Should it? I opened a clean developer account, put a trigger on B that just prints a debug statement, created the relevant data, deleted A and - nothing in the log.

FWIW, A is the standard Account object, B is the standard Event object, and C is a custom object we've developed.

Thanks in advance for your help!
  • October 29, 2008
  • Like
  • 0
Hi,
 
i'm trying to catch the user field $User.Division depending on the owner of the oppotunity. The new cross object formulars doesn't work in this case. So i thought about the possibility to catch this field with an little apex programm.
 
The problem is - i'm totaly new to this programming language. So my question is - where i can find some examples, tutorials or other helpfull stuff?
 
Thanks in advance for any help.
 
With best regards
Sascha