• Tzemach Aronow 4
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
Can I Use the NPSP as a starting point and then add my own object, picklist etc.. and package and sell it on the app exchange?
Is it posiible?
If yes, is it allowed?

If i cant sell it on the app exchange is it still posiible to package so i can install it on mutiple orgs?
I want to create a relationship between two contacts and have the relationship listed in the same related list on both contacts.

I created a relationship junction record using 2 lookup fields to the contact object. When I create the record it wont display the relation in the same related list on each object. In order to do that, upon creating the relationship record I need apex to duplicate the record and at the same time insert the same fields for the lookup but just switch them around, contact "A" and contact "B" should switch positions on the duplicate.

I tried writing some apex put im having trouble withe the creation of a new record, as opposed to an update on the current one.

trigger NewRelationship on Relationship__c (after insert) {
    List<relationship__c> NewRelationship = new List <relationship__c> ();

    for (relationship__c x : Trigger.new) {
        relationship__c NewRec = new relationship__c();
        NewRec.First_person_in_relationship__c = x.Second_person_in_relationship__c;
        NewRec.First_person_is_second_persons__c = x.Second_Person_is_first_persons__c;
        NewRec.Second_person_in_relationship__c = x.First_person_in_relationship__c;
        NewRec.Second_Person_is_first_persons__c = x.First_person_is_second_persons__c;
        newRelationship.add(NewRec);
   }
   INSERT newRelationship;
}

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger NewRelationship caused an unexpected exception, contact your administrator: NewRelationship: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, NewRelationship: maximum trigger depth exceeded Relationship trigger event AfterInsert for [a002000000VpusW] Relationship trigger event AfterInsert for [a002000000VpusX] Relationship trigger event AfterInsert for [a002000000VpusY] Relationship trigger event AfterInsert for [a002000000VpusZ] Relationship trigger event AfterInsert for [a002000000Vpusa] Relationship trigger event AfterInsert for [a002000000Vpusb] Relationship trigger event AfterInsert for [a002000000Vpusc] Relationship trigger event AfterInsert for [a002000000Vpusd] Relationship trigger event AfterInsert for [a002000000Vpuse] Relationship trigger event AfterInsert for [a002000000Vpusf] Relationship trigger event AfterInsert for [a002000000Vpusg] Relationship trigger event AfterInsert for [a002000000Vpush] Relationship trigger event AfterInsert for [a002000000Vpusi] Relationship trigger event AfterInsert for [a002000000Vpusj] Relationship trigger event AfterInsert for [a002000000Vpusk] Relationship trigger event AfterInsert for [a002000000Vpusl]: []: Trigger.NewRelationship: line 18, column 1
Im trying to create a trigger simmilar to the npsp relationship pack, that when I create a reationship record on contact "A", it should create a duplicate relationship on the record of contact "B".

I'm new to SF and I have tried a few ways but I'm still having trouble with my code.

trigger NewRelationships on Relationship__c (after insert) {

    List<relationship__c> NewRelationship = new List <relationship__c> {};

    for (relationship__c x : Trigger.new) {
        
        
           
        relationship__c NewRec = new relationship__c(
        First_person_in_relationship__c = x.Second_person_in_relationship__c,
        First_person_is_second_persons__c = x.Second_Person_is_first_persons__c,
        Second_person_in_relationship__c = x.First_person_in_relationship__c,
        Second_Person_is_first_persons__c = x.First_person_is_second_persons__c);
        NewRelationship.add(x);
        }
        
    
    
       insert NewRelationship;
      
}


I want to create a relationship between two contacts and have the relationship listed in the same related list on both contacts.

I created a relationship junction record using 2 lookup fields to the contact object. When I create the record it wont display the relation in the same related list on each object. In order to do that, upon creating the relationship record I need apex to duplicate the record and at the same time insert the same fields for the lookup but just switch them around, contact "A" and contact "B" should switch positions on the duplicate.

I tried writing some apex put im having trouble withe the creation of a new record, as opposed to an update on the current one.

trigger NewRelationship on Relationship__c (after insert) {

List<relationship__c> RecToInsert = new List <relationship__c> ();

for (relationship__c x : Trigger.new) {

    x.First_person_in_relationship__c = x.Second_person_in_relationship__c;
    x.First_person_is_second_persons__c = x.Second_Person_is_first_persons__c;
    x.Second_person_in_relationship__c = x.First_person_in_relationship__c;
    x.Second_Person_is_first_persons__c = x.First_person_is_second_persons__c;

    RecToInsert.add(x);

    try{

    insert RecToInsert;
    } catch (system.Dmlexception e) {
    system.debug (e);
    }

}
}



I also tried


trigger NewRelationship on Relationship__c (after insert) {

    List<relationship__c> RecToInsert = new List <relationship__c> ();

    for (relationship__c x : Trigger.new) {
        
                        RecToInsert.add(
                                new relationship__c(
        
        First_person_in_relationship__c = x.Second_person_in_relationship__c,
        First_person_is_second_persons__c = x.Second_Person_is_first_persons__c,
        Second_person_in_relationship__c = x.First_person_in_relationship__c,
        Second_Person_is_first_persons__c = x.First_person_is_second_persons__c)
   
  ); }
        INSERT RecToInsert;
       
   

    
}

