• chaitanya sfdc
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Hi,

I need to stop child records being edited and deleted if master's field "Status__c" reached to 'Complete'.
I have Call__c object which is master and Call_objective__c, Call_Asset__c are details to Call__c.
Call__c have Status__c field. I have created formula field Call_Status__c in both detail objects which takes current status of Call__c. 
 Here is the code I have tried but I am getting null pointer error.

trigger CallPlanProductTrigger on Call_Plan_Product__c (before insert, before update, before delete) 
{

for(Call_Objective__c CO : trigger.new) {
  Call_Objective__c oldVal = Trigger.oldMap.get(CO.Id);
  if(trigger.isBefore){
  if(trigger.isUpdate || trigger.isDelete || Trigger.isInsert){
  
    if(oldVal.Call_Status__c == 'Complete')
    {
        CO.addError('Call is Completed. Should not modify/delete Call Objective');
    }
  }
  }
 
}

Please help me.
Hi,

I need to write a trigger on base of a field value:

I have three objects:
Call__c -- Master object
Call_Objective__c -- detail object
Call_Asset__c -- detail object

In Call__c I have a picklist field called Status__c which have values like "In Progress", "Not Started" and "Completed".

Now my requirement is, I need to write a trigger that prevents updating of Call__c and creating, updating and deleting of  Call_Objective__c and Call_Asset__c records when Status__c is set to "Completed"

Thanks in Advance
Hi,

I am new to Salesforce. I need to write a trigger to show an error messages by comparing old values. Pls. see below detailed.

I have a junction object 'Related Products' which has master detail relationship with 'Contact' and have a lookup relationship with 'Product'. And I have added a related list of 'Related Products' in Contact detail page where user can create new Related Product from the Contact and can add multiple Products to it.

Now my requirment is "if any user selects a product which is already selected to that contact should through error".
For example, I have contact called "Test Contact111", In it I have created one Related Product "RP-0001" and selected a Product called "Prod111", It will get to save and will show in the Contact's detail page under 'Related Products' section.
Again from the same Contact I will create another Related Product "RP-0002" and again will select the Same Product "Prod111", now the trigger need to throw an error states "Prod111 is already selected"

Pls. help me on this.

Thanks in Advance :).
Hi,

I need to write a trigger on base of a field value:

I have three objects:
Call__c -- Master object
Call_Objective__c -- detail object
Call_Asset__c -- detail object

In Call__c I have a picklist field called Status__c which have values like "In Progress", "Not Started" and "Completed".

Now my requirement is, I need to write a trigger that prevents updating of Call__c and creating, updating and deleting of  Call_Objective__c and Call_Asset__c records when Status__c is set to "Completed"

Thanks in Advance
Hi,

I am new to Salesforce. I need to write a trigger to show an error messages by comparing old values. Pls. see below detailed.

I have a junction object 'Related Products' which has master detail relationship with 'Contact' and have a lookup relationship with 'Product'. And I have added a related list of 'Related Products' in Contact detail page where user can create new Related Product from the Contact and can add multiple Products to it.

Now my requirment is "if any user selects a product which is already selected to that contact should through error".
For example, I have contact called "Test Contact111", In it I have created one Related Product "RP-0001" and selected a Product called "Prod111", It will get to save and will show in the Contact's detail page under 'Related Products' section.
Again from the same Contact I will create another Related Product "RP-0002" and again will select the Same Product "Prod111", now the trigger need to throw an error states "Prod111 is already selected"

Pls. help me on this.

Thanks in Advance :).