• Shruthi GM 6
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 0
    Replies
"Your Apex code contains field level access checks that are redundant now that you've added 'WITH SECURITY_ENFORCED'. Please check your code again."

Code is:-

@RestResource(urlMapping='/secureApexRest')
global with sharing class SecureApexRest {
    @HttpGet
    global static Contact doGet(){
        Id recordId = RestContext.request.params.get('id');
        Contact result;
        if (recordId == null){
            throw new FunctionalException('Id parameter is required');
        }
        if (Schema.SObjectType.Contact.isAccessible()
            && Schema.SObjectType.Contact.fields.Name.isAccessible()
            && Schema.SObjectType.Contact.fields.Secret_Key__c.isAccessible()){
            List<Contact> results = [SELECT id FROM Contact WHERE Id = :recordId WITH SECURITY_ENFORCED];
            if (!results.isEmpty()) {
                result = results[0];
            }
        } else{
            throw new SecurityException('You don\'t have access to all contact fields required to use this API');
        }
        return result;
    }
    public class FunctionalException extends Exception{}
    public class SecurityException extends Exception{}
}

Kindly suggest me what exactly I need to change in the code.
Thanks inadvance.
I am trying to solve one of the lightning trail heads of creating Camping list.

Here is my component.

<aura:component>
 <!-- PAGE HEADER -->
<aura:attribute name="newItem" type="Camping_Item__c"
    default="{ 'sobjectType': 'Camping_Item__c','Name': '',
             'Quantity__c': 0,
             'Price__c': 0,
             'Packed__c': false }"/>
<aura:attribute name="items" type="Camping_Item__c[]"/>


     
    <!-- PAGE HEADER -->
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem>
            <lightning:icon iconName="standard:scan_card" alternativeText="Camping List"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
                <h1 class="slds-text-heading--label">Camping List</h1>
                <h2 class="slds-text-heading--medium">List</h2>
            </div>
        </lightning:layoutItem>
    </lightning:layout>
    <!-- / PAGE HEADER -->
    <!-- NEW CAMPINGLIST FORM -->
    <lightning:layout>
        <lightning:layoutItem padding="around-small" size="6">
        <!-- [[ CampingList form goes here ]] -->
        </lightning:layoutItem>
    </lightning:layout>
    <!-- / NEW CAMPINGLIST FORM -->
        <!-- CREATE NEW LIST -->
    <div aria-labelledby="newexpenseform">
        <!-- BOXED AREA -->
        <fieldset class="slds-box slds-theme--default slds-container--small">
        <legend id="newexpenseform" class="slds-text-heading--small 
          slds-p-vertical--medium">
          Add List
        </legend>
    
    
    
    <!-- CREATE NEW ITEM FORM -->
            
    <form class="slds-form--stacked">          
    <lightning:input aura:id="itemform" label="Name"
                             name="itemName"
                             value="{!v.newItem.Name}"
                             required="true"/> 
        
        
    <lightning:input type="number" aura:id="itemform" label="Quantity"
                             name="itemQuantity"
                             value="{!v.newItem.Quantity__c}"
                             required="true"/>
        
    <lightning:input type="number" aura:id="itemform" label="Price"
                             name="itemPrice"
                             min="0.1"
                             formatter="currency"
                             step="0.01"
                             value="{!v.newItem.Price__c}"
                             messageWhenRangeUnderflow="Enter an amount that's at least $0.10."/>
        
    <lightning:input type="checkbox" aura:id="itemform" label="Packed"  
                             name="itemPacked"
                             checked="{!v.newItem.Packed__c}"/>  
        
     <lightning:button label="Create Camping Item" 
                              class="slds-m-top--medium"
                              variant="brand"
                              onclick="{!c.clickCreate}"/>
            

</form>

    <!-- / CREATE NEW ITEM FORM -->

    <div class="slds-card slds-p-top--medium">

        <header class="slds-card__header">

            <h3 class="slds-text-heading--small">Items</h3>

        </header>

         

        <section class="slds-card__body">

            <div id="list" class="row">

                <aura:iteration items="{!v.items}" var="items">

                    <c:campingListItem item="{!item}"/>

                </aura:iteration>

            </div>

        </section>

    </div>

        </fieldset>
    </div>

</aura:component>


Component Controller:

({
    clickCreate: function(component, event, helper) {
        var validItem = component.find('itemform').reduce(function (validSoFar, inputCmp) {
            // Displays error messages for invalid fields
            inputCmp.showHelpMessageIfInvalid();
            return validSoFar && inputCmp.get('v.validity').valid;
        }, true);
        
    }
})

But the button "Click Create" has become static and is not working.Please help me so that it works!!!!


Please help.
Thanks in advance.
Please help!
Is it possible to set logs for lightning components?


Thanks in advance!
Please help.Here is my code.
It creates form to be filled by a user.
When I trying to type inside the form,nothing is happening.
Please help.


Code:-

<aura:component>
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem padding="horizontal-large">
            <div class="page-section page-header">
               
                <h1 class="slds-text-heading--large">School Application Form</h1>
               
            </div>   
            <div>
                <h2 class="slds-text-heading--medium">Form Details</h2>
            </div>
        </lightning:layoutItem>
    </lightning:layout> 
    
    
    <lightning:layout>
        <lightning:layoutItem padding="around-large" size="10">
            <!-- CREATE NEW EXPENSE -->
    <div aria-labelledby="newschoolApplicationform">
    
    <lightning:layout>
        <lightning:layoutItem padding="around-small" size="6">
            <!-- CREATE NEW School application form -->
    <div aria-labelledby="newschoolform">
         </div>
        </lightning:layoutItem>
    </lightning:layout>
    
     <fieldset class="slds-box slds-theme--default slds-container--small">
        <legend id="newschoolform" class="slds-text-heading--small 
          slds-p-vertical--medium">
          Add Details
        </legend>
    
     <!-- CREATE NEW SCHOOL APPLICATION FORM -->
        <form class="slds-form--stacked">          
            <lightning:input type="text" aura:id="schoolform" label="School Name"
                             name="Name"
                             value="{!v.newSchool.Name}"
                             required="true"/> 
            <lightning:input type="Phone" aura:id="schoolform" label="Mobile Ph No" 
                             name="Mobile Number"
                             value="{!v.newSchool.Mobile_Number__c}"
                             required="true"
                             messageWhenRangeUnderflow="Enter mobile number with 10 digits"/>
            <lightning:input aura:id="schoolform" label="Contact Address"
                             name="Address"
                             required="true"
                             value="{!v.newSchool.Contact_Address__c}"
                             />
            <lightning:input type="checkbox" aura:id="schoolform" label="Wanna Enjoy Schooling?"  
                             name="Wanna join the school"
                             required="true"
                             checked="{!v.newSchool.Do_you_wanna_join_the_mentioned_school__c}"/>
            <lightning:button label="Submit" 
                              class="slds-m-top--medium"
                              variant="brand"
                              onclick="{!c.clickCreate}"/>
        </form>
        <!-- / CREATE NEW EXPENSE FORM -->
  
      </fieldset>
      <!-- / BOXED AREA -->
        
            </div>
    
            </lightning:layoutItem>
    </lightning:layout>
    <!-- / NEW EXPENSE FORM -->
    
</aura:component>
Developer console is not opening.
It showing page loading since longer time.
So instead of Developer Console is there any other tool where we can write Lightning Component code?

Please help.