• Manish.Singh
  • NEWBIE
  • 20 Points
  • Member since 2015
  • Salesforce Developer
  • AHS IT Services

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
Hi Everyone,
I want to display contact record in LWC but show me error.
 Apex:
 @AuraEnabled(cacheable=true)
    public static contact getContact(string recordId){
        return [SELECT FirstName,LastName,Account.M2BF_Company_Key__c,Email FROM Contact WHERE Id=:recordId];
    }

LWC.js
import { LightningElement, api, track } from 'lwc';
import getContact from '@salesforce/apex/M2BFCreateCoachHandler.getContact';
export default class M2BFRegisterCoachLWC extends LightningElement {
    @api recordId;
    @track contactRec;
    renderedCallback() {
        this.handleload();
    }
    handleload() {
        getContact({ recordId: this.recordId })
            .then(result => {
                alert(JSON.stringify(result));
                this.contactRec = result;
            })
            .catch(error => {
                console.log(error);
            });
    }
}

lwc.html
<lightning-input type="text" data-id="txtFirstName" value={contactRec.FirstName} label="First Name" required="true">
                </lightning-input>

data collected from server side(apex) but while binding in html, it shows undefined.
Please help
Thanks
Hi Everyone,
I have used following code to convert datetime string to datetime but it not shows correct value. Please help me solve this.
string currentDateString=Datetime.Now().format('YYYY-MM-dd HH:mm:ss','Asia/Kolkata');
system.debug('currentDateString '+currentDateString);
datetime targetDate = Datetime.valueof(currentDateString);
system.debug('targetDate '+targetDate);
User-added image
My expectation both value will be same.
Please help.
Thank you
Hello everyone,
When I execute the following code from the anonymous window, it gave me the unexpected result. Please have a look,
Code-
datetime targetDate = Datetime.now();
Time tcurrentTime=targetDate.time();                
DateTime currentDateTime = datetime.newInstanceGmt(Date.today(), tcurrentTime);
string dayOfWeek = currentDateTime.format('EEEE');
Boolean isWithinBusinessHour = BusinessHours.isWithin('01m1H000000MbGw', currentDateTime);
System.debug('dayOfWeek '+dayOfWeek);
System.debug('isWithinBusinessHour '+isWithinBusinessHour);

Output-
User-added image

Business Hour-
User-added image
Expected output-
Boolean isWithinBusinessHour = BusinessHours.isWithin('01m1H000000MbGw', currentDateTime);
It must show "true" because current date exists in business hour.
any help would be appriciated
Thanks in advance!
Hello guys,
Can anyone help me to calculate case age in hours using following business days in apex?
User-added image
one condition should be concern when calulating, when case is open calculation must go on but when case is closed it should stop calulating age.
Hello everyone,
Can anyone tell me, How I exactly show the date-time selected in the lightning input datetime field as a formatted string?
User-added image
My Output:
User-added image
Code that i used to format
$A.localizationService.formatDate(string datetime,"MMM dd yyyy, hh:mm:ss a");
I want to show exactly the selected date/time as a formatted string in the output.
Thanks
Hello guys, 
Is there any ways to pass parameter in designe attribute of Lightning component.
My Requirement -  In community builder, when drag the component. In component setting window, I need following things,
1. Select sObject using picklist (already done).
2. On the basis of selected object, In want get the fieldset name in second picklist.
So, anyone can help me to achieve 2 point through design attribute.
Thanks 
Hello guys,
Can anyone help me to calculate case age in hours using following business days in apex?
User-added image
one condition should be concern when calulating, when case is open calculation must go on but when case is closed it should stop calulating age.
Hello everyone,
Can anyone tell me, How I exactly show the date-time selected in the lightning input datetime field as a formatted string?
User-added image
My Output:
User-added image
Code that i used to format
$A.localizationService.formatDate(string datetime,"MMM dd yyyy, hh:mm:ss a");
I want to show exactly the selected date/time as a formatted string in the output.
Thanks