Checkmarx FLS Create Issue for Lead Convert?

Question:
I am converting a Lead using Apex in my managed package with the following code:
List<Database.LeadConvertResult> lcr = Database.convertLead(listOfLeadConvert);However, Checkmarx is throwing an FLS (Field-Level Security) Create error. I know that for normal insert operations, I can resolve this by using Database.insert(records, AccessLevel.USER_MODE), like this:
insert as user acc;How can I remove the Checkmarx FLS Create error for Database.convertLead? Is there a way to specify user mode, or do we need to log this as a false positive?
Similarly, how should we handle the same FLS Create error for Database.insert()?
Answer
You can use the Database.convertLead method with an additional accessLevel parameter to specify AccessLevel.USER_MODE. This ensures the operation respects the user’s permissions and should resolve the Checkmarx error:
List<Database.LeadConvertResult> lcr = Database.convertLead(listOfLeadConvert, true, AccessLevel.USER_MODE);For handling the same FLS Create issue with Database.insert(), you can use:
Database.insert(records, AccessLevel.USER_MODE);This approach ensures that both operations comply with field-level security checks, preventing Checkmarx from flagging them as potential security risks.
Summing Up
To resolve Checkmarx’s FLS Create error when converting Leads or inserting records, always use AccessLevel.USER_MODE to enforce field-level security checks. For Database.convertLead(), specify the access level explicitly, and for Database.insert(), pass USER_MODE as a parameter. This ensures that operations respect user permissions and eliminates security scan issues without needing false positive justifications.
Master Salesforce with Expert Training in Hyderabad
Kickstart your career with our comprehensive  salesforce online training . Whether you’re new to Salesforce or looking to enhance your skills, our program offers specialized tracks in Salesforce Administration, Development, and Artificial Intelligence. We equip you with the knowledge and hands-on experience necessary to excel in the tech industry.
Our training program includes interactive modules, real-world projects, and expert-led sessions to ensure you’re fully prepared for certification exams and interviews. Salesforce training in Hyderabad Our experienced instructors provide personalized attention, making even complex concepts easy to understand.
Start your journey to success today! Enroll for the free demo and set yourself on the path to a rewarding future!!!