I want to create a relationship between two contacts and have the relationship listed in the same related list on both contacts.

I created a relationship junction record using 2 lookup fields to the contact object. When I create the record it wont display the relation in the same related list on each object. In order to do that, upon creating the relationship record I need apex to duplicate the record and at the same time insert the same fields for the lookup but just switch them around, contact "A" and contact "B" should switch positions on the duplicate.

I tried writing some apex put im having trouble withe the creation of a new record, as opposed to an update on the current one.

trigger NewRelationship on Relationship__c (after insert) {
    List<relationship__c> NewRelationship = new List <relationship__c> ();

    for (relationship__c x : Trigger.new) {
        relationship__c NewRec = new relationship__c();
        NewRec.First_person_in_relationship__c = x.Second_person_in_relationship__c;
        NewRec.First_person_is_second_persons__c = x.Second_Person_is_first_persons__c;
        NewRec.Second_person_in_relationship__c = x.First_person_in_relationship__c;
        NewRec.Second_Person_is_first_persons__c = x.First_person_is_second_persons__c;
        newRelationship.add(NewRec);
   }
   INSERT newRelationship;
}

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger NewRelationship caused an unexpected exception, contact your administrator: NewRelationship: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, NewRelationship: maximum trigger depth exceeded Relationship trigger event AfterInsert for [a002000000VpusW] Relationship trigger event AfterInsert for [a002000000VpusX] Relationship trigger event AfterInsert for [a002000000VpusY] Relationship trigger event AfterInsert for [a002000000VpusZ] Relationship trigger event AfterInsert for [a002000000Vpusa] Relationship trigger event AfterInsert for [a002000000Vpusb] Relationship trigger event AfterInsert for [a002000000Vpusc] Relationship trigger event AfterInsert for [a002000000Vpusd] Relationship trigger event AfterInsert for [a002000000Vpuse] Relationship trigger event AfterInsert for [a002000000Vpusf] Relationship trigger event AfterInsert for [a002000000Vpusg] Relationship trigger event AfterInsert for [a002000000Vpush] Relationship trigger event AfterInsert for [a002000000Vpusi] Relationship trigger event AfterInsert for [a002000000Vpusj] Relationship trigger event AfterInsert for [a002000000Vpusk] Relationship trigger event AfterInsert for [a002000000Vpusl]: []: Trigger.NewRelationship: line 18, column 1
I want to create a relationship between two contacts and have the relationship listed in the same related list on both contacts.

I created a relationship junction record using 2 lookup fields to the contact object. When I create the record it wont display the relation in the same related list on each object. In order to do that, upon creating the relationship record I need apex to duplicate the record and at the same time insert the same fields for the lookup but just switch them around, contact "A" and contact "B" should switch positions on the duplicate.

I tried writing some apex put im having trouble withe the creation of a new record, as opposed to an update on the current one.

trigger NewRelationship on Relationship__c (after insert) {

List<relationship__c> RecToInsert = new List <relationship__c> ();

for (relationship__c x : Trigger.new) {

    x.First_person_in_relationship__c = x.Second_person_in_relationship__c;
    x.First_person_is_second_persons__c = x.Second_Person_is_first_persons__c;
    x.Second_person_in_relationship__c = x.First_person_in_relationship__c;
    x.Second_Person_is_first_persons__c = x.First_person_is_second_persons__c;

    RecToInsert.add(x);

    try{

    insert RecToInsert;
    } catch (system.Dmlexception e) {
    system.debug (e);
    }

}
}



I also tried


trigger NewRelationship on Relationship__c (after insert) {

    List<relationship__c> RecToInsert = new List <relationship__c> ();

    for (relationship__c x : Trigger.new) {
        
                        RecToInsert.add(
                                new relationship__c(
        
        First_person_in_relationship__c = x.Second_person_in_relationship__c,
        First_person_is_second_persons__c = x.Second_Person_is_first_persons__c,
        Second_person_in_relationship__c = x.First_person_in_relationship__c,
        Second_Person_is_first_persons__c = x.First_person_is_second_persons__c)
   
  ); }
        INSERT RecToInsert;
       
   

    
}

I have a custom Object: Milsetone__c, (it is a Child of custom Object: Project__c), I want to create a new Milestone record when the current Milestone Record that has a Project_Stage__c = 'Pre-construction Engineering' and a checkbox field called: Complete__c = true.  In my sandbox it just updates the exisitng record, does not create new record?  I need help I've written several triggers, but none like this - same Object/new record, 

 

 

trigger MilestoneZoning on Milestone__c (after insert) {

List<Milestone__c>newMilestones = new List<Milestone__c>();

for(Milestone__c ms :trigger.new) {

if( (ms.Name == 'Pre-construction Engineering Milestone')
&& (ms.Complete__c == True)){
Milestone__c freshMilestone = new Milestone__c();
freshMilestone.Name = 'Pre-construction Zoning Milestone';
freshMilestone.Opportunity__c = ms.opportunity__c;
freshMilestone.Project_Stage__c = 'Pre-construction Zoning';
freshMilestone.Project__c = ms.Project__c;
freshMilestone.Project_Manager__c = ms.Project_Manager__c;


newMilestones.add(freshMilestone);

}
}

Insert newMilestones;
}