• Anuj Joshi 42
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 37
    Questions
  • 24
    Replies
Hi all,

I am writing escape=false in my VF Page. like this.
 
<apex:outputText escape="false"  value="{!cr.Message__c}" rendered="{!(cr.Message__c)!= ''}"/><br/><br/>

The Mesage__c is a custom field in the object with is of type Rich Text Area. This issue is coming up in my checkmarx report. In the document I have checked using Rich text area eliminated XSS vulnerabilty. How do I solve this? I have tried all possible solutions like JSENCODE, HTMLENCODE etc.  
Hi All,

I want to check FLS permissions at field level since it comes as an issue in checkmarx report. The below code is
global class AsyncApexClass{
@future

public static void sendEmail(Set<Id> sendList){
List <Notes__c> notesList = new List<Notes__c>();
notesList.clear();
for(List<EmailMessage> emailmsglist:[select Id,parentId,Parent.Email__c,Parent.Contact.Email,ToAddress, FromAddress, Subject, TextBody, HTMLBody, CreatedDate from EmailMessage where id in :sendList] )
{
        for(EmailMessage emlist :emailmsglist){

             Notes__c note= new Notes__c(); // Create a note object 
             note.Case__c= emlist.parentid;
                 IF (emlist.HTMLBody != NULL && emlist.HTMLBody != ''){
                 note.Message__c = emlist.HTMLBody;
                 }
                 else {
                 note.Message__c = emlist.TextBody;
                 }    
             note.Sent_To__c = emlist.ToAddress;
             note.From__c = emlist.FromAddress;
             note.Subject__c = emlist.Subject;
             note.Datetime_Created__c = emlist.CreatedDate;
             if (emlist.Parent.Contact.Email == emlist.ToAddress || emlist.Parent.Email__c == emlist.ToAddress) // If the email is the same as Case's contact email or Email__c on Case itself, the type is a response.
             {
             note.Type__c = 'Response';
             }
             else {
             note.Type__c = 'Forward/Others';
             }
             notesList.add(note); // Add note object to the list
         }
}
// If the note list has records, insert the list.
if(notesList.size()>0) {
       insert notesList;
       }
}
}

Kindly help me how to check FLS pers=missions at field level and kindly tell me how to test the code after changes.

Thanks,
Hi All,

I have a custom bar chart written in VF page where we are dsipalying records based on controller. Currently we are displayng the values in generic way. But we want to display values differently based on user locale/country. For example the value shown to Indian user will be 1,00,000 but the same value shown to US user will be in the format 100,000. Kindly provide me solution.

Thanks,
Anuj
Hi All,

I want to write a validation rule on phone number custom field. I want to check if the phone number cotains the user's iso country code. For example the user creating or updatin the record has its iso country as INDIA. The validation rule must check if the phone number contains +91. I want to write that for many countries.

Thanks,
Anuj
Hi All,

We have a link. Wehn that link is clicked it is opening a site on new tab. Initially it is taking to <domain>.force.com Wehn user enters login details then its is taking us to https://<domain>.secure.force.com Can we make the first page as secure.force.com?

Thanks,
Anuj
Hi All,

In sesstion settings I have enabled the checkbox "HSTS for sites and communities". Also Require connections(HTTPS) checkbox is checked in Site settings. My requirement is to redirect the current site URL which is in HTTP to HTTPS. Will it have any impact if I change the above two settings above.

Thanks,
Anuj
Hi All,

We have client who has its own website. When the user clicks in a link he is redirected to force.com site. But he is redirected to site URL which is is in HTTP. My requirement is that the URL should be changed from HTTP to HTTPS. The HTTPS setting checkbox in session settings is enabled. In the login settings of site, the secure web address is given as HTTPS. Is there any way that when user click on the link, it opens HTTPS instead of HTTP site URL. I tried to change to HTTPS in href tag of the website but its not working.

Thanks,
Anuj
Hi all,

We are working with sites. We have 4 languages namely- English, Spanish, Japanese and Chinese. We have footer where we have 5-6 tabs or links. We are storing the values in custom labels and corresponding translations have been defined. We are detecting the language from user's browser i.e. we have written Accept-Langaueg in the code. My req is that, when the particualr language link is clicked from footer it should redirect it to another chinese page. If its spanish it should do the same. I want to redirect to other pages based on the language in which its showing. For example Contact Us ia link in footer. If its showed in English and user clicks on it, it redirects to www.google.com and for the chinese one it redirects to www.gmail.com.

Thanks,
Anuj
Hi All,

