• Raghu.2020
  • NEWBIE
  • 90 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 13
    Replies
Aura Component
 
<aura:component controller="objSearchController" implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
    
    <aura:attribute name="objName" type="String" />
    <aura:attribute name="datacolumns" type="List"/>
    <aura:attribute name="showTable" type="Boolean" default="false"/>
    <aura:attribute name="fieldsList" type="objSearchController.Result[]" />
    
    <lightning:card title="Object Search">
        <div class="slds-m-around_medium">
            <lightning:input name="objSearch" label="Enter Object Name: " value="{!v.objName}"/><br/>
            <lightning:button variant="brand-outline" label="Get Fields" onclick="{!c.getFields}"/>
        </div>
    </lightning:card>

    <aura:if isTrue="{!v.showTable}">
        <lightning:datatable data="{!v.fieldsList}" columns="{!v.dataColumns}" keyField="Sno"/>
    </aura:if>
</aura:component>
Controller:
 
({
    getFields : function(component, event, helper) {
        var objName = component.get("v.objName");
        var action = component.get("c.getObjFields");
        component.set('v.datacolumns', [
                {label: 'Field Name', fieldName: 'fieldName', type: 'text'},
                {label: 'Field Type', fieldName: 'fieldType', type: 'text'},
            ]);
        action.setParams({ "objName" : objName });

        action.setCallback(this, function(response) {
            var state = response.getState();
            var fields = response.getReturnValue();
            console.log(fields);
            if (state === "SUCCESS") {
                component.set("v.showTable",true);
                component.set("v.fieldsList",fields);
            }
            else {
                console.log(state);
            }
        });

          $A.enqueueAction(action);
    }
})

Apex Controller:
 
public with sharing class objSearchController {
    
    public objSearchController() {

    }

    @AuraEnabled
    public static List<Result> getObjFields(String objName){
        
        Integer count = 0;
        List<Result> resList = new List<Result>();
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Schema.SObjectType leadSchema = schemaMap.get(objName);
        Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();

        for (String fieldName: fieldMap.keySet()) {
            String fieldLabel = fieldMap.get(fieldName).getDescribe().getLabel();
            Schema.DisplayType fielddataType = fieldMap.get(fieldName).getDescribe().getType();
            String fieldType = String.valueOf(fielddataType);

            count = count+1;

            Result res = new Result();
            res.Sno = count;
            res.fieldName = fieldLabel;
            res.fieldType = fieldType;
            resList.add(res);
        }

        return resList;
    }

    public class Result{
        
        @AuraEnabled public Integer Sno;
        @AuraEnabled public String fieldName;
        @AuraEnabled public String fieldType;
        
        public Result()
        {
            fieldName = '';
            fieldType = '';
        }
    }
}

​​​​​​​
 
Hi,

I have requirement to search for an object and then display their related field names and field datatype using aura. Can anyone help me with this. 

Thanks
Hi,

I am trying to use omouseover for a lightning:datatable but unable to find any documentation or example on how to do it. Can anyone suggest how to acheive this. 

Thanks
Hi,

I'm getting 'null' displayed in my LWC component. I do not want 'null' to be displayed. 

User-added image

HTML:
<div class="slds-card__body">
            <table
                class="slds-table slds-table_cell-buffer slds-no-row-hover slds-table_bordered slds-table_fixed-layout"
                role="grid">
                <thead>
                    <tr class="slds-line-height_reset">
                        <th class="" scope="col">
                            <div class="slds-truncate" title="Date">Date</div>
                        </th>
                        <th class="" scope="col">
                            <div class="slds-truncate" title="Field">Field</div>
                        </th>
                        <th class="" scope="col">
                            <div class="slds-truncate" title="User">User</div>
                        </th>
                        <th class="" scope="col">
                            <div class="slds-truncate" title="Original Value">Original Value</div>
                        </th>
                        <th class="" scope="col">
                            <div class="slds-truncate" title="New Value">New Value</div>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <template for:each={trackingData} for:item="track">
                        <tr class="slds-hint-parent" key={track.Id}>
                            <td role="gridcell">
                                <div class="slds-truncate">
                                    <p>
                                        <lightning-formatted-date-time value={track.CreatedDate} year="numeric"
                                            month="numeric" day="numeric" hour="2-digit" minute="2-digit"
                                            hour12="false"></lightning-formatted-date-time>
                                    </p>
                                </div>
                            </td>
                            <td role="gridcell">
                                <div class="slds-truncate">
                                    {track.e_eat__Enhanced_Audit_Tracking_Field__r.e_eat__Field_API_Name__c}
                                </div>
                            </td>
                            <td role="gridcell">
                                <div class="slds-truncate">{track.CreatedBy.Name}</div>
                            </td>
                            <td role="gridcell">
                                <div class="slds-truncate" >
                                    <lightning-helptext content={track.e_eat__Original_Value__c}></lightning-helptext>
                                    {track.e_eat__Original_Value__c}
                                </div>
                            </td>
                            <td role="gridcell">
                                <div class="slds-truncate">
                                    <lightning-helptext content={track.e_eat__New_Value__c}></lightning-helptext>
                                    {track.e_eat__New_Value__c}
                                </div>
                            </td>
                        </tr>
                    </template>
                </tbody>
            </table>
        </div>
