• Akhil Katkam 5
  • NEWBIE
  • 145 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 38
    Questions
  • 32
    Replies
Hi Developer Community , 

i have  a task , where i need to display 3 field values in chart based on the current record id values, i have tried using lwc , i will post the code here 
.JS:


import { LightningElement, track,wire ,api } from 'lwc';
import getcompetition from '@salesforce/apex/GEN_ChartController.getcompetition';

export default class Gen_opportunitychart extends LightningElement {
    chartConfiguration;

    @track recId;
    @api recordId;
    @track clist;




    @wire(getcompetition,{rec:'$recordId'})
    getcompetition({ error, data }) {
        if (error) {
            this.error = error;
            this.chartConfiguration = undefined;
        } else if (data) {  
            let chartDomain1 = [];
            let chartDomain2 = [];
            let chartDomain3 = [];

            var clist = data;
            this.clist=data;
            clist.Domain1= 
            

            data.forEach(opp => {
                chartDomain1.push(opp.Domain1);
                chartDomain2.push(opp.Domain2);
                chartDomain3.push(opp.Domain3);

            });

            this.chartConfiguration = {
                type: 'bar',
                data: {
                    datasets: [{
                            label: 'Domain1',
                            backgroundColor: "green",
                            data: chartDomain1,
                        },
                        {
                            label: 'Domain2',
                            backgroundColor: "red",
                            data: chartDomain2,
                        },
                        {
                            label: 'Domain3',
                            backgroundColor: "blue",
                            data: chartDomain3,
                        },

                    ],labels:chartDomain1,chartDomain2,chartDomain3,
                },
                options: {},
            };
            console.log('data => ', data);
            this.error = undefined;
        }
    }
}
 
APEX CLASS: 

public class GEN_ChartController {
    @AuraEnabled(cacheable=true)
    public static Competition__c getcompetition(string rec){
    return [SELECT  Domain1__c , Domain2__c, Domain3__c
    FROM Competition__c WHERE id=:rec];
    
    }
    }

as u can see i have taken apex class where there are 3 values domain 1 , 2 , 3 (these 3 fields are  present in competition object ) , based on the these particular record , values need to displayed on chart ,  

can anyone plz check the code and help me with the solution 

Thanks in advance
Hi Developer  Community , 

i have an apex class where i am querying fields based on the stage name and formula field (month__c) 

here is the code: 
 
[SELECT SUM(Amount) amount, StageName stage ,Month__c month
    FROM Opportunity WHERE StageName NOT IN ('Closed Won') GROUP BY StageName,Month__c];

i am getting an error as :  
[object Object]: ('Closed Won') GROUP BY StageName, Month__c ^ ERROR at Row:1:Column:135 field 'Month__c' can not be grouped in a query call

month__c is a  formula field based on close date , 

can anyone please help me with the solution

Thanks in Advance
Hi Developer Community , i have a url field called  youtube_video __c,

in this field i will keep embedded youtube link , and how can i use this field in  aura component for displaying video based on the url field ?

can anyone please help me with the solution or code

Thanks in Advance
Hi developer Community , 

