• B Karthickeyan
  • NEWBIE
  • 165 Points
  • Member since 2020

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 14
    Replies
I am trying to solve the Trailhead Platform Developer 1 (PD1) maintenance module I am facing the following error please help me to solve it. "The correct Safe Navigation logic was not found. Your Apex code should use the Safe Navigation operator to check for null values for Account Name. Please review line 18 of the original code and recheck your code for the Safe Navigation operator."..?
@RestResource(urlMapping='/apexSecurityRest')
global with sharing class ApexSecurityRest {
    @HttpGet
    global static Contact doGet() {
        Id recordId = RestContext.request.params.get('id');
        Contact result;
        if (recordId == null) {
           throw new FunctionalException('Id parameter is required');
        }
        if (Schema.SObjectType.Contact.isAccessible()
          && Schema.SObjectType.Contact.fields.Name.isAccessible()
          && Schema.SObjectType.Contact.fields.Top_Secret__c.isAccessible()
        ) {
          List<Contact> results = [SELECT id, Name, Title, Top_Secret__c, Account.Name FROM Contact WHERE Id = :recordId];
          if (!results.isEmpty()) {
             result = results[0];
             if (Schema.sObjectType.Contact.fields.Description.isUpdateable()){
                 result.Description = result.Account.Name;
                 }
             }
           } else {
             throw new SecurityException('You don\'t have access to all contact fields required to use this API');
           }
           return result;
      }
      public class FunctionalException extends Exception{}
      public class SecurityException extends Exception{}
}

 
I am not 100% sure how to change this to be recognized in Lightning.  The Opportunity Name / ID is not being added to the Quote in Lightning.  Works just fine in Classic.  Any guidance would be great.

        if(theOpp.Account.RecordType.Name =='Prospect') {
            PageReference pref =  new PageReference('/0Q0/e?Name=' + EncodingUtil.urlEncode(theOpp.Name,'UTF-8')  + '&retURL=%2F' + theOpp.Id + '&oppid=' + theOpp.Id);
            return pref;
        }
        else {
            PageReference pref =  new PageReference('/0Q0/e?Name=' + EncodingUtil.urlEncode(theOpp.Name,'UTF-8') + '&BillingName=' + EncodingUtil.urlEncode(theOpp.Account.Name,'UTF-8') + '&retURL=%2F' + theOpp.Id + '&oppid=' + theOpp.Id);
            return pref;
        }
My requirement is when i click the refresh button it should display the date and time like standard report chart.there is any solution 

i need like this
User-added image
This is my code:
Html 
      <button class="slds-input__icon slds-button slds-button_icon iconheight" onclick={today}>
 
js

      
var today = new Date();

console.log("hi");

var date =  String(today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate());

var time = String(today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds());

var dateTime = date+' '+time;

    
today(){
        this.expenseAmount();
    }
this.expenseAmount is having full data

 
I would like to know what are the Events available in LWC and Aura components? 
and how it can be utilized effectively(with example)? 
I would like to trigger an LWC page from Apex method. I tried using PageReference as a return type but it didn't help me. If someone tries the same please add your comments. 


Here is the reason why I am trying this:
 I am trying to make an API call from Apex but it through a certification Error but If I try the same Endpoint from LWC I am getting the expected response. In this case, I am planning to write a schedule (every 30min) class and invoke the LWC component. please add your comments or what could be the alternate solution. 
when I make API call from apex I am receiving Certification Error but when trying the same endpoint from LWC It works fine what could be the reason for this.
@track pickListValueList=[];

for(let key in data) {
if (data.hasOwnProperty(key)) {
this.pickListValueList.push({label: data[key], value: key, classVal:"slds-m-left_x-small slds-m-bottom_x-small slds-button removeColor"});
}
}

