You need to sign in to do that
Don't have an account?

Why my custom checkbox is always checked when I try to save as uncheck in the account object with active trigger?
Why my custom checkbox is always checked when I try to save as uncheck in the account object?
This is happening only when I have a active trigger. The trigger which I wrote is simple one to check whether that checkbox is "checked" or not, then copy the postal code from Billing address to shipping address.
When that particular trigger is "Inactive" and tried to save the record with that checkbox as "unchecked" it is working good.
Not sure why this trigger is always "checked" the checkbox when I save the record.
This is my trigger:
Trigger AccountAddressTrigger on Account (before insert,before update) {
for (Account a : Trigger.new)
{
if(a.Match_Billing_address__C = True)
{
if(a.BillingPostalCode != NULL)
{
a.ShippingPostalCode= a.BillingPostalCode;
}
}
}
}
This is happening only when I have a active trigger. The trigger which I wrote is simple one to check whether that checkbox is "checked" or not, then copy the postal code from Billing address to shipping address.
When that particular trigger is "Inactive" and tried to save the record with that checkbox as "unchecked" it is working good.
Not sure why this trigger is always "checked" the checkbox when I save the record.
This is my trigger:
Trigger AccountAddressTrigger on Account (before insert,before update) {
for (Account a : Trigger.new)
{
if(a.Match_Billing_address__C = True)
{
if(a.BillingPostalCode != NULL)
{
a.ShippingPostalCode= a.BillingPostalCode;
}
}
}
}
This is because of a minor mistake in your if condition. Replace the below line: to this: The first one assigns the value 'true' to the field while the second one checks if the field value is true.
Please mark the answer and close the question if this helped you.
Thanks!
All Answers
This is because of a minor mistake in your if condition. Replace the below line: to this: The first one assigns the value 'true' to the field while the second one checks if the field value is true.
Please mark the answer and close the question if this helped you.
Thanks!
In if condition you don't event need to compare with boolean Variable true or false (but if you want you can).
For checking true condition you can do
For checking false condition you can do
Thank you Ketankumar for your suggestion
trigger trigger_ManagePrimaryMember on Team_Members__c (before update) { Set<Id> currentprimarymemberid = new Set<Id>(); Set<Id> currentprimarymembrteamid = new Set<Id>(); List<Team_Members__c> teamid =new List<Team_Members__c>(); List<Team_Members__c> Updateprimarymember = new List<Team_Members__c>(); for(Team_Members__c primarymember : trigger.new) { currentprimarymemberid.add(primarymember.Id); } teamid= [select Id,Team__c from Team_Members__c where Id in :currentprimarymemberid]; for(Team_Members__c teammembers :teamid) { currentprimarymembrteamid.add(teammembers.Team__c); } for(Team_Members__c teammembers :[select id,Name from Team_Members__c where Team__c in :currentprimarymembrteamid]) { if(!currentprimarymemberid.contains(teammembers.id)) { // making the checkbox to false for other member in the team teammembers.check_box__c= false; } } }