+ Start a Discussion
Neil Hatch 9Neil Hatch 9 
Hi,
I have a field validation that requires a comment being added when certain picklist values are manually selected. This works fine.

As the picklist field is also being updated by a Process Builder I need to add text comment to my comment field. Is there a way that I can append this text? at the moment my PB text over writes all previous comments. 
Best Answer chosen by Neil Hatch 9
Raj VakatiRaj Vakati
you can able to add like below 

User-added image
abu saleh khan 20abu saleh khan 20 
Hi I am getting this error when i call one component from another component by clicking on the button.

Comp2CompNav:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,lightning:isUrlAddressable" description="c:Comp2CompNav component" access="global" >
    <aura:attribute name="firstname" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.doinit}"/>
    Hello {!v.firstname}.
</aura:component>    

js: 
({
    doinit: function(cmp, evt, helper) {
        var myPageRef = cmp.get("v.pageReference");
        var firstname = myPageRef.state.c__firstname;
        console.log('Check value with new way of fetching: '+firstname);
        cmp.set("v.firstname", firstname);
    }
})


Comp2CompNav2:
From this component I am calling another Component.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" description="c:Comp2CompNav2 component" access="global" >
    
    <aura:attribute name="pageReference" type="Object"/>
    <aura:handler name="init" value="{!this}" action="{!c.doinit }"/>
    <lightning:navigation aura:id="navService"/>
    <lightning:button label="Navigate" onclick="{!c.handleClick}"/>
</aura:component>    


js:

({
    doinit : function(component, event, helper) {
        var pageReference = {
            type: 'standard__component',
            attributes: {
                componentName: 'c__Comp2CompNav',
            },
            state: {
                "c__firstname": "John"
            }
        };
        component.set("v.pageReference", pageReference);
     },
     handleClick: function(component, event, helper) {
        var navService = component.find("navService");
        var pageReference = component.get("v.pageReference");
       // event.preventDefault();
        navService.navigate(pageReference);
    }
})

Error Message
Best Answer chosen by abu saleh khan 20
Khan AnasKhan Anas (Salesforce Developers) 
Hi Abu,

Greetings to you!

According to lightning:isUrlAddressable documentation (https://developer.salesforce.com/docs/component-library/bundle/lightning:isUrlAddressable/documentation):

This navigation feature is supported only in Lightning Experience and the Salesforce App.

This component is not supported in Lightning Application but only in Lightning Experience and Salesforce Mobile App.

Also, see below release notes (https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_lc_components_navigation.htm) for New Lightning Navigation APIs for Lightning Components:

Where: This change applies to orgs with Lightning components in Lightning Experience and all versions of the mobile app. These resources aren’t supported in other containers, such as Lightning Components for Visualforce, Lightning Out, or Communities. This is true even if you access these containers inside Lightning Experience or the Salesforce mobile app.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Sharmila Sahu 12Sharmila Sahu 12 
I want to set record type while creating record in lightning component through e.force:createRecord. But I am not able to do so.
I tried using custom label and even I tried hardcoding still It is not showing correct record type and it is showing default record type for record creation.
Please find below code for javascript controller:
({
    doInit: function (component, event, helper) {
        var recId = component.get("v.recordId");
        console.log(recId);

        var action = component.get("c.getdetails");
        action.setParams({
            "sId": recId
        });
        action.setCallback(this, function (response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                $A.get("e.force:closeQuickAction").fire();
                console.log("Success" + JSON.stringify(response.getReturnValue()));
                component.set("v.sampleRequest", response.getReturnValue());
                var sampProd = component.get("v.sampleRequest");
                
                 if(sampProd.Lead__c === sampProd.Contact__c){
                    var Name = sampProd.Contact__r.Name;
                }
                else
                {
                   var Name = sampProd.Lead__r.Name; 
                }
                


                var createSampleProduct = $A.get("e.force:createRecord");
                var staticRecordLabel = $A.get("$Label.c.UsCanSampleProductRecordType");
                createSampleProduct.setParams({
                    "entityApiName": "Sample_Product__c",
                    "RecordTypeId": '0121b0000004aeSAAQ',
                    "defaultFieldValues": {
                        'Sample_Request__c' : component.get("v.recordId"),
                        'Name__c': Name,                    
                    }
                });
                createSampleProduct.fire();
            } else {
                console.log("Fail");
            }
        });
        $A.enqueueAction(action);
    }
})

