• Mounica M 10
  • NEWBIE
  • 5 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies

I am salesforce administrator getting my hand dirty with development

In apex class, I am not able to set Accountshare.ContactAcessLevel to edit.

Error: Field is not writeable: AccountShare.ContactAccessLevel
OWD setting on account object is public read-only and contact is controlled by the parent.

Hello,

I have a lightning component in which a window pops up on certain command. now i need to close the pop up on clicking ouside of the window or hitting esc button on key pad any ideas? Thank in advance

how to redirect to the detail record page when you click a button on a lightning component
I have calendar component(component-1) . when ever we click on a date, it pops a table with list of recordspresent in a day(component 2).now when we select a record by checking the check box beside it and click submit button it should be redirected to the record detail page.
Note: all the above is being implemented in a community built for the internal users.
component-2
<aura:component controller="EventDataTableServerCtrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="StartTest" type="Date"/>
    <aura:attribute name="StartDate" type="string" default="0"/>
    <aura:attribute name="EndDate" type="String" default="2018-01-02T12:00:00-05:00"/>
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="SelectedRecord" type="String[]" default="0"/> 
    <!-- <aura:attribute name="isOpen" type="boolean" default="false"/> -->
          
    <aura:handler name="change" value="{!v.StartTest}" action="{!c.handleValueChange}"/>
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
      
       <div style="height: 300px;">
        <lightning:datatable data="{! v.mydata }" 
        columns="{! v.mycolumns }" 
        keyField="Id"
        resizeColumnDisabled="True"
        onrowselection="{!c.getSelectedName}"/>
        </div>
    
             
       <lightning:button variant="brand" label="Submit" onclick="{! c.closeModel }" /> 
   
 
  
</aura:component>

controller
({
    init: function (cmp, event, helper) {
        //console.log(new Date(cmp.get('v.StartDate')).getMilliseconds());
        cmp.set('v.mycolumns', [
            {label: 'Event Name', fieldName: 'Name', type: 'text'},
            {label: 'Start Date & Time', fieldName: 'Event_Start_date_and_time__c', type: 'Date/Time'},
            {label: 'End Date & Time', fieldName: 'Event_End_Date__c', type: 'Date/Time'}
        ]);
        //helper.getData(cmp);
    },
    handleValueChange : function (component, event, helper) {
         component.set('v.mycolumns', [
            {label: 'Event Name', fieldName: 'Name', type: 'text'},
            {label: 'Start Date & Time', fieldName: 'Event_Start_date_and_time__c', type: 'Date/Time'},
            {label: 'End Date & Time', fieldName: 'Event_End_Date__c', type: 'Date/Time'}
        ]);
        
        // handle value change
        var date = event.getParam("value");
        component.set('v.StartDate',date);
        //component.set('v.StartDate',event.getParam("value"));
        console.log("old value: " + event.getParam("oldValue"));

        console.log("current value: " + event.getParam("value"));
        helper.getData(component);

    },
    getSelectedName: function (cmp, event) {
        
        var selectedRows = event.getParam('selectedRows');
        for (var i = 0; i < selectedRows.length; i++){
            console.log(selectedRows[i].Id);
            cmp.set('v.SelectedRecord',selectedRows[i].Id);
        }
    },
    
   
           
   },
 
   
      gotoURL : function (cmp, event, helper) {
    var eventId = cmp.get('v.SelectedRecord');
    var navEvt = $A.get("e.force:navigateToSObject");
    navEvt.setParams({
      "recordId": eventId,
    });
    navEvt.fire();
    }
})User-added image
how to redirect to the detail record page when you click a button on a lightning component
I have calendar component(component-1) . when ever we click on a date, it pops a table with list of recordspresent in a day(component 2).now when we select a record by checking the check box beside it and click submit button it should be redirected to the record detail page.
Note: all the above is being implemented in a community built for the internal users.
component-2
<aura:component controller="EventDataTableServerCtrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="StartTest" type="Date"/>
    <aura:attribute name="StartDate" type="string" default="0"/>
    <aura:attribute name="EndDate" type="String" default="2018-01-02T12:00:00-05:00"/>
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="SelectedRecord" type="String[]" default="0"/> 
    <!-- <aura:attribute name="isOpen" type="boolean" default="false"/> -->
          
    <aura:handler name="change" value="{!v.StartTest}" action="{!c.handleValueChange}"/>
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
      
       <div style="height: 300px;">
        <lightning:datatable data="{! v.mydata }" 
        columns="{! v.mycolumns }" 
        keyField="Id"
        resizeColumnDisabled="True"
        onrowselection="{!c.getSelectedName}"/>
        </div>
    
             
       <lightning:button variant="brand" label="Submit" onclick="{! c.closeModel }" /> 
   
 
  
