You need to sign in to do that
Don't have an account?
Trigger to check a checkbox
Hi I have two custom fields subscription_start_date and subscription_end_date on Opportunity object
Have a two custom checkbox customer1 and customer2 on Contact Object (These two checkboxes are checked from another workflow)
I have a requirement to that these checkboxes should be unchecked if today date does not lies between subscription_start_date and subscription_end_date
No i have to write a trigger with the condition
if (today date should be greater than or equal to subscription_start_date) and (lesser than or equal to subscription_end_date) and (customer1 checkbox should be checked)
{customer1=true }//should be checked
else
{customer1=false}//should not be checked
The following is my trigger but does not gives expected result
what is wrong
trigger checkthecheckbox on Contact (before insert) {
Set<id> oppids = new set<id>();
for (Contact opp: Trigger.new)
{
oppids.add(opp.id);
}
Map<id, opportunity> oppMap = new Map<id, opportunity>();
for(opportunity o : [select Subscription_Start_Date__c,Subscription_End_Date__c from opportunity where id in: oppids])
{
oppMap.put(o.id, o);
}
for (Contact opp: Trigger.new)
{
if(oppMap.get(opp.Id).Subscription_Start_Date__c>=date.Today())
{
opp.Customer_of_PubKCyber__c=False;
}
}
}
Between what is the relationship between Contact and Opportunity is used? Is there a custom relationship or the standard OpportunityContactRole is used?
Contact and Opportunity have standard realtionship
Checking this condition when a lead is converted to Opp,contact and acc