i have an apex class where it covered only 93%test coverage , there are 4 lines which are needed to be covered , can ayone please help wit the suggestions or solutions
for (Schema.DescribeIconResult describeIcon : describeTabResult.getIcons()) {
                            if (describeIcon.getContentType() == 'image/svg+xml'){
                                return 'custom:' + describeIcon.getUrl().substringBetween('custom/','.svg').substringBefore('_');
                            }

Thnaks in Advance
Hi Developer Community , 

i need test class for these 2 lines , can anyone please help me with the solution 
 
@TestVisible

    global ObjectFieldPickList(VisualEditor.DesignTimePageContext context) {
        this.rows = getRows(context.pageType, context.entityName);
    }

thansks in advance
Hi developer Community , 
i have an apex class , and also i have test class for this apex class , but it is not covering few lines of code , can anyone please check the test class and help me with the solution
 
public with Sharing class lookupfieldController {    
    @AuraEnabled
    public static List<sObject> GetRecentRecords(String ObjectName, List<String> ReturnFields, Integer MaxResults) {
        
        List<Id> recentIds = new List<Id>();
        for(RecentlyViewed recent : [SELECT Id FROM RecentlyViewed WHERE Type = :ObjectName ORDER BY LastViewedDate DESC LIMIT :MaxResults]) {
            recentIds.add(recent.Id);
        }
        
        
        String sQUERY = 'SELECT Id, ';

        if (ReturnFields != null && ReturnFields.Size() > 0) {
            sQuery += String.join(ReturnFields, ',');
        } else {
            sQuery += 'Name';   
        }
        
        sQuery += ' FROM ' + ObjectName + ' WHERE Id IN :recentIds';

        List<sObject> searchResult = Database.query(sQuery);
        
        return searchResult;
    }
    
    @AuraEnabled
    public static List<sObject> SearchRecords(String ObjectName, List<String> ReturnFields, List<String> QueryFields, String SearchText, String SortColumn, String SortOrder, Integer MaxResults, String Filter) {
        
        //always put a limit on the results
        if (MaxResults == null || MaxResults == 0) {
            MaxResults = 20;
        }
        
        SearchText = '%' + SearchText + '%';
        
        List <sObject> returnList = new List <sObject> ();
        
        String sQuery =  'SELECT Id, ';
        
        if (ReturnFields != null && ReturnFields.Size() > 0) {
            sQuery += String.join(ReturnFields, ',');
        } else {
            sQuery += 'Name';   
        }
        
        sQuery += ' FROM ' + ObjectName + ' WHERE ';
        
        if (QueryFields == null || QueryFields.isEmpty()) {
            sQuery += ' Name LIKE :SearchText ';
        } else {
            string likeField = '';
            for(string field : QueryFields) {
                likeField += ' OR ' + field + ' LIKE :SearchText ';    
            }
            sQuery += ' (' + likeField.removeStart(' OR ') + ') ';
        }
        
        if (Filter != null) {
            sQuery += ' AND (' + Filter + ')';
        }
        
        if(string.isNotBlank(SortColumn) && string.isNotBlank(SortOrder)) {
            sQuery += ' ORDER BY ' + SortColumn + ' ' + SortOrder;
        }
        
        sQuery += ' LIMIT ' + MaxResults;
        
        System.debug(sQuery);
        
        List <sObject> searchResult = Database.query(sQuery);
        
        return searchResult;
    }
    
    @AuraEnabled
    public static List<sObject> GetRecord(String ObjectName, List<String> ReturnFields, String Id) {
        String sQUERY = 'SELECT Id, ';

        if (ReturnFields != null && ReturnFields.Size() > 0) {
            sQuery += String.join(ReturnFields, ',');
        } else {
            sQuery += 'Name';   
        }
        
        sQuery += ' FROM ' + ObjectName + ' WHERE Id = :Id';

        List<sObject> searchResult = Database.query(sQuery);
        
        return searchResult;
    }
    
    @AuraEnabled
    public static string findObjectIcon(String ObjectName) {    
        String u;
        List<Schema.DescribeTabResult> tabDesc = new List<Schema.DescribeTabResult>();
        List<Schema.DescribeIconResult> iconDesc = new List<Schema.DescribeIconResult>();
        
        for(Schema.DescribeTabSetResult describeTabSetResult : Schema.describeTabs()) {
            for(Schema.DescribeTabResult describeTabResult : describeTabSetResult.getTabs()) {
                if(describeTabResult.getSobjectName() == ObjectName) { 
                    if( describeTabResult.isCustom() == true ) {
                        for (Schema.DescribeIconResult describeIcon : describeTabResult.getIcons()) {
                            if (describeIcon.getContentType() == 'image/svg+xml'){
                                return 'custom:' + describeIcon.getUrl().substringBetween('custom/','.svg').substringBefore('_');
                            }
                        }
                    } else {
                        return 'standard:' + ObjectName.toLowerCase();
                    }
                }
            }
        }

        return 'standard:default';
    }
    
    @AuraEnabled
    public static objectDetails getObjectDetails(String ObjectName) {    

        objectDetails details = new objectDetails();
        
        Schema.DescribeSObjectResult describeSobjectsResult = Schema.describeSObjects(new List<String>{ObjectName})[0];

        details.label = describeSobjectsResult.getLabel();
        details.pluralLabel = describeSobjectsResult.getLabelPlural();

        details.iconName = findObjectIcon(ObjectName);
        
        return details;
    }
    
    public class objectDetails {
        @AuraEnabled
        public string iconName;
        @AuraEnabled
        public string label;
        @AuraEnabled
        public string pluralLabel;
    }
}

test clas:
@isTest
public class lookupfieldController_Test {
    //This test class just ensures that there is enough code coverage
    //to get the component into production from your sandbox
    //it does not perform any validations.
    static testMethod void testLookupField() {
        List<string> returnFields = new List<string> {'Name'};
            Account acc = new Account();
        acc.Name='test';
        acc.Industry='Banking';
        insert acc;
        Account a = [SELECT Id,Name FROM Account LIMIT 1];
		    lookupfieldController.getObjectDetails('Account');
        lookupfieldController.GetRecentRecords('Account', returnFields, 5);
        lookupfieldController.SearchRecords('Account', returnFields, returnFields, '', 'Name', 'ASC', 5, 'CreatedDate > 2001-01-01T00:00:01Z');
        lookupfieldController.GetRecord('Account', returnFields, a.Id);
    }
}

User-added imageUser-added imagethese lines are not covering , please help me with any ideas
Hi Developer Community , 


Can u please write test class for this apex code
public class RSSFeedUtil {
    public static List<RSSObject> getGoogleRSSObjects(String theUrl) {
        List<RSSObject> returnList = new List<RSSObject>();
        
        Http h = new Http();
        HttpRequest req = new HttpRequest();        
        req.setEndpoint(theUrl);
        req.setMethod('GET');
        HttpResponse res = h.send(req);
        
        Dom.Document doc = res.getBodyDocument();
        Dom.XMLNode feed = doc.getRootElement();
        String namespace = feed.getNamespace();
        
        for(Dom.XMLNode child : feed.getChildElements()) {
            if(child.getName() == 'entry') {
                RSSObject returnListItem = new RSSObject(
                    child.getChildElement('title', namespace).getText().unescapeHtml4(),
                    child.getChildElement('link', namespace).getAttribute('href', ''),                    
                    child.getChildElement('content', namespace).getText().unescapeHtml4(),
                    child.getChildElement('published', namespace).getText()
                );
                System.debug(returnListItem);
                returnList.add(returnListItem);
            }
            System.debug(returnList);
        }
        return returnList;        
    }
}

Thanks in Advance
Hi Developer Community , 

can u please write test class for this apex code
public class RSSObject {
    @AuraEnabled
    public String title {get;set;}
    @AuraEnabled
    public String link {get;set;}
    @AuraEnabled
    public String content {get;set;}
    @AuraEnabled
    public String published {get;set;}
    
    public RSSObject(String title, String link, String content, String published) {
        this.title = title;
        this.link = link;
        this.content = content;
        this.published = published;
    }
}

Thanks in Advance
Hi Developer community , 

i have an apex class , i am having only little knowledge on test classes , 
can u please write test class for below apex code
public class RSSFeedCtrl {
    @AuraEnabled
    public static String getURL(String URLField, ID recordId, String objectName) {
        String queryString = 'select ' + URLField + ' from ' + objectName + ' where Id = \'' + recordId + '\'';
        String returnValue = '';
        
        try {
            sObject s = Database.query(queryString);
            returnValue = (String)s.get(URLField);
        }
        catch (Exception e) {
            throw new AuraHandledException('Error in getURL method of RSSFeedCtrl: ' + e.getMessage());    
        }
        
        return returnValue;
    }

    @AuraEnabled
    public static List<RSSObject> getRSSFeed(String url) {
        List<RSSObject> toReturn = new List<RSSObject>();
        try {
            if(url != null){
                toReturn = RSSFeedUtil.getGoogleRSSObjects(url);
            } 
        }
        catch (Exception e) {
            throw new AuraHandledException('Error in getRSSFeed method of RSSFeedCtrl:' + e.getMessage());    
        }
               
        return toReturn;
    }
}

Thanks in Advance
Hi Developer Community , 

please help me with the test class for below code,
public static void fetchCompetitors(String recordId, String recId){
        List<Opportunity> opp=new List<Opportunity>();
        Opportunity o = [select id,Name,CIBoostVersion1__MainCompetitors__c from Opportunity where id=:recordId];
        List<CIBoostVersion1__Competitor__c> cmptList=[select id,Name from CIBoostVersion1__Competitor__c where id=:recId];
        for(CIBoostVersion1__Competitor__c comp : cmptList){
        o.CIBoostVersion1__MainCompetitors__c = comp.Name; 
        }
        update o; 
    }

thanks in advance
Hi Developer Community , 

i am working on a task (i have createda custom lookup field component ) 

in my apex class i have taken records based on recently viewed 
 
for(RecentlyViewed recent : [SELECT Id,Name FROM RecentlyViewed WHERE Type =:ObjectName]) {
            recentIds.add(recent.Id);
        }
this is the code i kept in apex class , but i need the records based on opportunity object 

actually i kept this component in opportunity record page , so i need to get particular opportunity related recoprds only 

i tried keeping where opportunity__c:rec 

but i am getting error , how to take particular opportunity related record ids 
please help me with the ideas and solution

Thanks in Advacnce


 
Hi Developer Community , 

i have an issue with displaying lightning component in mobile app,

firstly i have a visualforce page  , in my visualforce page i kept a href tag "twitter link " url ,

and i have previewed this visual force page and copied that linl and poasted in a lightning component using iframe ;

    <iframe src="{!'https://ciboost-c1501-dev-ed--ciboostc1501.visualforce.com/apex/TwitterFeedPage?twitterHandle='+v.twitterHandle}"

this is the above code using iframe i kept in a lightning component , this component is displaying in desktop but not in mobile app 

please help me with the issue 
Thanks in Advance
 
Hi Developer Community,
We want to Display text from a single record of an object, These are stored in fields (type:text area)
There is an issue with a table alignment for one of my component.

I will be sharing the screenshot of the issue here:


User-added imageas u can see that left side field datas , those are not inclined exactly  to right side data , i need to have left and right data to be aligned in same way , left side data points to right side data 

here is the code:
<table class="slds-table slds-table_cell-buffer slds-table_bordered slds-no-row-hover slds-table_col-bordered">
             <tbody>

               <aura:iteration items="{!v.Competition}"  var="comp">
        <tr scope="row" class="slds-box">     
            <td style="vertical-align:top;">Coverage<br/><br/>Compatibility<br/><br/>Capability<br/><br/>Creditworthiness<br/><br/>Capacity<br/><br/>Commitment</td>
            <td class="slds-cell-wrap">{!comp.ciboostc1501__Coverage__c}<br/><br/>{!comp.ciboostc1501__Compatibility__c}<br/><br/>{!comp.ciboostc1501__Capability__c}<br/><br/>{!comp.ciboostc1501__Creditworthiness__c}<br/><br/>{!comp.ciboostc1501__Capacity__c}<br/><br/>{!comp.ciboostc1501__Commitment__c}</td>
        </tr>   
 			   </aura:iteration>
            </tbody>
        
     </table>

please help me the suggestions , so that data can be aligned in the correct manner according to left side fields 

Thanks in Advance
 

Hi Developer Community ,

recently i have copied a code for custom lookup field from github , this is a custom component which have .cmp, .js, .helper and a apex class

what this look up field is , we can keep this lookupfield component in any component like in this way 

 

<aura:component>

 <c:lookupField 
                    objectAPIName="Competition__c" 
                    label="PRIMARY COMPETITION"
                    returnFields="['Name','Opportunity__c']" 
                    queryFields="['Name']"
                    selectedId="{!v.selectedId}"
                    />
</aura:component>

my issue is i kept this lookup field in a component and kept in a opportunity record page , when ever i click on this look up field i need to display only values related to this opportunity record , but it is showing all records irrespective of opportunity record

so i have seen the code in lookupfield.cmp

it looks like this component is built in a way that can be used for any object , but in my case i want to queryfields only related to opportunity record ,

can anyone please tell me how to solve this issue , i will keep the link of the github here

click here for link (https://github.com/Chaos-Tech-Corp/Input-Field-Lookup)

Thanks in advance

 

Hi Developer Community , 

please help me with this , how to write test class for this
global ObjectFieldPickList(VisualEditor.DesignTimePageContext context) {
        this.rows = getRows(context.pageType, context.entityName);
    }

Thanks in Advance
Hi Developer Community, 

please help me with this code to be written in test class 
public class competingclass {
@AuraEnabled
public static List<ciboostc1501__Competition__c> getDetails(string rec){
 return [SELECT ciboostc1501__Persona1__c, ciboostc1501__Persona2__c , ciboostc1501__Persona3__c, ciboostc1501__Key_message_1__c, ciboostc1501__Key_message_2__c, ciboostc1501__Key_message_3__c
   FROM ciboostc1501__Competition__c where id=:rec];
  
}
}
please help me with the code , 
Thanks in Advance
 
Hi Developer Community, 

I am having an issue with the alignment , how to align key-message which is shown in image to the somewhat right same as the row data

User-added image
<aura:set attribute="body">
     <table class="slds-table slds-table_bordered slds-table_cell-buffer">
         
   <thead>
    <tr class="slds-text-title_caps">
        <td  class="slds-cell-wrap">
      <th scope="col">Persona</th>  
            <td class="slds-cell-wrap">  <th scope="col">Key Message</th></td>
       </td></tr>
         </thead> 
       
           <tbody>
               
    <aura:iteration items="{!v.Competition}"  var="comp">
       
        <tr scope="row">     
            <td>{!comp.ciboostc1501__Persona1__c}<br/><br/>{!comp.ciboostc1501__Persona2__c}<br/><br/>{!comp.ciboostc1501__Persona3__c}</td>      
            <td Class="slds-cell-wrap">{!comp.ciboostc1501__Key_message_1__c}<br/><br/>{!comp.ciboostc1501__Key_message_2__c}<br/>{!comp.ciboostc1501__Key_message_3__c}</td>
            </tr>
           
    
 </aura:iteration>
         </tbody>
          </table>
          </aura:set>
here is the code , please let me know how to move Key message column name to right same as row data

Thanks in Advance
 
Hi Developer Community , 

i have an issue , i am displaying a record field value which is having a large text , but the text is crosssing the component and displaying in a out of orderUser-added imagehere u can see the first row of key message where the text is crossing the component and not displaying correctly , can anyone please tell me where to write the size of this row to control or manage it 
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
   <thead>
    <tr class="slds-text-title_caps">
      <th scope="col">Persona</th>
      <th scope="col" >Key Message</th>
       </tr>
         </thead>
           <tbody>
    <aura:iteration items="{!v.Competition}"  var="comp">
       
        <tr scope="row">
            <td>{!comp.ciboostc1501__Persona1__c}<br/><br/>{!comp.ciboostc1501__Persona2__c}<br/><br/>{!comp.ciboostc1501__Persona3__c}</td>      
            <td>{!comp.ciboostc1501__Key_message_1__c}<br/><br/>{!comp.ciboostc1501__Key_message_2__c}<br/><br/>{!comp.ciboostc1501__Key_message_3__c}</td>
       
            </tr>
    
 </aura:iteration>
         </tbody>
          </table>

this is the code , please let me knopw how to stop crossing that line and should be displayed with in the component

Thanks in Advance

Hi Developer Community,

i have a requriement for my task ,

i want to display a custom object record using table slds attribute ,

but i want to display only one particular record from that custom object 

how to do that , i have already written some code , but it is displaying all records

my code: 

 

.cmp: 

<aura:attribute name="CompetingProduct" type="ciboostc1501__Competing_Product__c" />
      <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
  	  <lightning:card title="Personas">
      <aura:set attribute="body">
     <table class="slds-table slds-table_bordered slds-table_cell-buffer">
   <thead>
    <tr class="slds-text-title_caps">
      <th scope="col">Personas</th>
      <th scope="col">Key Message</th>
       </tr>
         </thead>
           <tbody>
    <aura:iteration items="{!v.CompetingProduct}" var="comp">
         <tr scope="row">
             <td>{!comp.ciboostc1501__Persona1__c}</td>      
             <td>{!comp.ciboostc1501__Key_message_1__c}</td>  
        </tr>
     </aura:iteration>
         </tbody>
          </table>
          </aura:set>
    </lightning:card>

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

controller.js :

({
  doInit: function(component, event, helper) {
    var action = component.get("c.getDetails");
    action.setCallback(this, function(data) {
      component.set("v.CompetingProduct", data.getReturnValue());
      console.log(data.getReturnValue());
    });
    $A.enqueueAction(action);
  }
})

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

apex class :

public class competingclass {
@AuraEnabled
public static List<ciboostc1501__Competing_Product__c> getDetails(){
  return [SELECT ciboostc1501__Persona1__c,ciboostc1501__Key_message_1__c FROM ciboostc1501__Competing_Product__c];
}

}
 

can anyone please tell me how to display only one particular record 

Thanks in Advacnce

Hi Developer Community ,
I have been working on a task in my project , i will share the ocde of component , js and apex function .
My scenario is , i have a standard object :OPPORTUNITY and
Custom object: competition__c
in my opportunity there is a custom field called “Main_Competitor” (text field ) and in my competition there is a field called “Competitor” (look up field)

i have created a custom aura component and displayed in opportunity record page
User-added image
Competition.cmp:

<aura:component controller="oppcompquery" implements=" .......">
     <aura:attribute name="selectedId" type="String" />
         <aura:attribute name="competitionlist" type="String" />
<c:lookupField 
                    objectAPIName="Competition__c" 
                    label="PRIMARY COMPETITION"
                    returnFields="['Name']" 
                    queryFields="['Name']"
                    selectedId="{!v.selectedId}"
                    />
    <lightning:button label="set as primary" onclick="{!c.request1}" variant="brand" name="name2" class="slds-m-right_small"/>


controller.JS:

request1: function(component, event, helper) {
        var recId = component.get("v.selectedId");
        alert('hi');
        var action = component.get("c.fetchCompetitions");
        action.setParams({
            "recordId": component.get("v.recordId"),
            "recId": recId
        }); // Create a callback that is executed after 
        action.setCallback(this, function(response) {
                var state = response.getState();
                if (state === "SUCCESS") { // Alert the user with the value returned 
                    // from the server 
                    alert("From server: " + response.getReturnValue());
                    // You would typically fire a event here to trigger 
                    // client-side notification that the server-side 
                    // action is complete 
                } else if (state === "INCOMPLETE") {
                    // do something 
                } else if (state === "ERROR") {
                    var errors = response.getError();
                    if (errors) {
                        if (errors[0] && errors[0].message) {
                            console.log("Error message: " + errors[0].message);
                        }
                    } else {
                        console.log("Unknown error");
                    }
                }
            });
                $A.enqueueAction(action);
        }



apex class:

 @AuraEnabled
    public static void fetchCompetitions(String recordId, String recId){
                  System.debug('hi');
                   system.debug('recordId' +recordId);
                    system.debug('recId' +recId);
        List<Opportunity> opp=new List<Opportunity>();
        Opportunity o = [select id,Name,MainCompetitors__c from Opportunity where id=:recordId];
        List<Competitor__c> cmptList=[select id,Name  from Competitor__c where id=:recId];
        for(Competitor__c comp : cmptList){
           Opportunity opList = new Opportunity();    
           opList.MainCompetitors__c = comp.Name;        
            opp.add(opList);
        }
       update opp; 
        system.debug('opp' +opp);

    }

i am also getting a pop up : ((From server: null))
this error is getting after clicking on set as primary in pop up box 

please look into this code and help me where where is error

Thanks in Advance
Hi Developer Community , 


Can u please write test class for this apex code
public class RSSFeedUtil {
    public static List<RSSObject> getGoogleRSSObjects(String theUrl) {
        List<RSSObject> returnList = new List<RSSObject>();
        
        Http h = new Http();
        HttpRequest req = new HttpRequest();        
        req.setEndpoint(theUrl);
        req.setMethod('GET');
        HttpResponse res = h.send(req);
        
        Dom.Document doc = res.getBodyDocument();
        Dom.XMLNode feed = doc.getRootElement();
        String namespace = feed.getNamespace();
        
        for(Dom.XMLNode child : feed.getChildElements()) {
            if(child.getName() == 'entry') {
                RSSObject returnListItem = new RSSObject(
                    child.getChildElement('title', namespace).getText().unescapeHtml4(),
                    child.getChildElement('link', namespace).getAttribute('href', ''),                    
                    child.getChildElement('content', namespace).getText().unescapeHtml4(),
                    child.getChildElement('published', namespace).getText()
                );
                System.debug(returnListItem);
                returnList.add(returnListItem);
            }
            System.debug(returnList);
        }
        return returnList;        
    }
}

Thanks in Advance
Hi Developer Community , i have a url field called  youtube_video __c,

in this field i will keep embedded youtube link , and how can i use this field in  aura component for displaying video based on the url field ?

can anyone please help me with the solution or code

Thanks in Advance
Hi developer Community , 

i have an apex class where it covered only 93%test coverage , there are 4 lines which are needed to be covered , can ayone please help wit the suggestions or solutions
for (Schema.DescribeIconResult describeIcon : describeTabResult.getIcons()) {
                            if (describeIcon.getContentType() == 'image/svg+xml'){
                                return 'custom:' + describeIcon.getUrl().substringBetween('custom/','.svg').substringBefore('_');
                            }

Thnaks in Advance
Hi Developer Community , 

i need test class for these 2 lines , can anyone please help me with the solution 
 
@TestVisible

    global ObjectFieldPickList(VisualEditor.DesignTimePageContext context) {
        this.rows = getRows(context.pageType, context.entityName);
    }

thansks in advance
Hi developer Community , 
i have an apex class , and also i have test class for this apex class , but it is not covering few lines of code , can anyone please check the test class and help me with the solution
 
public with Sharing class lookupfieldController {    
    @AuraEnabled
    public static List<sObject> GetRecentRecords(String ObjectName, List<String> ReturnFields, Integer MaxResults) {
        
        List<Id> recentIds = new List<Id>();
        for(RecentlyViewed recent : [SELECT Id FROM RecentlyViewed WHERE Type = :ObjectName ORDER BY LastViewedDate DESC LIMIT :MaxResults]) {
            recentIds.add(recent.Id);
        }
        
        
        String sQUERY = 'SELECT Id, ';

        if (ReturnFields != null && ReturnFields.Size() > 0) {
            sQuery += String.join(ReturnFields, ',');
        } else {
            sQuery += 'Name';   
        }
        
        sQuery += ' FROM ' + ObjectName + ' WHERE Id IN :recentIds';

        List<sObject> searchResult = Database.query(sQuery);
        
        return searchResult;
    }
    
    @AuraEnabled
    public static List<sObject> SearchRecords(String ObjectName, List<String> ReturnFields, List<String> QueryFields, String SearchText, String SortColumn, String SortOrder, Integer MaxResults, String Filter) {
        
        //always put a limit on the results
        if (MaxResults == null || MaxResults == 0) {
            MaxResults = 20;
        }
        
        SearchText = '%' + SearchText + '%';
        
        List <sObject> returnList = new List <sObject> ();
        
        String sQuery =  'SELECT Id, ';
        
        if (ReturnFields != null && ReturnFields.Size() > 0) {
            sQuery += String.join(ReturnFields, ',');
        } else {
            sQuery += 'Name';   
        }
        
        sQuery += ' FROM ' + ObjectName + ' WHERE ';
        
        if (QueryFields == null || QueryFields.isEmpty()) {
            sQuery += ' Name LIKE :SearchText ';
        } else {
            string likeField = '';
            for(string field : QueryFields) {
                likeField += ' OR ' + field + ' LIKE :SearchText ';    
            }
            sQuery += ' (' + likeField.removeStart(' OR ') + ') ';
        }
        
        if (Filter != null) {
            sQuery += ' AND (' + Filter + ')';
        }
        
        if(string.isNotBlank(SortColumn) && string.isNotBlank(SortOrder)) {
            sQuery += ' ORDER BY ' + SortColumn + ' ' + SortOrder;
        }
        
        sQuery += ' LIMIT ' + MaxResults;
        
        System.debug(sQuery);
        
        List <sObject> searchResult = Database.query(sQuery);
        
        return searchResult;
    }
    
    @AuraEnabled
    public static List<sObject> GetRecord(String ObjectName, List<String> ReturnFields, String Id) {
        String sQUERY = 'SELECT Id, ';

        if (ReturnFields != null && ReturnFields.Size() > 0) {
            sQuery += String.join(ReturnFields, ',');
        } else {
            sQuery += 'Name';   
        }
        
        sQuery += ' FROM ' + ObjectName + ' WHERE Id = :Id';

        List<sObject> searchResult = Database.query(sQuery);
        
        return searchResult;
    }
    
    @AuraEnabled
    public static string findObjectIcon(String ObjectName) {    
        String u;
        List<Schema.DescribeTabResult> tabDesc = new List<Schema.DescribeTabResult>();
        List<Schema.DescribeIconResult> iconDesc = new List<Schema.DescribeIconResult>();
        
        for(Schema.DescribeTabSetResult describeTabSetResult : Schema.describeTabs()) {
            for(Schema.DescribeTabResult describeTabResult : describeTabSetResult.getTabs()) {
                if(describeTabResult.getSobjectName() == ObjectName) { 
                    if( describeTabResult.isCustom() == true ) {
                        for (Schema.DescribeIconResult describeIcon : describeTabResult.getIcons()) {
                            if (describeIcon.getContentType() == 'image/svg+xml'){
                                return 'custom:' + describeIcon.getUrl().substringBetween('custom/','.svg').substringBefore('_');
                            }
                        }
                    } else {
                        return 'standard:' + ObjectName.toLowerCase();
                    }
                }
            }
        }

        return 'standard:default';
    }
    
    @AuraEnabled
    public static objectDetails getObjectDetails(String ObjectName) {    

        objectDetails details = new objectDetails();
        
        Schema.DescribeSObjectResult describeSobjectsResult = Schema.describeSObjects(new List<String>{ObjectName})[0];

        details.label = describeSobjectsResult.getLabel();
        details.pluralLabel = describeSobjectsResult.getLabelPlural();

        details.iconName = findObjectIcon(ObjectName);
        
        return details;
    }
    
    public class objectDetails {
        @AuraEnabled
        public string iconName;
        @AuraEnabled
        public string label;
        @AuraEnabled
        public string pluralLabel;
    }
}

test clas:
@isTest
public class lookupfieldController_Test {
    //This test class just ensures that there is enough code coverage
    //to get the component into production from your sandbox
    //it does not perform any validations.
    static testMethod void testLookupField() {
        List<string> returnFields = new List<string> {'Name'};
            Account acc = new Account();
        acc.Name='test';
        acc.Industry='Banking';
        insert acc;
        Account a = [SELECT Id,Name FROM Account LIMIT 1];
		    lookupfieldController.getObjectDetails('Account');
        lookupfieldController.GetRecentRecords('Account', returnFields, 5);
        lookupfieldController.SearchRecords('Account', returnFields, returnFields, '', 'Name', 'ASC', 5, 'CreatedDate > 2001-01-01T00:00:01Z');
        lookupfieldController.GetRecord('Account', returnFields, a.Id);
    }
}

User-added imageUser-added imagethese lines are not covering , please help me with any ideas
Hi Developer Community , 


Can u please write test class for this apex code
public class RSSFeedUtil {
    public static List<RSSObject> getGoogleRSSObjects(String theUrl) {
        List<RSSObject> returnList = new List<RSSObject>();
        
        Http h = new Http();
        HttpRequest req = new HttpRequest();        
        req.setEndpoint(theUrl);
        req.setMethod('GET');
        HttpResponse res = h.send(req);
        
        Dom.Document doc = res.getBodyDocument();
        Dom.XMLNode feed = doc.getRootElement();
        String namespace = feed.getNamespace();
        
        for(Dom.XMLNode child : feed.getChildElements()) {
            if(child.getName() == 'entry') {
                RSSObject returnListItem = new RSSObject(
                    child.getChildElement('title', namespace).getText().unescapeHtml4(),
                    child.getChildElement('link', namespace).getAttribute('href', ''),                    
                    child.getChildElement('content', namespace).getText().unescapeHtml4(),
                    child.getChildElement('published', namespace).getText()
                );
                System.debug(returnListItem);
                returnList.add(returnListItem);
            }
            System.debug(returnList);
        }
        return returnList;        
    }
}

Thanks in Advance
Hi Developer Community , 

can u please write test class for this apex code
public class RSSObject {
    @AuraEnabled
    public String title {get;set;}
    @AuraEnabled
    public String link {get;set;}
    @AuraEnabled
    public String content {get;set;}
    @AuraEnabled
    public String published {get;set;}
    
    public RSSObject(String title, String link, String content, String published) {
        this.title = title;
        this.link = link;
        this.content = content;
        this.published = published;
    }
}

Thanks in Advance
Hi Developer community , 

i have an apex class , i am having only little knowledge on test classes , 
can u please write test class for below apex code
public class RSSFeedCtrl {
    @AuraEnabled
    public static String getURL(String URLField, ID recordId, String objectName) {
        String queryString = 'select ' + URLField + ' from ' + objectName + ' where Id = \'' + recordId + '\'';
        String returnValue = '';
        
        try {
            sObject s = Database.query(queryString);
            returnValue = (String)s.get(URLField);
        }
        catch (Exception e) {
            throw new AuraHandledException('Error in getURL method of RSSFeedCtrl: ' + e.getMessage());    
        }
        
        return returnValue;
    }

    @AuraEnabled
    public static List<RSSObject> getRSSFeed(String url) {
        List<RSSObject> toReturn = new List<RSSObject>();
        try {
            if(url != null){
                toReturn = RSSFeedUtil.getGoogleRSSObjects(url);
            } 
        }
        catch (Exception e) {
            throw new AuraHandledException('Error in getRSSFeed method of RSSFeedCtrl:' + e.getMessage());    
        }
               
        return toReturn;
    }
}

Thanks in Advance
Hi Developer Community , 

please help me with the test class for below code,
public static void fetchCompetitors(String recordId, String recId){
        List<Opportunity> opp=new List<Opportunity>();
        Opportunity o = [select id,Name,CIBoostVersion1__MainCompetitors__c from Opportunity where id=:recordId];
        List<CIBoostVersion1__Competitor__c> cmptList=[select id,Name from CIBoostVersion1__Competitor__c where id=:recId];
        for(CIBoostVersion1__Competitor__c comp : cmptList){
        o.CIBoostVersion1__MainCompetitors__c = comp.Name; 
        }
        update o; 
    }

thanks in advance
Hi Developer Community , 

i am working on a task (i have createda custom lookup field component ) 

in my apex class i have taken records based on recently viewed 
 
for(RecentlyViewed recent : [SELECT Id,Name FROM RecentlyViewed WHERE Type =:ObjectName]) {
            recentIds.add(recent.Id);
        }
this is the code i kept in apex class , but i need the records based on opportunity object 

actually i kept this component in opportunity record page , so i need to get particular opportunity related recoprds only 

i tried keeping where opportunity__c:rec 

but i am getting error , how to take particular opportunity related record ids 
please help me with the ideas and solution

Thanks in Advacnce


 

Hi Developer Community ,

recently i have copied a code for custom lookup field from github , this is a custom component which have .cmp, .js, .helper and a apex class

what this look up field is , we can keep this lookupfield component in any component like in this way 

 

<aura:component>

 <c:lookupField 
                    objectAPIName="Competition__c" 
                    label="PRIMARY COMPETITION"
                    returnFields="['Name','Opportunity__c']" 
                    queryFields="['Name']"
                    selectedId="{!v.selectedId}"
                    />
</aura:component>

my issue is i kept this lookup field in a component and kept in a opportunity record page , when ever i click on this look up field i need to display only values related to this opportunity record , but it is showing all records irrespective of opportunity record

so i have seen the code in lookupfield.cmp

it looks like this component is built in a way that can be used for any object , but in my case i want to queryfields only related to opportunity record ,

can anyone please tell me how to solve this issue , i will keep the link of the github here

click here for link (https://github.com/Chaos-Tech-Corp/Input-Field-Lookup)

Thanks in advance

 

Hi Developer Community, 

please help me with this code to be written in test class 
public class competingclass {
@AuraEnabled
public static List<ciboostc1501__Competition__c> getDetails(string rec){
 return [SELECT ciboostc1501__Persona1__c, ciboostc1501__Persona2__c , ciboostc1501__Persona3__c, ciboostc1501__Key_message_1__c, ciboostc1501__Key_message_2__c, ciboostc1501__Key_message_3__c
   FROM ciboostc1501__Competition__c where id=:rec];
  
}
}
please help me with the code , 
Thanks in Advance
 
Hi Developer Community , 

i have an issue , i am displaying a record field value which is having a large text , but the text is crosssing the component and displaying in a out of orderUser-added imagehere u can see the first row of key message where the text is crossing the component and not displaying correctly , can anyone please tell me where to write the size of this row to control or manage it 
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
   <thead>
    <tr class="slds-text-title_caps">
      <th scope="col">Persona</th>
      <th scope="col" >Key Message</th>
       </tr>
         </thead>
           <tbody>
    <aura:iteration items="{!v.Competition}"  var="comp">
       
        <tr scope="row">
            <td>{!comp.ciboostc1501__Persona1__c}<br/><br/>{!comp.ciboostc1501__Persona2__c}<br/><br/>{!comp.ciboostc1501__Persona3__c}</td>      
            <td>{!comp.ciboostc1501__Key_message_1__c}<br/><br/>{!comp.ciboostc1501__Key_message_2__c}<br/><br/>{!comp.ciboostc1501__Key_message_3__c}</td>
       
            </tr>
    
 </aura:iteration>
         </tbody>
          </table>

this is the code , please let me knopw how to stop crossing that line and should be displayed with in the component

Thanks in Advance

Hi Developer Community,

i have a requriement for my task ,

i want to display a custom object record using table slds attribute ,

but i want to display only one particular record from that custom object 

how to do that , i have already written some code , but it is displaying all records

my code: 

 

.cmp: 

<aura:attribute name="CompetingProduct" type="ciboostc1501__Competing_Product__c" />
      <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
  	  <lightning:card title="Personas">
      <aura:set attribute="body">
     <table class="slds-table slds-table_bordered slds-table_cell-buffer">
   <thead>
    <tr class="slds-text-title_caps">
      <th scope="col">Personas</th>
      <th scope="col">Key Message</th>
       </tr>
         </thead>
           <tbody>
    <aura:iteration items="{!v.CompetingProduct}" var="comp">
         <tr scope="row">
             <td>{!comp.ciboostc1501__Persona1__c}</td>      
             <td>{!comp.ciboostc1501__Key_message_1__c}</td>  
        </tr>
     </aura:iteration>
         </tbody>
          </table>
          </aura:set>
    </lightning:card>

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

controller.js :

({
  doInit: function(component, event, helper) {
    var action = component.get("c.getDetails");
    action.setCallback(this, function(data) {
      component.set("v.CompetingProduct", data.getReturnValue());
      console.log(data.getReturnValue());
    });
    $A.enqueueAction(action);
  }
})

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

apex class :

public class competingclass {
@AuraEnabled
public static List<ciboostc1501__Competing_Product__c> getDetails(){
  return [SELECT ciboostc1501__Persona1__c,ciboostc1501__Key_message_1__c FROM ciboostc1501__Competing_Product__c];
}

}
 

can anyone please tell me how to display only one particular record 

Thanks in Advacnce

Hi Developer Community ,
I have been working on a task in my project , i will share the ocde of component , js and apex function .
My scenario is , i have a standard object :OPPORTUNITY and
Custom object: competition__c
in my opportunity there is a custom field called “Main_Competitor” (text field ) and in my competition there is a field called “Competitor” (look up field)

i have created a custom aura component and displayed in opportunity record page
User-added image


in this above image u can see custom field : Main Competitor in details area,
on the right side u can see PRIMARY COMPETITION look up field (i have created a custom look up field )
in this primary competition , if i click on search , then it will show the list of Competitions ,if i select one of the competition name from them and click on set as primary , then this value is to be set a sprimary competition and in this particular selected competition i need to take value of competitor and assign that value to Main competitor in oppoertunity
i have already created all the necesaary requirements , but value is not updating , i think error is in apex code , i will share the code , plz check and let me know how to solve this


 

Competition.cmp:

<aura:component controller="oppcompquery" implements=" .......">
     <aura:attribute name="selectedId" type="String" />
         <aura:attribute name="competitionlist" type="String" />
<c:lookupField 
                    objectAPIName="Competition__c" 
                    label="PRIMARY COMPETITION"
                    returnFields="['Name']" 
                    queryFields="['Name']"
                    selectedId="{!v.selectedId}"
                    />
    <lightning:button label="set as primary" onclick="{!c.request1}" variant="brand" name="name2" class="slds-m-right_small"/>


controller.JS:

request1: function(component, event, helper) {
        var recId = component.get("v.selectedId");
        alert('hi');
        var action = component.get("c.fetchCompetitions");
        action.setParams({
            "recordId": component.get("v.recordId"),
            "recId": recId
        }); // Create a callback that is executed after 
        action.setCallback(this, function(response) {
                var state = response.getState();
                if (state === "SUCCESS") { // Alert the user with the value returned 
                    // from the server 
                    alert("From server: " + response.getReturnValue());
                    // You would typically fire a event here to trigger 
                    // client-side notification that the server-side 
                    // action is complete 
                } else if (state === "INCOMPLETE") {
                    // do something 
                } else if (state === "ERROR") {
                    var errors = response.getError();
                    if (errors) {
                        if (errors[0] && errors[0].message) {
                            console.log("Error message: " + errors[0].message);
                        }
                    } else {
                        console.log("Unknown error");
                    }
                }
            });
                $A.enqueueAction(action);
        }



apex class:

 @AuraEnabled
    public static void fetchCompetitions(String recordId, String recId){
                  System.debug('hi');
                   system.debug('recordId' +recordId);
                    system.debug('recId' +recId);
        List<Opportunity> opp=new List<Opportunity>();
        Opportunity o = [select id,Name,MainCompetitors__c from Opportunity where id=:recordId];
        List<Competitor__c> cmptList=[select id,Name  from Competitor__c where id=:recId];
        for(Competitor__c comp : cmptList){
           Opportunity opList = new Opportunity();    
           opList.MainCompetitors__c = comp.Name;        
            opp.add(opList);
        }
       update opp; 
        system.debug('opp' +opp);

    }
 

please help me with solution