</aura:component>

controller
({
    init: function (cmp, event, helper) {
        //console.log(new Date(cmp.get('v.StartDate')).getMilliseconds());
        cmp.set('v.mycolumns', [
            {label: 'Event Name', fieldName: 'Name', type: 'text'},
            {label: 'Start Date & Time', fieldName: 'Event_Start_date_and_time__c', type: 'Date/Time'},
            {label: 'End Date & Time', fieldName: 'Event_End_Date__c', type: 'Date/Time'}
        ]);
        //helper.getData(cmp);
    },
    handleValueChange : function (component, event, helper) {
         component.set('v.mycolumns', [
            {label: 'Event Name', fieldName: 'Name', type: 'text'},
            {label: 'Start Date & Time', fieldName: 'Event_Start_date_and_time__c', type: 'Date/Time'},
            {label: 'End Date & Time', fieldName: 'Event_End_Date__c', type: 'Date/Time'}
        ]);
        
        // handle value change
        var date = event.getParam("value");
        component.set('v.StartDate',date);
        //component.set('v.StartDate',event.getParam("value"));
        console.log("old value: " + event.getParam("oldValue"));

        console.log("current value: " + event.getParam("value"));
        helper.getData(component);

    },
    getSelectedName: function (cmp, event) {
        
        var selectedRows = event.getParam('selectedRows');
        for (var i = 0; i < selectedRows.length; i++){
            console.log(selectedRows[i].Id);
            cmp.set('v.SelectedRecord',selectedRows[i].Id);
        }
    },
    
   
           
   },
 
   
      gotoURL : function (cmp, event, helper) {
    var eventId = cmp.get('v.SelectedRecord');
    var navEvt = $A.get("e.force:navigateToSObject");
    navEvt.setParams({
      "recordId": eventId,
    });
    navEvt.fire();
    }
})User-added image

I am salesforce administrator getting my hand dirty with development

In apex class, I am not able to set Accountshare.ContactAcessLevel to edit.

Error: Field is not writeable: AccountShare.ContactAccessLevel
OWD setting on account object is public read-only and contact is controlled by the parent.

