You need to sign in to do that
Don't have an account?
sksfdc221
Check if current record value present in other records
I have a requirement, where account name and account number if do not match with any other records, a custom field called alert_text__c will be updated with some text.
Below is the code snippet:
Now, the above logic is not working as expected and even when i provide different Account Name and Account Numbers, I am not able to populate the text in Alert_text__c field.
Can anyone please suggest changes in the above code so that i can get this done.
Thanks!
Below is the code snippet:
List<Account_Codes__c> records = [SELECT ID, Account_Name__c, Account_Number__c from Account_Codes__c where Account_Name__c != Null AND Account_Number__c != Null]; final String accName = newPPAs[0].Account_Name__c; final String accNum = newPPAs[0].Account_Number__c; for (Account_Codes__c record : records) { if (record.Account_Name__c != accName && record.Account_Number__c != accNum) { record.Alert_Text__c = 'Account Number and Account Names are different'; } }
Now, the above logic is not working as expected and even when i provide different Account Name and Account Numbers, I am not able to populate the text in Alert_text__c field.
Can anyone please suggest changes in the above code so that i can get this done.
Thanks!
You need to update the records after adding the value in this field. You can use the code below:
Let me know if you need more help.
Thanks,
Abhishek Bansal.
The suggest logic didnt work. I didnt get any error but the warning message isnt getting displayed.
I have updated the logic and even then it didnt work. Below is my updated logic
Could you please suggest the changes if possible?