I'm trying to display the current object icon in my lwc. Any ideas?

Example:
User-added image
Hi,

I would like to format standard custom field 'createddate' into the below format and display in my LWC component.

 User-added image
Is it possible to display Lightning Web Component as related list in salesforce classic record detail page.
Hi,

I'm not sure if this is a valid question but I have a request to find out the List of fields that update the last modified date on change of field value in each entity for some custom objects in my org.
 
Hi,

I am trying to complete the topic Creating a data model under the module 'Build a Conference Management App' in Trailhead. However, even after doing everything right with the speaker object. The challenge still throws an error. Did anyone else complete the challenge. 

Thank you,
Satyanarayana
Hi,

I am trying to learn module "Using CSS and JavaScript Mobile Frameworks" in Visualforce Trailhead. However, even after following the instructions in the module, I am unable to get any output. My preview window is blank. Does anyone else face this problem. Please help.
Hi,

I am trying to complete the topic Creating a data model under the module 'Build a Conference Management App' in Trailhead. However, even after doing everything right with the speaker object. The challenge still throws an error. Did anyone else complete the challenge. 

Thank you,
Satyanarayana
Aura Component
 
<aura:component controller="objSearchController" implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
    
    <aura:attribute name="objName" type="String" />
    <aura:attribute name="datacolumns" type="List"/>
    <aura:attribute name="showTable" type="Boolean" default="false"/>
    <aura:attribute name="fieldsList" type="objSearchController.Result[]" />
    
    <lightning:card title="Object Search">
        <div class="slds-m-around_medium">
            <lightning:input name="objSearch" label="Enter Object Name: " value="{!v.objName}"/><br/>
            <lightning:button variant="brand-outline" label="Get Fields" onclick="{!c.getFields}"/>
        </div>
    </lightning:card>

    <aura:if isTrue="{!v.showTable}">
        <lightning:datatable data="{!v.fieldsList}" columns="{!v.dataColumns}" keyField="Sno"/>
    </aura:if>
</aura:component>
Controller:
 
({
    getFields : function(component, event, helper) {
        var objName = component.get("v.objName");
        var action = component.get("c.getObjFields");
        component.set('v.datacolumns', [
                {label: 'Field Name', fieldName: 'fieldName', type: 'text'},
                {label: 'Field Type', fieldName: 'fieldType', type: 'text'},
            ]);
        action.setParams({ "objName" : objName });

        action.setCallback(this, function(response) {
            var state = response.getState();
            var fields = response.getReturnValue();
            console.log(fields);
            if (state === "SUCCESS") {
                component.set("v.showTable",true);
                component.set("v.fieldsList",fields);
            }
            else {
                console.log(state);
            }
        });

          $A.enqueueAction(action);
    }
})

Apex Controller:
 