data I am getting it from the back end as a Map<String, String>. find the value of pickListValueList and update the classVal of that element.
How to make a group of button act as checkbox functionality with the changes in button color.
when I make API call from apex I am receiving Certification Error but when trying the same endpoint from LWC It works fine what could be the reason for this.
I am trying to solve the Trailhead Platform Developer 1 (PD1) maintenance module I am facing the following error please help me to solve it. "The correct Safe Navigation logic was not found. Your Apex code should use the Safe Navigation operator to check for null values for Account Name. Please review line 18 of the original code and recheck your code for the Safe Navigation operator."..?
@RestResource(urlMapping='/apexSecurityRest')
global with sharing class ApexSecurityRest {
    @HttpGet
    global static Contact doGet() {
        Id recordId = RestContext.request.params.get('id');
        Contact result;
        if (recordId == null) {
           throw new FunctionalException('Id parameter is required');
        }
        if (Schema.SObjectType.Contact.isAccessible()
          && Schema.SObjectType.Contact.fields.Name.isAccessible()
          && Schema.SObjectType.Contact.fields.Top_Secret__c.isAccessible()
        ) {
          List<Contact> results = [SELECT id, Name, Title, Top_Secret__c, Account.Name FROM Contact WHERE Id = :recordId];
          if (!results.isEmpty()) {
             result = results[0];
             if (Schema.sObjectType.Contact.fields.Description.isUpdateable()){
                 result.Description = result.Account.Name;
                 }
             }
           } else {
             throw new SecurityException('You don\'t have access to all contact fields required to use this API');
           }
           return result;
      }
      public class FunctionalException extends Exception{}
      public class SecurityException extends Exception{}
}

 
I am not 100% sure how to change this to be recognized in Lightning.  The Opportunity Name / ID is not being added to the Quote in Lightning.  Works just fine in Classic.  Any guidance would be great.

        if(theOpp.Account.RecordType.Name =='Prospect') {
            PageReference pref =  new PageReference('/0Q0/e?Name=' + EncodingUtil.urlEncode(theOpp.Name,'UTF-8')  + '&retURL=%2F' + theOpp.Id + '&oppid=' + theOpp.Id);
            return pref;
        }
        else {
            PageReference pref =  new PageReference('/0Q0/e?Name=' + EncodingUtil.urlEncode(theOpp.Name,'UTF-8') + '&BillingName=' + EncodingUtil.urlEncode(theOpp.Account.Name,'UTF-8') + '&retURL=%2F' + theOpp.Id + '&oppid=' + theOpp.Id);
            return pref;
        }
@track pickListValueList=[];

for(let key in data) {
if (data.hasOwnProperty(key)) {
this.pickListValueList.push({label: data[key], value: key, classVal:"slds-m-left_x-small slds-m-bottom_x-small slds-button removeColor"});
}
}

data I am getting it from the back end as a Map<String, String>. find the value of pickListValueList and update the classVal of that element.
How to make a group of button act as checkbox functionality with the changes in button color.
Hi All,

I have a Wired Method like this:
 
recordId = '';
searchString;

@wire(searchUsers, {recordId: '$recordId', searchString: '$searchString'})

The method is working correctly, but the method is running everytime the recordId or the searchstring is changed. I would only like to run it when the searchstring is being changed & also not onload of the component. How can i manage this?

 
My requirement is when i click the refresh button it should display the date and time like standard report chart.there is any solution 

i need like this
User-added image
This is my code:
Html 
      <button class="slds-input__icon slds-button slds-button_icon iconheight" onclick={today}>
 
js

      
var today = new Date();

console.log("hi");

var date =  String(today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate());

var time = String(today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds());

var dateTime = date+' '+time;

    
today(){
        this.expenseAmount();
    }
this.expenseAmount is having full data

 
Hi 

I want to set a variable from an apex class at the beginning of the component load.
I guess connctedCallBack should work for me. but as I am using a promise call there it's not working there, though if I write static code there, it works for me. What can I do to achieve this motive?

Code sample that I am using:
 
connectedCallback() {
        console.log('connectedCallback Called! ');
        //console.log(this.bookMarked);
        console.log('Item Id: ' + this.itemId);
        console.log('Checking if already bookmarked'); IsBookmarked({ sItemId: this.itemId })
            .then(result => {
                console.log(result);
                console.log(this.buttonText);
                if (result) {
                    this.buttonText = "Remove from bookmark";
                    this.updateButtonText('Remove from bookmark!');
                }
                else {
                    this.buttonText = "Bookmark Me!"
                    this.updateButtonText('Bookmark Me!');
                }
                console.log(this.buttonText);
            })
            .error(error => {
                console.log('IsBookmarked Failed:' + error.body.message);
            });

    }

 
Hi All,

I am new to creating custom lightning components and I am trying to create a button/link in a Community so that when the button/link is clicked a string of text is shown below the button.  How can I accomplish this?  Thank you in advance!
So I just made my new TP, found the settings to rename it. clicked on the Launch your hands-on org after making sure it was the default hands on org and I get an error:
This site can’t be reached
cunning-raccoon-380385-dev-ed.lightning.force.com’s server DNS address could not be found.

I have my normal DE org connected as well and it takes me to the login page for that org where I can log in successfully. Not sure what I'm missing?
Any help is appreciated, Thanks!