• Gautam_Kasukhela
  • NEWBIE
  • 60 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 23
    Replies
Hey All,
     How can I access a custom URL defined for a community in Apex? 
     I am getting the base URL in Apex by using 
Network.getLoginUrl(communityId)
but this does not give me the custom URL, it gives me the base Url.
e.g my community base url : 
https://abc.force.com/community1
but my Custom URL configured (Setup> Custom URL) for this community is https://www.community1.com

and I want to read the custom URL value in Apex. Any pointers?

Regards,
Gautam.
 
I am encountering an error when I run a simple query on the Contact record. Email is again a Standard Field 
SELECT Id FROM Contact WHERE Email = 'asd@gmail.com'
I get the below error:-
"
[object Object]: SELECT Id FROM Contact WHERE Email = 'asd@gmail.com' ^ ERROR at Row:1:Column:30 field 'Email' can not be filtered in a query call
"

User-added image
Why can't I filter using a Standard (non text area field)??
 

I am having trouble completing this badge. I keep getting an error that reads "We can’t find 'reduceErrors' imported into contactList.js."

I double checked the component, it is saved and has the the import statement. My workspace also has the ldsUtils component and even that is saved. This should have been a walk in the park challenge as a similar one is already stated in the trailhead module. Even with similar code as mentioned, I get an error: (https://trailhead.salesforce.com/content/learn/modules/lightning-web-components-and-salesforce-data/handle-server-errors)

//JS FILE
import {
    reduceErrors
} from 'c/ldsUtils';
import {
    LightningElement,
    wire
} from 'lwc';

import FIRST_NAME_FIELD from '@salesforce/schema/Contact.FirstName';
import LAST_NAME_FIELD from '@salesforce/schema/Contact.LastName';
import EMAIL_FIELD from '@salesforce/schema/Contact.Email';
import getContacts from '@salesforce/apex/ContactController.getContacts';

const COLUMNS = [{
        label: 'First Name',
        fieldName: FIRST_NAME_FIELD.fieldApiName,
        type: 'text'
    },
    {
        label: 'Last Name',
        fieldName: LAST_NAME_FIELD.fieldApiName,
        type: 'text'
    },
    {
        label: 'Email',
        fieldName: EMAIL_FIELD.fieldApiName,
        type: 'email'
    },
];

export default class ContactList extends LightningElement {

    columns = COLUMNS;
    errors;
    @wire(getContacts)
    contacts;


    get errors() {
        console.log('this.contacts.error: ', this.contacts.error);
        return (this.contacts.error) ? reduceErrors(this.contacts.error) : [];
    }
}

//HTML FILE
<template>
    <lightning-card title="Contact List">


        <template if:true={errors}>
            <p>{errors}</p>
        </template>

        <!--<lightning-datatable key-field="Id" data={contacts.data} columns={columns}>
        </lightning-datatable> -->
    </lightning-card>


</template>

//Controller

public with sharing class ContactController {
    
    @AuraEnabled(cacheable = true)
    public static List<Contact> getContacts(){
        
        //return [SELECT FirstName, LastName, Email FROM Contact];
        throw new AuraHandledException('Forced error');
    }
}
Hello All,
    I have an Apex class (SendEmailCommunications) that implements "Database.Batchable<sObject>,Schedulable" and has the 'start', 'execute' & 'finish' methods.
global Database.QueryLocator start(Database.BatchableContext bc)
{
return Database.getQueryLocator( <My Query>);
}

global void execute(Database.BatchableContext bc, List<My_Custom_Object> scope){
        System.debug('Scope Size is: '+scope.size());
 //more logic
}

global void finish(Database.BatchableContext bc)
    {
        System.debug('Sent emails');
    }
I have used the 'Apex Scheduler' in Setup to schedule this class to run at a designated time. As per the logs, the batch job starts and finshes without running any logic. Even the first system.debug statement in my execute method does not get logged.
User-added image
What am I missing here?
 
I am building a custom component to show a list of Cases filtered by a certain criteria. I am using <lightning:dataTable> for this. One of the columns in the list is Record Type and I am unable to display the Name of the Record Type in my list component. It shows up as Id.
 
<lightning:datatable
                             data="{! v.caseData}" 
                              columns="{! v.caseColumns}" 
                              keyField="Id" hideCheckboxColumn="true"/>

//Helper. JS
component.set('v.caseColumns', [
					{label: 'Case Number', fieldName: 'linkName', 
                     type: 'url', 
                     typeAttributes: {label: { fieldName: 'CaseNumber'},target: '_blank'}},
					{label: 'Status', fieldName: 'Status', type: 'text'},
					{label: 'Subject', fieldName: 'Subject', type: 'text'},
                    {label: 'Record Type', fieldName: 'RecordTypeId', type: 'text'},
				]);

//Controller code
listOfCases = [SELECT Id,
                               CaseNumber,
                               Status,
                               RecordType.Name,
                               Subject,
                               OwnerId,
                               CreatedDate
                          FROM Case WHERE xyz...];

In the helper, on the column attributes for Record Type fieldName, I have tried options other than 'RecordTypeId' but that do not show anything in the column. When I run the query in the Console I can see the developer name. What am I missing or doing incorrectly here.

User-added image
Hello All,
    Need help in resolving an issue. I am trying to display the Status picklist field on a lightning component. For this I have written a server side controller to fetch the values and set in the component. 
During the callback in the helper, I keep encountering an error where the reposne is ERROR and the message in the ERROR reads "Unable to read sObject". Below is the code: 

Component Code
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
                access="global"
                controller="FetchValuesFromDatabase">

<aura:handler name="init" value="this" action="{!c.doInit}"/>

<aura:attribute name="case" type="Case" default="{'sObjectType': 'case'}"/>
<aura:attribute name="listOfStatusPicklistValues" type="list" default="[]" description="List of Status Picklist values on Case object"/>

<aura:attribute name="statusFieldAPI" type="string" default="status" description="API name of the Status field whose picklist values we want to fetch"/>
<aura:attribute name="originFieldAPI" type="string" default="origin" description="API name of the Origin field whose picklist values we want to fetch"/>

    <!-- CREATE NEW CASE -->
    <div aria-labelledby="newCaseForm">
        <!-- BOXED AREA -->
        <fieldset class="slds-box slds-theme--default slds-container--small">
        <legend id="newCaseForm" class="slds-text-heading--small 
          slds-p-vertical--medium">
          Add Case
        </legend>
  
        <!-- Create New Case Form : START -->
        <form class="slds-form--stacked">          
            <lightning:select aura:id="newCaseForm" label="Status"
                              name="caseStatus"
                              value="{!v.case.Status}"
                              required="true">
                <aura:iteration items="{!v.listOfStatusPicklistValues}" var="status">
                    <option value="{!status}">{!status} </option>
                </aura:iteration>              
                              

            </lightning:select>                  
            <lightning:select aura:id="newCaseForm" label="Case Origin"
                              name="caseOrigin"
                              value="{!v.case.Origin}"
                              required="true"/>                   
            <lightning:textarea aura:id="newCaseForm" label="Description"
                             name="caseDescription"
                             value="{!v.case.Description}"/>
            
    
        </form>
        <!-- Create New Case Form : END -->
      </fieldset>
      <!-- / BOXED AREA -->
    </div>
    <!-- / CREATE NEW CASE -->
</aura:component>
Controller Code:-
({
    doInit : function(component, event, helper) {
        //get the details of the Object and its fields that we want to retrieve. These have been defined
        // as attributes in the component.
        var picklistFieldAPI = component.get("v.statusFieldAPI");
        var objDetails       = component.get("v.case");

        //call the helper to fetch the values of the picklist from database
        helper.fetchPickListValues(component,objDetails,picklistFieldAPI);
        

    }
})

Helper Code
({
    fetchPickListValues : function(component,objDetails,picklistFieldAPI) {
            //invoke the server-side controller to get the picklist values
            var action = component.get("c.getPicklistValues");
            action.setParams({
                'objDetails' : objDetails,
                'picklistFieldAPI' : picklistFieldAPI
            });
        //set callback action
        action.setCallback(this,function(response){
            debugger;
            if(response.getState() == "SUCCESS"){
                //set the response in the component field
               component.set("v.listOfStatusPicklistValues",response.getReturnValue());
            } else if(response.getState() == "ERROR"){
                var errors = response.getError();
                alert(errors);
            }
        });
			$A.enqueueAction(action);
    }
})

Client-Side Controller Code
public class FetchValuesFromDatabase {
   
    @AuraEnabled
    public static List<String> getPicklistValues(SObject objDetails, string picklistFieldAPI){
        List<String> pickListValues = new List<String>();

        //Check if the object type passed from the component is not null. I yes, return empty list
        Schema.sObjectType objType = objDetails.getSObjectType();
        if(objType == null){
               return pickListValues; 
        }

        //Check if the field API names passed from the component are present on the object.
        //If not, return an empty list
        //Get the fields corresponding to the object in a MAP
        Map<String,Schema.SObjectField> objFieldsMap = objType.getDescribe().fields.getMap();
        if(!objFieldsMap.containsKey(picklistFieldAPI)){
            return pickListValues;
        }
        
        //Get the picklist values of the field
        List<Schema.PicklistEntry> pickListEntries = objFieldsMap.get(picklistFieldAPI).getDescribe().getPicklistValues();
        for(Schema.PicklistEntry ple: pickListEntries){
            pickListValues.add(ple.getValue());
        }
        System.debug('pickListValues: '+pickListValues);
        return pickListValues;
    }
}

what am i missing ?​​​​​​​

 
I am trying to load a lightning card with data from 4 fields of the Account object using "force:recordData" .
I see only one field's data i.e. of the 'Name' field. Following is a code of my component:-
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
	
    <aura:attribute name ="record" type="Object"
                    description="the record object to be displayed"/>
    <aura:attribute name="simpleRecord" type ="Object"
                    description="simplified view record object to be displayed."/>
    <aura:attribute name="recordError" type="String" 
  					description="An error message bound to force:recordData"/>
    <force:recordData 	aura:id="record"
    					layoutType="FULL"
                        recordId="{!v.recordId}"
                        targetError="{!v.recordError}"
                        targetRecord="{!v.record}"
                        targetFields ="{!v.simpleRecord}"
                        mode="VIEW"/>
    <!-- Use the Lightning Data Service to populate the data-->
    <div class="Record Details"> 
        <lightning:card iconName="standard:account" title="{!v.simpleRecord.Name}" >
		            
        <div class="slds-p-horizontal--small">
            <p class="slds-text-heading--small">
                <lightning:formattedText title="Annual Revenue" value="{!v.simpleRecord.AnnualRevenue}" /></p>
            <p class="slds-text-heading--small">
                <lightning:formattedText title="Number of Employees" value="{!v.simpleRecord.NumberOfEmployees}" /></p>
            <p class="slds-text-heading--small">
                <lightning:formattedText title="Billing City" value="{!v.simpleRecord.BillingCity}" /></p>
        </div>
    </lightning:card>
</div>
<!-- Display Lightning Data Service errors, if any -->
<aura:if isTrue="{!not(empty(v.recordError))}">
    <div class="recordError">
        {!v.recordError}</div>
</aura:if>
                                 
    
    
</aura:component>
What am I missing here that is resulting in a page like the below:-
I am using an Admin profile and I have validated that the fields have data and is accessible for this profile.

User-added image
 
Hello All,
   This is with reference to a trailhead example under (Lightning Component Basics > Handle Actions with Controllers) :
I am trying to invoke a component that invokes a controller. However, when I am clicking on the buttons, nothing happens on the page and neither do I see any logs in the console or error messages in the developer console.

I am wondering if the way I am invoking the component is correct or if I am missing anything else? Screen shots of my code snippets are attached below:-

User-added imageUser-added imageUser-added imageUser-added image
Hello All,
     The SOSL query that I am using to search for a picklist value on a custom object does not return any results, although there are 25 records  in the custom object that contain the value that I am searching for. 

FIND {Airbus} IN ALL FIELDS RETURNING Aircraft__c(Date_of_purchase__c)

I am searching for the 'Airbus' value in all the fields. The Object's 'isSearchable' property is also true. Is there anything that I am missing here?

Regards,
Gautam.
Hello All,
      I am facing a Callout exception which says " Illegal character(s) in message header value: 
{"HEADER": {"APPLICATION-ID": "APP-0000010120", "CUST-ID": "P/001N000000p35DTIAY","REQUEST-TYPE": "REQUEST","REQUEST-TIME":"08092016 16:15:11"},"REQUEST": {"03":"PERSONAL LOAN","04":"421000","07":"DIRECT","11":"QA/UAT","21": {"01":"A B C"},"22":"MALE","27":"02091992","29":[ {"01":"RESIDENCE","03":"543543544","04":"Bihupuria","06":"Assam","05":"435435"}],"30":{"01":"YHGPS7560W"},"31":[{"01": "MOBILE","02":"9664561852"}],"36":"456465465464"}}
"

I have set the header if the request as follows:-
httpReq.setHeader('inputJson_',jsonRequestBody); 
In the 'jsonRequestBody', I have set the content that is show above in curly braces. 

Strange thing is that, if I use the same header value through a REST client (Postman), it works fine. From within Apex, I get the above mentioned issue. Can anyone let me know what is wrong here?

Regards,
Gautam.
Hello,
       I have a custom field on the Account object (no record types) which uses a global picklist. We have built a REST web service and are passing a value for this picklist. Even though we are passing the same value in the web service, we are facing the issue "INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Primary Marketplace: bad value for restricted picklist field: Myntra: [Primary_Marketplace__c]"

Screen shot of the global picklist:-
User-added image

And the Primary Market place  custom field's screen shot which uses this global picklist

User-added image

Any inputs as to what might be wrong here??

Regards,
Gautam.

 
The Issue In requesting SOAP API.Please resolve it

soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>sf:UNSUPPORTED_CLIENT</faultcode>
         <faultstring>UNSUPPORTED_CLIENT: TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https.</faultstring>
         <detail>
            <sf:UnexpectedErrorFault xsi:type="sf:UnexpectedErrorFault">
               <sf:exceptionCode>UNSUPPORTED_CLIENT</sf:exceptionCode>
               <sf:exceptionMessage>TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https.</sf:exceptionMessage>
            </sf:UnexpectedErrorFault>
         </detail>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>
Hi, I am having trouble with the "Attributes and Expressions" module from trailhead.

Here is the challenge:
Create a Lightning Component to display a single item for your packing list.
  • Create a component called campingListItem that displays the name (ui:outputText) and the three custom fields using the appropriate output components.
  • Add an attribute named 'item' for type Camping_Item__c.
I created an component named campingListItem and this is the code:
<aura:component >
    <aura:attribute name="item" type="<my_domain>__Camping_Item__c"/>
    
    <ui:outputText value="{!v.item.Name}"/>
    <ui:outputCheckbox value="{!v.item.<my_domain>__Packed__c}"/>
    <ui:outputCurrency  value="{!v.item.<my_domain>__Price__c}"/>
    <ui:outputNumber value="{!v.item.<my_domain>__Quantity__c}"/>
</aura:component>

The error that I am getting is: "Challenge Not yet complete... here's what's wrong: 
The packingListItem Lightning Component's attribute tag doesn't exist or its attributes are not set correctly."

With this, I tried to create another component, with the name "packingListItem", but It didn't work.

Can anyone help me?

Thanks,