public with sharing class objSearchController {
    
    public objSearchController() {

    }

    @AuraEnabled
    public static List<Result> getObjFields(String objName){
        
        Integer count = 0;
        List<Result> resList = new List<Result>();
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Schema.SObjectType leadSchema = schemaMap.get(objName);
        Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();

        for (String fieldName: fieldMap.keySet()) {
            String fieldLabel = fieldMap.get(fieldName).getDescribe().getLabel();
            Schema.DisplayType fielddataType = fieldMap.get(fieldName).getDescribe().getType();
            String fieldType = String.valueOf(fielddataType);

            count = count+1;

            Result res = new Result();
            res.Sno = count;
            res.fieldName = fieldLabel;
            res.fieldType = fieldType;
            resList.add(res);
        }

        return resList;
    }

    public class Result{
        
        @AuraEnabled public Integer Sno;
        @AuraEnabled public String fieldName;
        @AuraEnabled public String fieldType;
        
        public Result()
        {
            fieldName = '';
            fieldType = '';
        }
    }
}

​​​​​​​
 
Hi,

I have requirement to search for an object and then display their related field names and field datatype using aura. Can anyone help me with this. 

Thanks
I'm trying to display the current object icon in my lwc. Any ideas?

Example:
User-added image
Hi,

I am trying to complete the topic Creating a data model under the module 'Build a Conference Management App' in Trailhead. However, even after doing everything right with the speaker object. The challenge still throws an error. Did anyone else complete the challenge. 

Thank you,
Satyanarayana
Hi,

I am trying to learn module "Using CSS and JavaScript Mobile Frameworks" in Visualforce Trailhead. However, even after following the instructions in the module, I am unable to get any output. My preview window is blank. Does anyone else face this problem. Please help.
hello,

i am a newbie to salesforce and trying to complete this trailhead challenge and unable to find a way through apex to generate this method for creating new contacts with unique id. as one requirement to pass the challenge is "The 'generateRandomContacts' method must be capable of consistently generating contacts with unique first names."

If somebody successfully completed the task kindly help me.

regards,
Apex class as following-

public class VerifyDate {
//method to handle potential checks against two dates
public static Date CheckDates(Date date1, Date date2) {
//if date2 is within the next 30 days of date1, use date2. Otherwise use the end of the month
if(DateWithin30Days(date1,date2)) {
return date2;
} else {
return SetEndOfMonthDate(date1);
}
}
//method to check if date2 is within the next 30 days of date1
private static Boolean DateWithin30Days(Date date1, Date date2) {
Date date30Days = date1.addDays(30); //create a date 30 days away from date1
if( date2 > date30Days ) { return false; }
else { return true; }
}
 
//method to return the end of the month of a given date
private static Date SetEndOfMonthDate(Date date1) {
Integer totalDays = Date.daysInMonth(date1.year(), date1.month());
Date lastDay = Date.newInstance(date1.year(), date1.month(), totalDays);
return lastDay;
}
}

-------------------------------------------------
@Test class as following-

@isTest
public class TestVerifyDate
{
     @isTest static void testWarmTemp()
     {
          Date dte = VerifyDate.CheckDates(1,10);
          System.assertEquals(10,dte);
     }
}

--------------------------

test code show me the following error-
[Error] Error: Compile Error: Method does not exist or incorrect signature: VerifyDate.CheckDates(Integer, Integer) at line 6 column 21
My Trigger is as following:-

trigger RestrictContactByName on Contact (before insert, before update)
{ //check contacts prior to insert or update for invalid data
For (Contact c : Trigger.New)
{
if(c.LastName == 'INVALIDNAME')
{ //invalidname is invalid
c.AddError('The Last Name "'+c.LastName+'" is not allowed for DML');
}
}
}

--------------------------------------------------
And my Test class as follows:-
@isTest
private class TestRestrictContactByName
{
    @isTest static void TestContact()
    {

        Contact con=new Contact(FirstName='Arjun', LastName='Mahi');
        if(con.LastName=='INVALIDNAME')
        {
             con.AddError('The Last Name "'+con.LastName+'" is not allowed for DML');
            
        }else{insert con;}  
 
        Contact conn=new Contact(FirstName='Arjun', LastName='Kapur');
         if(conn.LastName=='INVALIDNAME')
        {
             conn.AddError('The Last Name "'+conn.LastName+'" is not allowed for DML');
            
        }else {update conn;}  
       
        Contact com=new Contact(FirstName='Rama', LastName='INVALIDNAME');
        
        if(com.LastName=='INVALIDNAME')
        {
             com.AddError('The Last Name "'+com.LastName+'" is not allowed for DML');
            
        }else {insert conn;}
    }
}


plz help me complete this Challenge :)
Thanx in Advance :)