We have a code where we are using site templates. I have to add one more div in the VF page. The site template is used in VF Page. I am not able to figure out where to add the div code. We have code like this.
<apex:composition template="{!$Site.Template}">
  <apex:define name="headerNav">
    <c:HeaderComponent id="headerComponent" displayContactUs="true" displayMyCases="true" displayMyProfile="true"/>
  </apex:define>
  <apex:define name="maincolumn">
        <a name="mainContent" id="mainContent"></a>
                           <div id="rn_dashboardwrapper">
                               <div id="rn_dashboard">
                                   <div style="padding-bottom: 10px;">
                                   <apex:outputLink value="{!$Page.InstantAnswers}"><apex:image alt="CertificationSupport" url="{!URLFOR($Resource.CiscoPortalResource, 'images/skin/CertificationsSupport.PNG')}" /></apex:outputLink>
                            <!-- banner start here on 7/21/2017 -->

I am not able to find where {$Site.Template} is used. I need to add the div code.

Thanks,
Anuj
 
Hi All,

I have a trigger and a batch class. the class is
global class AsyncApexClass{
@future

public static void sendEmail(Set<Id> sendList){
List <Notes__c> notesList = new List<Notes__c>();
notesList.clear();
for(List<EmailMessage> emailmsglist:[select Id,parentId,Parent.Email__c,Parent.Contact.Email,ToAddress, FromAddress, Subject, TextBody, HTMLBody, CreatedDate from EmailMessage where id in :sendList] )
{
        for(EmailMessage emlist :emailmsglist){

             Notes__c note= new Notes__c(); // Create a note object 
             note.Case__c= emlist.parentid;
                 IF (emlist.HTMLBody != NULL && emlist.HTMLBody != ''){
                 note.Message__c = emlist.HTMLBody;
                 }
                 else {
                 note.Message__c = emlist.TextBody;
                 }    
             note.Sent_To__c = emlist.ToAddress;
             note.From__c = emlist.FromAddress;
             note.Subject__c = emlist.Subject;
             note.Datetime_Created__c = emlist.CreatedDate;
             if (emlist.Parent.Contact.Email == emlist.ToAddress || emlist.Parent.Email__c == emlist.ToAddress) // If the email is the same as Case's contact email or Email__c on Case itself, the type is a response.
             {
             note.Type__c = 'Response';
             }
             else {
             note.Type__c = 'Forward/Others';
             }
             notesList.add(note); // Add note object to the list
         }
}
// If the note list has records, insert the list.
if(notesList.size()>0) {
       insert notesList;
       }
}
}

The triger is
trigger CreateNotes on EmailMessage(after insert) {

    //Variable declaration
    Set<Id> collectEmailSet = new Set<Id>();
    for(EmailMessage  msg : Trigger.New){
      collectEmailSet.Add(msg.Id);
    }
    if(collectEmailSet.size()>0){
            AsyncApexClass.sendEmail(collectEmailSet); 
    }
 }

When i was deploying it to prod I got a error like this "
This Apex class has batch or future jobs pending or in progress". I checked the checkbox in deployment settings option. But after deployment mail is not delivered to users. Do I need to schedule my jobs again?

Thanks,
Anuj
Hi All,

In our org we have many pages and controllers. Most of the poages are used in sites. When we run a checkmarx report we have encountered Query:sahring issue. Its description is "All entry points to an app (Global or Controller classes) must use the 'with sharing' keyword. Classes without this keyword run without sharing if they are entry points to your code, or with the sharing policy of the caller. Do not omit the sharing declaration as this hides critical security information in side-effects that can change when code is refactored. Only declare classes as 'without sharing' if they are not entry points to your app and if they only modify objects whose security is managed by your code (such as wizard state, or fields in a site). It is a common misconception to believe that batch apex or async apex must run with the global keyword. This is not true, the only classes that must be global are those that expose webservices or are intended to be used by extension packages. All async apex should run as public in order to avoid creating privileged entry points to your app."
I am also checking for FLS in all the controllers. What do I need to eliminate the issue in the report. 
For example some of the controllers are written as:
 
public virtual class BaseSiteController {}