I tried hardcoding:
              var staticRecordLabel = $A.get("$Label.c.UsCanSampleProductRecordType");
                createSampleProduct.setParams({
                    "entityApiName": "Sample_Product__c",
                    "RecordTypeId": '0121b0000004aeSAAQ',

I have tried using:

            var staticRecordLabel = $A.get("$Label.c.UsCanSampleProductRecordType");
                createSampleProduct.setParams({
                    "entityApiName": "Sample_Product__c",
                    "RecordTypeId": staticRecordLabel ,

it is just showing for 1 sec 
UsCanSampleProductRecordType and then it is taking me to record creation page with default record type.

Please help. 
Best Answer chosen by Sharmila Sahu 12
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sharmila,

Greetings to you!

You need to use recordTypeId instead of RecordTypeId as lightning is based on aura framework which is a type of JavaScript and JavaScript is case sensitive so lightning is case sensitive.

Please refer to the below links which might help you further.

http://sfdcmonkey.com/2017/05/09/custom-record-type-selection-lightning-component/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
The new LearnerThe new Learner 
Hi Experts,

I have small requirement where i need to filter a long text area field called Desc__c which i am not able to do that can anyone help me please.

OrderItem oli1 = new OrderItem ();
        oli1.Orderid = order.Id;
        oli1.Desc__c= 'Test OLI 1'; 
      insert oli1;


 OrderItem oli2 = [SELECT Id, Orderid
                    FROM OrderItem WHERE  Desc__c = 'Test OLI 1' LIMIT 1];

In this filter condition its throwing an error can anyone help me please thanks in adavance
Best Answer chosen by The new Learner
Bhargavi TunuguntlaBhargavi Tunuguntla
Then the first solution might work:

All the orderItems with 'Test OLI 1' in desc__c will be added to the list 'oli2'.
List<OrderItem > oli2= new List<OrderItem >(); 
for(OrderItem  oli : [SELECT Id, Orderid FROM OrderItem) { 
if(oli.Desc__c.contains('Test OLI 1')) { 
oli2.add(oli);
} 
}
AJAY KRISHNA RAJAY KRISHNA R 
Challenge Not yet complete... here's what's wrong:  There was an unexpected error while verifying this challenge. Usually, this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: HGSGLHNZ
 
Best Answer chosen by AJAY KRISHNA R
Khan AnasKhan Anas (Salesforce Developers) 
Hi Ajay,

Make sure that you have provided the correct Group Description.

Group Description: This group is for all Lusso Scarpe employees to collaborate and receive company announcements. All employees can join the group

Regards,
Khan Anas
Evan GillardEvan Gillard 
When I am doing my Lightning Reports and Dashboards Superbadge, after I create the Top Case Drivers by SolarBot Ownership, it comes up with the following error... "There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: WNGEFDSV", if I then delete that report then it says "We can’t find a report with name “Top Case Drivers by SolarBot Ownership” in the correct folder, or it uses an incorrect report type."
Best Answer chosen by Evan Gillard
Evan GillardEvan Gillard
Ok, this was actually fixed. I continued with the instructions for the challenge, ignorning the error message. For challenge 3 for instance I have now done the SolarBot ownership grouping and case reason grouping. Then saved. Error is now: We can’t find the categorization called 'SolarBot Ownership', or the categorization is based on an incorrect field, or the category settings are incorrect on the 'Top Case Drivers by SolarBot Ownership' report. which should be easily fixed on my part. Hope this helps anyone else
David Allen 26David Allen 26 
I am unable to complete challenge for "Business Administration Specialist" superbadge. 
When checking challenge 3, Create reports and dashboards, it says

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: RMKQULNG
Close errors.

I started with a clean org for this and have done nothing in it except what was required. Though of course I may have done something wrong.

Does anyone know how to address an error such as this? 
Best Answer chosen by David Allen 26
David Allen 26David Allen 26
I fixed it myself. I edited a layout of a table in the dashboard and refreshed it, even though that was a random guess in teh dark. 
I tried again and it worked. I have no idea what it was thinking. They need a bit more error-handling code in that checker.
Best Answer chosen by sarthak das 4
Deepali KulshresthaDeepali Kulshrestha
Hi sarthak,

If you are facing problem related to this challenge.
Please refer to these links it may be helpful for you.
https://developer.salesforce.com/forums/?id=9060G000000MQwtQAG
https://success.salesforce.com/answers?id=9063A000000DnTIQA0
https://www.youtube.com/watch?v=7Kqq6nzDwqI

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
FreddySFreddyS 
Hello, can someone point me in the right direction on writing a test class for this apex controller (for a lightning component DataTable). Below is my controller and test class so far. My test class is covering 55% and covers the getRecords soql method but I cannot get the test class to cover the update list method (database.update).

The objects parent, child, and grandchild are in masterdetil relationships and require lookups to one another so there will always be a parent, child, and grandchild in the data model. 

Thanks so much!
 
Controller: 

public class LightningDataTableCtrl {
    @AuraEnabled    
    public static List <grandchild__c> getRecords (String parentId) {   
        List <grandchild__c> updatedObjList = 
            [SELECT Id,
             Name,
             Text_Formula__c,
             Status_Picklist__c,
             Hours_Number_Field__c,
             Custom_Lookup__c,
             Number_Field__c,
             Number_Field_2__c,
             Custom_Picklist__c
             FROM grandchild__c
             WHERE child__r.parent__c = :parentId
             ORDER BY Name ASC];
        return updatedObjList;
    }    
    @AuraEnabled    
    public static void updateRecords( List <grandchild__c> updatedObjList ) {    
        try {  
            Database.update (updatedObjList); 
            
        } catch(Exception e) {  
            
        }  
    }  
}

Test Class: 

@isTest
public class LightningDataTableCtrlTest {
    @isTest (SeeAllData = 'true') static void testGetRecords() {
       
        parent__c parent = new parent__c(Name = 'Lightning Data Table Apex Test', 
                                                                          parent_type_picklist__c = 'Duration');
        insert parent;
        
        child__c child = new child__c(Name = 'Apex Test Phase', 
                                                                                    parent__c = parent.Id);
        insert phase;
        
        grandchild__c grandchild = new grandchild__c(Name = 'Apex Test Task',
                                                                                 child__c = child.Id,
                                                                                 Number_field__c = 1, 
                                                                                 Date_field__c = Date.newInstance(2018, 4, 27),
                                                                                 Number_Field_2__c = 1);
        insert task;
        // List covers the soql and 'getRecords' method of the class.
        List <grandchild__c> getRecords = LightningDataTableCtrl.getRecords(granchild.id);
        
        // Test method to cover update method in controller        
    }
}

 
Best Answer chosen by FreddyS
Prakhar Saxena 19Prakhar Saxena 19
Hi FreddyS,

You can create another test method for updateRecords method.
 
@isTest
static void testUpdateRecords(){

   List<grandchild__c> updatedObjList = new List<grandchild__c>();
   LightningDataTableCtrl.updateRecords(updatedObjList);

}

Additionally, if you want to pass the same updatedObjList that you inserted in the testGetRecords method, then you will have to use @testSetup annotation for testGetRecords method.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_testsetup_using.htm

If you want to use any test data in other test methods, then insert all such data in a method with @testSetup annotation and query the same in other methods. With @testSetup annotation, you can create test records once and access them in every test method.

Thanks.
Prakhar
 
Patrick James 13Patrick James 13 
Hi,

I am just trying to get a handle on AND/OR syntax.  I have the following that does not get a syntax error, but I am not sure it is doing what I want it to.

What I want is for this to trigger if:

date_Sent_to_Customer is today
OR
if the RecordType is Quote Request and the Quote Amount is > 5000.

Does this do that?

AND
(  OR   (TODAY() =  Date_Sent_to_Customer__c ),
    RecordType.Name = "Quote Request",
    Quote_Amount__c > 5000,
 )
 
Best Answer chosen by Patrick James 13
Raj VakatiRaj Vakati
Try this 
 
OR(
 Date_Sent_to_Customer__c =TODAY(),
 AND(
     RecordType.Name = "Quote Request",
    Quote_Amount__c > 5000
	)
)