• Cprocessing
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
trigger SigningLiveUpdate on Account (before update) {

	//Get accounts from Trigger
	Account account = trigger.new[0];
    
    //If criteria in Account are met then proceed
    if(account.CustomerStatus__c = 'Approved')
    {
    	//Create New Signing Array - I'm aware i could condense this step, but it's an attempt to make it work
    	Signing__c[] allSignings = new Signing__c[0];
    	
    	//Add all Signing__c objects that share that are related to the account
    	allSignings = [select Live__c from Signing__c where Id =: account.Id];       
    
    	//Go through each related Signing__c object and set them to live
    	if(allSignings.size()>0) {
    		for(Signing__c signing: allSignings){
    	    	signing.Live__c = true;
    	    	//update signing;
       		}
    	}
    }
   	
   	// Update Signings
    update allSignings;              
}

 

Signing__c is a custom object that has a Master-Detail Relationship to Account.

 

Essentially all i want to do is when a the status in Account gets set to Approved i want all the signing objects to then get set to "Live"

 

This must be doable? What am i doing wrong guys?

 

CProcessing.

Hi Guys,

 

I'm struggling to write an apex test class for my apex trigger. Please Bear in mind that this is the second thing i've ever written in APEX, however i do have other programming knowledge.

 

My Apex Trigger looks something like this:

 

trigger DisputeStatus on Dispute__c (before update) {

	// Get Trigger Object
	Dispute__c dispute = trigger.new[0];
	
	
	if((dispute.Un_Actioned_Conversations__c == 0) && (dispute.Resolved__c == true))
	{
		dispute.Status_of_Problem__c = 'Resolved';
		dispute.Resolved__c = true;
	} else if (dispute.Un_Actioned_Conversations__c > 0)
	{
		dispute.Status_of_Problem__c = 'Waiting for ACTION';
		dispute.Resolved__c = false;
	} else
	{
		dispute.Status_of_Problem__c = 'Waiting for RESPONSE';
		dispute.Resolved__c = false;
	}
}

 

Background information

 

An account object has these custom "Dispute" objects attached

 

A dispute object has custom "Conversation" objects attached

 

dispute.Un_Actioned_Conversations__c // is a roll up summary counting a boolean field in conversation 

 

However i have no idea how to write an APEX test class. I understand that it's essentially a unit test and should test the all the scope of the trigger. I've had a go, using tutorials, and produced the following code:

 

@isTest
private class testDisputeStatus {

    static testMethod void myUnitTest() {
        Dispute__c dispute = new Dispute__c();

		        
        dispute.Un_Actioned_Conversations__c = 0;
        dispute.Resolved__c = false;

		insert dispute;
		
		dispute.Un_Actioned_Conversations__c = 1;
		
		update dispute;
		
		dispute.Resolved__c = true;
		
		update dispute;
		
		dispute.Un_Actioned_Conversations__c = 0;
		
		update dispute;
        
    }}

 However all i've managed to produce is : 

Field is not writeable: Dispute__c.Un_Actioned_Conversations__c

 I appreciate i'm probably doing this completely wrong however being pointed in the right direction would be appreciated.

 

Any ideas?

 

Hi Guys,

 

I feel a bit daft as i just can't work out how to access related objects within the trigger.

 

My structure is something like this:

 

Rep < Account > Return

 

And i'd like to get information from REP to process the return.

 

trigger get_REP_Email on Return__c (before update) {
	
	Return__c myReturn = trigger.new[0];

}

 Above is all i've managed to get so far, and i've tried many things. What i'd like to do is on update, take the return object - Find the related Account Object - Find the related rep object and base a condition in the return object on the rep object?

 

Can this be done?

 

Can anybody point me in the right direction?

 

Kind Regards,

CP

trigger SigningLiveUpdate on Account (before update) {

	//Get accounts from Trigger
	Account account = trigger.new[0];
    
    //If criteria in Account are met then proceed
    if(account.CustomerStatus__c = 'Approved')
    {
    	//Create New Signing Array - I'm aware i could condense this step, but it's an attempt to make it work
    	Signing__c[] allSignings = new Signing__c[0];
    	
    	//Add all Signing__c objects that share that are related to the account
    	allSignings = [select Live__c from Signing__c where Id =: account.Id];       
    
    	//Go through each related Signing__c object and set them to live
    	if(allSignings.size()>0) {
    		for(Signing__c signing: allSignings){
    	    	signing.Live__c = true;
    	    	//update signing;
       		}
    	}
    }
   	
   	// Update Signings
    update allSignings;              
}

 

Signing__c is a custom object that has a Master-Detail Relationship to Account.

 

Essentially all i want to do is when a the status in Account gets set to Approved i want all the signing objects to then get set to "Live"

 

This must be doable? What am i doing wrong guys?

 

CProcessing.

Hi Guys,

 

I'm struggling to write an apex test class for my apex trigger. Please Bear in mind that this is the second thing i've ever written in APEX, however i do have other programming knowledge.

 

My Apex Trigger looks something like this:

 

trigger DisputeStatus on Dispute__c (before update) {

	// Get Trigger Object
	Dispute__c dispute = trigger.new[0];
	
	
	if((dispute.Un_Actioned_Conversations__c == 0) && (dispute.Resolved__c == true))
	{
		dispute.Status_of_Problem__c = 'Resolved';
		dispute.Resolved__c = true;
	} else if (dispute.Un_Actioned_Conversations__c > 0)
	{
		dispute.Status_of_Problem__c = 'Waiting for ACTION';
		dispute.Resolved__c = false;
	} else
	{
		dispute.Status_of_Problem__c = 'Waiting for RESPONSE';
		dispute.Resolved__c = false;
	}
}

 

Background information

 

An account object has these custom "Dispute" objects attached

 

A dispute object has custom "Conversation" objects attached

 

dispute.Un_Actioned_Conversations__c // is a roll up summary counting a boolean field in conversation 

 

However i have no idea how to write an APEX test class. I understand that it's essentially a unit test and should test the all the scope of the trigger. I've had a go, using tutorials, and produced the following code:

 

@isTest
private class testDisputeStatus {

    static testMethod void myUnitTest() {
        Dispute__c dispute = new Dispute__c();

		        
        dispute.Un_Actioned_Conversations__c = 0;
        dispute.Resolved__c = false;

		insert dispute;
		
		dispute.Un_Actioned_Conversations__c = 1;
		
		update dispute;
		
		dispute.Resolved__c = true;
		
		update dispute;
		
		dispute.Un_Actioned_Conversations__c = 0;
		
		update dispute;
        
    }}

 However all i've managed to produce is : 

Field is not writeable: Dispute__c.Un_Actioned_Conversations__c

 I appreciate i'm probably doing this completely wrong however being pointed in the right direction would be appreciated.

 

Any ideas?