public without sharing class SiteRegistrationController extends BaseSiteController {

public class SearchMyCaseExt extends BaseSiteController{

Thanks,
Anuj​
Hi All,

I have a requirement that in a visualforce page i need to display case records where owner is the current logged in user. It should come in a table. Also there should be a search box on the top of table. When the user puts the case subject or number on the box and clicks on search button the table should refresh and show that particular record. When the user loads the page initially it should show user case records in table with pagination. After search button is clicked table should get refereshed.
Kindly provide me the example.

Thanks,
Anuj
Hi All,

I have some some controllers in my org which are declared as without sharing and virtual. When I run the checkmarx report I get the Sharng issue like this
All entry points to an app (Global or Controller classes) must use the 'with sharing' keyword. Classes without this keyword run without sharing if they are entry points to your code, or with the sharing policy of the caller. Do not omit the sharing declaration as this hides critical security information in side-effects that can change when code is refactored. Only declare classes as 'without sharing' if they are not entry points to your app and if they only modify objects whose security is managed by your code (such as wizard state, or fields in a site). It is a common misconception to believe that batch apex or async apex must run with the global keyword. This is not true, the only classes that must be global are those that expose webservices or are intended to be used by extension packages. All async apex should run as public in order to avoid creating privileged entry points to your app.

I need solution to fix this issue.

Thanks,
Anuj
Hi all,

Has anyone used Force.com ESCAPI https://code.google.com/archive/p/force-dot-com-esapi/source/default/source anytime. I wanted to know how we can use it in out classes or pages.

Thanks,
Anuj
Hi All,

When we write a vf page and click on security we see that some object and fioelds have permission.

User-added image

Stll do we need to check FLS conditions like isCreateable and isUpdateable in the apex class? I need to eliminate these error in checkmarx report. I have written them but i have no ides on how to test the code by looging as different users.

Thanks,
Anuj
Hi All,

I am checking in my class whether the fields of object are createable. I am using this condition in the objects. I am using Schema.sObjectType.Case.fields.fieldname.isCreateable in the if loop. I have 10 fields like this for which I am checking. For this if loop the code is not getting covered in the test class. 
I have tried to run as system admin using system.runAs() but that ios also not covering the test class.

Thanks,
Anuj
Hi All,

I have a line of code which is written like this.
<apex:outputText escape="False" value="{!cr.Message__c}" rendered="{!(cr.Message__c)!= ''}"/><br/><br/>
I am getting an issue in the checkmarx report saying that this line is vulnerable to Cross site scripting (XSS). When i convert the above line to 
<apex:outputText escape="False" value="{!HTMLENCODE(cr.Message__c)}" rendered="{!HTMLENCODE(cr.Message__c)!= ''}"/>

I am getting a output as <p> Hi <br/> ...in this format. Kindly help me to resolve this issue. Actually I am displaying the emailmeesage content in this vf page and diplaying in case related list.

Thanks,
Anuj
 
Hi All,

I have run a checkmarx report and have been reported with FLS create issue. In my class I am writing upsert statements. I dont know how to check upsert condition. For insert i am checking if each field isCreateable() and for update i am checking if field is isUpdateable().
I also need a optimised solution. I am checking FLS like this for each field. 
 
Contact contact = [Select c.Phone, c.OtherPhone, c.MobilePhone, c.MailingStreet, c.MailingState, 
            	       c.MailingPostalCode, c.MailingCountry, c.MailingCity, c.LastName, c.Id, c.HomePhone, 
            	       c.FirstName, c.Fax, c.Email_Alt_2__c, c.Email_Alt_1__c, c.Email, c.Country__c, 
            	       c.Cisco_com_Login__c, c.Cisco_ID_CSCO__c, c.AssistantPhone, c.Country_Code__c, c.Area_Code__c From Contact c
            	       where c.Id =: user.ContactId];	
            	   if (contact != null) {
                       if(Schema.SObjectType.contact.fields.FirstName.isUpdateable() &&
                         Schema.SObjectType.contact.fields.LastName.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Email.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Email_Alt_1__c.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Email_Alt_2__c.isUpdateable() &&
                         Schema.SObjectType.contact.fields.MailingStreet.isUpdateable() &&
                         Schema.SObjectType.contact.fields.MailingCity.isUpdateable() &&
                         Schema.SObjectType.contact.fields.MailingPostalCode.isUpdateable() &&
                         Schema.SObjectType.contact.fields.MailingState.isUpdateable() &&
                          Schema.SObjectType.contact.fields.MailingCountry.isUpdateable() &&
                          Schema.SObjectType.contact.fields.Country__c.isUpdateable() &&
                          Schema.SObjectType.contact.fields.Cisco_com_Login__c.isUpdateable() &&
                          Schema.SObjectType.contact.fields.Testing_ID__c.isUpdateable() &&
                          Schema.SObjectType.contact.fields.Cisco_ID_CSCO__c.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Area_Code__c.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Country_Code__c.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Phone.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Fax.isUpdateable() &&
                         Schema.SObjectType.contact.fields.HomePhone.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;
                       }

Is there any shorter approach rather than checking each field. I checked each field but its not going away in checkmarx report.

Thanks,
Anuj​
Hi All,

I have  a requirement. There are 2 queues, lets say A and B. There is a lookup field to user and other field is a picklist field which is the status field. There is a trigger written in before insert and before update which updates the case owner to the value of the lookup field(which is the user).

Now my requirement is when the case owner is queue B, and status is closed, the owner must be changed to the value of lookup field. If the status is not closed then owner should not change. I am unable to get it with trigger.

Kindly provide me solution.

Thanks,
Anuj
Hi all,

I have few controllers which are declared as without sharing. When I run checkmarx report it states that they should be declared as with sharing. I would like to know whether changing it to with sharing will have any impact or not.

Thanks,
Anuj
Hi All,

I have 2 triggers written on contact object. I need to make it to one trigger and retain the functionalities of both triggers. 
 
trigger DupePreventer on contact
                               (before insert, before update) {

    Map<String, contact> contactMap = new Map<String, contact>();
    for (contact contact : System.Trigger.new) {
        
        
        if ((contact.Email != null) &&
                (System.Trigger.isInsert ||
                (contact.Email != 
                    System.Trigger.oldMap.get(contact.Id).Email))) {
        
           
    
            if (contactMap.containsKey(contact.Email)) {
                contact.Email.addError('Another new contact has the '
                                    + 'same email address.');
            } else {
                contactMap.put(contact.Email, contact);
            }
       }
    }
    
 
    for (contact contact : [SELECT Email FROM contact
                      WHERE Email IN :contactMap.KeySet()]) {
        contact newcontact = contactMap.get(contact.Email);
        newcontact.Email.addError('A contact with this email '
                               + 'address already exists.');
    }
}
 
trigger DeactivateUser on Contact (before update) 
{
	
	Map<Id, Boolean> contactToActivateDeactivate = new Map<Id, Boolean>(); 
	
	
	for(Contact contact : trigger.new)
	{
		
		
		if (contact.Blacklisted__c != trigger.oldMap.get(contact.Id).Blacklisted__c)
		{
			
			contactToActivateDeactivate.put(contact.Id, !contact.Blacklisted__c);
		}
	}

	
	
	if (!contactToActivateDeactivate.IsEmpty())
	{
		activateDeactivateUser activateDeactivateUser = new activateDeactivateUser(); //referring to class
		activateDeactivateUser.updateUser(contactToActivateDeactivate);
	} 
}

Kindly provide me solution

Thanks,
Anuj​
Hi All,

I have a controller class which was previously written as without sharing. If I change it to with sharing will it have any impact?

Thanks,
Anuj
Hi All,
I have a requirement in my code where I need to convert uploaded Excel file into CSV.
Can anyone tell me how to do this ?

Thanks and Regards,
Naznin
Hi All,

I have a custom bar chart written in VF page where we are dsipalying records based on controller. Currently we are displayng the values in generic way. But we want to display values differently based on user locale/country. For example the value shown to Indian user will be 1,00,000 but the same value shown to US user will be in the format 100,000. Kindly provide me solution.

Thanks,
Anuj
Hello , 

When I try to complete a superbadge "Apex specialist" , shows me a error message and does not login to my org:

The error message is:

"Houston, we have a problem.
You are attempting to log into Trailhead to complete challenges with an org that isn't supported.
Please make sure that your Org is
A Developer Edition Org (it cannot be a Production or Sandbox Org) and
The Developer Edition Org does not have a namespace assigned to it."


I do have a namespace in my org. If required I can delete them as well. Can anyone help me please?
 
  • June 08, 2018
  • Like
  • 0
Hi All,

I want to write a validation rule on phone number custom field. I want to check if the phone number cotains the user's iso country code. For example the user creating or updatin the record has its iso country as INDIA. The validation rule must check if the phone number contains +91. I want to write that for many countries.

Thanks,
Anuj
Hi All,

We have client who has its own website. When the user clicks in a link he is redirected to force.com site. But he is redirected to site URL which is is in HTTP. My requirement is that the URL should be changed from HTTP to HTTPS. The HTTPS setting checkbox in session settings is enabled. In the login settings of site, the secure web address is given as HTTPS. Is there any way that when user click on the link, it opens HTTPS instead of HTTP site URL. I tried to change to HTTPS in href tag of the website but its not working.

Thanks,
Anuj
Hi All,

We have a code where we are using site templates. I have to add one more div in the VF page. The site template is used in VF Page. I am not able to figure out where to add the div code. We have code like this.
<apex:composition template="{!$Site.Template}">
  <apex:define name="headerNav">
    <c:HeaderComponent id="headerComponent" displayContactUs="true" displayMyCases="true" displayMyProfile="true"/>
  </apex:define>
  <apex:define name="maincolumn">
        <a name="mainContent" id="mainContent"></a>
                           <div id="rn_dashboardwrapper">
                               <div id="rn_dashboard">
                                   <div style="padding-bottom: 10px;">
                                   <apex:outputLink value="{!$Page.InstantAnswers}"><apex:image alt="CertificationSupport" url="{!URLFOR($Resource.CiscoPortalResource, 'images/skin/CertificationsSupport.PNG')}" /></apex:outputLink>
                            <!-- banner start here on 7/21/2017 -->

I am not able to find where {$Site.Template} is used. I need to add the div code.

Thanks,
Anuj
 
Hi All,

I have a requirement that in a visualforce page i need to display case records where owner is the current logged in user. It should come in a table. Also there should be a search box on the top of table. When the user puts the case subject or number on the box and clicks on search button the table should refresh and show that particular record. When the user loads the page initially it should show user case records in table with pagination. After search button is clicked table should get refereshed.
Kindly provide me the example.

Thanks,
Anuj
Hi All,

When we write a vf page and click on security we see that some object and fioelds have permission.

User-added image

Stll do we need to check FLS conditions like isCreateable and isUpdateable in the apex class? I need to eliminate these error in checkmarx report. I have written them but i have no ides on how to test the code by looging as different users.

Thanks,
Anuj
Hi All,

I have a line of code which is written like this.
<apex:outputText escape="False" value="{!cr.Message__c}" rendered="{!(cr.Message__c)!= ''}"/><br/><br/>
I am getting an issue in the checkmarx report saying that this line is vulnerable to Cross site scripting (XSS). When i convert the above line to 
<apex:outputText escape="False" value="{!HTMLENCODE(cr.Message__c)}" rendered="{!HTMLENCODE(cr.Message__c)!= ''}"/>

I am getting a output as <p> Hi <br/> ...in this format. Kindly help me to resolve this issue. Actually I am displaying the emailmeesage content in this vf page and diplaying in case related list.

Thanks,
Anuj
 
Hi All,

I have run a checkmarx report and have been reported with FLS create issue. In my class I am writing upsert statements. I dont know how to check upsert condition. For insert i am checking if each field isCreateable() and for update i am checking if field is isUpdateable().
I also need a optimised solution. I am checking FLS like this for each field. 
 
Contact contact = [Select c.Phone, c.OtherPhone, c.MobilePhone, c.MailingStreet, c.MailingState, 
            	       c.MailingPostalCode, c.MailingCountry, c.MailingCity, c.LastName, c.Id, c.HomePhone, 
            	       c.FirstName, c.Fax, c.Email_Alt_2__c, c.Email_Alt_1__c, c.Email, c.Country__c, 
            	       c.Cisco_com_Login__c, c.Cisco_ID_CSCO__c, c.AssistantPhone, c.Country_Code__c, c.Area_Code__c From Contact c
            	       where c.Id =: user.ContactId];	
            	   if (contact != null) {
                       if(Schema.SObjectType.contact.fields.FirstName.isUpdateable() &&
                         Schema.SObjectType.contact.fields.LastName.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Email.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Email_Alt_1__c.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Email_Alt_2__c.isUpdateable() &&
                         Schema.SObjectType.contact.fields.MailingStreet.isUpdateable() &&
                         Schema.SObjectType.contact.fields.MailingCity.isUpdateable() &&
                         Schema.SObjectType.contact.fields.MailingPostalCode.isUpdateable() &&
                         Schema.SObjectType.contact.fields.MailingState.isUpdateable() &&
                          Schema.SObjectType.contact.fields.MailingCountry.isUpdateable() &&
                          Schema.SObjectType.contact.fields.Country__c.isUpdateable() &&
                          Schema.SObjectType.contact.fields.Cisco_com_Login__c.isUpdateable() &&
                          Schema.SObjectType.contact.fields.Testing_ID__c.isUpdateable() &&
                          Schema.SObjectType.contact.fields.Cisco_ID_CSCO__c.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Area_Code__c.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Country_Code__c.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Phone.isUpdateable() &&
                         Schema.SObjectType.contact.fields.Fax.isUpdateable() &&
                         Schema.SObjectType.contact.fields.HomePhone.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;
                       }

Is there any shorter approach rather than checking each field. I checked each field but its not going away in checkmarx report.

Thanks,
Anuj​
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.
 
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;
                       }

 
Hi All,

I have a controller class which was previously written as without sharing. If I change it to with sharing will it have any impact?

Thanks,
Anuj