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

isupdateable method
Hi All,
I am iserting contact record in my class. I need to check if all the fields are updateble and then i will upsert the record. I have written the following code but it is not working. Kindly provide me solution.
I am iserting contact record in my class. I need to check if all the fields are updateble and then i will upsert the record. I have written the following code but it is not working. Kindly provide me solution.
if (Schema.sObjectType.Contact.isUpdateable()){ contact.FirstName = firstname; contact.LastName = lastname; contact.Email = emailaddress; contact.Email_Alt_1__c = altemail1; contact.Email_Alt_2__c = altemail2; contact.MailingStreet = street; contact.MailingCity = city; contact.MailingPostalCode = postalCode; if (country == 'United States') { contact.MailingState = stateprovince; } else { contact.MailingState = ''; } contact.MailingCountry = country; contact.Country__c = regioncountry; //contact.Audience__c = audience; contact.Cisco_com_Login__c = ciscocomlogin; contact.Testing_ID__c = testingid; contact.Cisco_ID_CSCO__c = ciscoid; contact.Area_Code__c = Integer.valueOf(areaCode.trim()); contact.Country_Code__c = countryCode; contact.Phone = phonenumber; contact.Fax = faxPhone; contact.HomePhone = homePhone; upsert contact; }
Try checking field level access using
if it return true then assign value to that field.
Both the solutions are not working.
@Nisar, I need to check for all the fields
Thanks,
Anuj
Please try out the below snippet and change your code accordingly,
Add whatever field that you need the check, then add those in the fieldNames set.
Your cosde is not fulfilling my requirement. When i run the checkmarx report again, it is hsowing me the same thing.
Thanks,
Anuj