Hello All,
I wrote a simple Trigger to not allow deletion of a specific record. Also, I wrote a Test Class with 100% code coverage in dev. When attempting change set I am receiving a Code Coverage Failure, with 0% code coverage. What is happening? I have tried the Change Set as both Default, and only run the Test related to my Trigger. I am deploying both in the same Change Set. All suggestions appreciated!
Thanks, Ryan
Trigger:
trigger callapplyTrigger on Lead (before update, before insert,before delete){
    if(Trigger.isDelete){
        for (Lead l : [SELECT Id,Email FROM Lead WHERE Email = 'testingtrigger1@test.com' AND Id IN :Trigger.old]){
            Trigger.oldMap.get(l.Id).addError(
                'Cannot delete this Lead.');
        }
    }
}
Test Class:
@isTest
public class Test_callApply {
    @isTest static void TestDelete(){
        Lead lead = new Lead(Segment__c='Small Group',Email='testingtrigger1@test.com',
                             FirstName='testRyan',LastName='testGreene',Status='New',
                          Company='testCompany',City='Orlando',State='FL',LeadSource='Event');
        insert lead;
        
        Test.startTest();
        Database.DeleteResult result = Database.delete(lead,false);
        Test.stopTest();

        System.assert(!result.isSuccess());
        System.assert(result.getErrors().size() > 0);
        System.assertEquals('Cannot delete this Lead.',result.getErrors()[0].getMessage());
    }
}

 
how to redirect to the detail record page when you click a button on a lightning component
I have calendar component(component-1) . when ever we click on a date, it pops a table with list of recordspresent in a day(component 2).now when we select a record by checking the check box beside it and click submit button it should be redirected to the record detail page.
Note: all the above is being implemented in a community built for the internal users.
component-2
<aura:component controller="EventDataTableServerCtrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="StartTest" type="Date"/>
    <aura:attribute name="StartDate" type="string" default="0"/>
    <aura:attribute name="EndDate" type="String" default="2018-01-02T12:00:00-05:00"/>
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="SelectedRecord" type="String[]" default="0"/> 
    <!-- <aura:attribute name="isOpen" type="boolean" default="false"/> -->
          
    <aura:handler name="change" value="{!v.StartTest}" action="{!c.handleValueChange}"/>
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
      
       <div style="height: 300px;">
        <lightning:datatable data="{! v.mydata }" 
        columns="{! v.mycolumns }" 
        keyField="Id"
        resizeColumnDisabled="True"
        onrowselection="{!c.getSelectedName}"/>
        </div>
    
             
       <lightning:button variant="brand" label="Submit" onclick="{! c.closeModel }" /> 
   
 
  
</aura:component>

controller
({
    init: function (cmp, event, helper) {
        //console.log(new Date(cmp.get('v.StartDate')).getMilliseconds());
        cmp.set('v.mycolumns', [
            {label: 'Event Name', fieldName: 'Name', type: 'text'},
            {label: 'Start Date & Time', fieldName: 'Event_Start_date_and_time__c', type: 'Date/Time'},
            {label: 'End Date & Time', fieldName: 'Event_End_Date__c', type: 'Date/Time'}
        ]);
        //helper.getData(cmp);
    },
    handleValueChange : function (component, event, helper) {
         component.set('v.mycolumns', [
            {label: 'Event Name', fieldName: 'Name', type: 'text'},
            {label: 'Start Date & Time', fieldName: 'Event_Start_date_and_time__c', type: 'Date/Time'},
            {label: 'End Date & Time', fieldName: 'Event_End_Date__c', type: 'Date/Time'}
        ]);
        
        // handle value change
        var date = event.getParam("value");
        component.set('v.StartDate',date);
        //component.set('v.StartDate',event.getParam("value"));
        console.log("old value: " + event.getParam("oldValue"));

        console.log("current value: " + event.getParam("value"));
        helper.getData(component);

    },
    getSelectedName: function (cmp, event) {
        
        var selectedRows = event.getParam('selectedRows');
        for (var i = 0; i < selectedRows.length; i++){
            console.log(selectedRows[i].Id);
            cmp.set('v.SelectedRecord',selectedRows[i].Id);
        }
    },
    
   
           
   },
 
   
      gotoURL : function (cmp, event, helper) {
    var eventId = cmp.get('v.SelectedRecord');
    var navEvt = $A.get("e.force:navigateToSObject");
    navEvt.setParams({
      "recordId": eventId,
    });
    navEvt.fire();
    }
})User-added image
The following won't validate, but won't pass the validation in this trail.  Quantity field is howver using the correct field.  Thoughts?

User-added image

<aura:component>

<aura:attribute name="item" type="Camping_Item__c" required="true"/>    
    <ui:outputText value="{!v.item.Name}"/>
    <ui:outputCheckbox value="{!v.item.Packed__c}"/>
    <ui:outputCurrency value="{!v.item.Price__c}"/>
      <ui:outputNumber value="{!v.item.Quantity}"/>
            
</aura:component>