You need to sign in to do that
Don't have an account?
Arpitha M
Adding a today's date?
Hi ,
I am getting a parsing error at line which is bold and underlined.
While I am reading today's date.
Please help me out to resolve this problem.
import { LightningElement, track,wire } from 'lwc';
import { getPicklistValues, getPicklistValuesByRecordType } from 'lightning/uiObjectInfoApi';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import HOTEL_OBJECT from '@salesforce/schema/Hotel_Information__c';
import searchroom from '@salesforce/apex/RoomSearch_ctrl.searchroom';
import addtocart from '@salesforce/apex/AddToCart_ctrl.addToCart';
export default class ButtonGroupBasic extends LightningElement {
@track tdate;
@track dd;
@track mm;
@track yyyy;
@track inputvalue;
@track Buttontrue=true;
@track date1;
zone;
state;
bookeremail;
hotelid;
checkindate;
checkoutdate;
@track value;
@track id;
@track roomTypeList;
@track controllingValues = []; // Zone values
@track dependentValues = []; // state values
@track hotelvalues= []; // Hotel values
@track selectedZone;
@track selectedState;
@track selectedHotel;
@track isEmpty = false;
@track error;
controlValues;
controlValues2;
totalDependentValues = []; // dependent state values
totalDepHotelValues=[]; // dependent hotel values
@track loaded= true;
dd = new Date().getDate();
mm = new Date().getMonth() + 1;
yyyy = new Date().getFullYear();
if(dd < 10){
dd = '0'+dd;
}
if(mm < 10){
mm = '0'+mm;
}
tdate = this.yyyy+'-'+this.mm+'-'+this.dd;
//console.log("date"+tdate);
handleChange(event){
this.inputvalue = event.target.value;
console.log('++++',this.inputvalue);
if(this.inputvalue > 0){
this.Buttontrue=false;
}
else{
this.Buttontrue= true;
}
}
checkindate1(event){
this.date1=event.target.value;
console.log("check in:",this.date1);
}
@wire(getObjectInfo, { objectApiName: HOTEL_OBJECT })
objectInfo;
// Picklist values based on record type
@wire(getPicklistValuesByRecordType, { objectApiName: HOTEL_OBJECT, recordTypeId: '$objectInfo.data.defaultRecordTypeId'})
zonePicklistValues({error, data}) {
if(data) {
this.error = null;
let zoneOptions = [{label:'--None--', value:'--None--'}];
// Zone Control Field Picklist values
data.picklistFieldValues.zone__c.values.forEach(key => {
zoneOptions.push({
label : key.label,
value: key.value
})
});
this.controllingValues = zoneOptions;
let stateOptions = [{label:'--None--', value:'--None--'}];
// State Control Field Picklist values
this.controlValues = data.picklistFieldValues.States__c.controllerValues;
// State dependent Field Picklist values
this.totalDependentValues = data.picklistFieldValues.States__c.values;
let hotelOptions = [{label:'--None--',value:'--None--'}];
//Hotel field picklist values
this.controlValues2 = data.picklistFieldValues.Hotel__c.controllerValues;
// Hotel dependent Field Picklist values
this.totalDepHotelValues = data.picklistFieldValues.Hotel__c.values;
}
else if(error) {
this.error = JSON.stringify(error);
}
}
handleZoneChange(event) {
// Selected Zone Value
this.selectedZone = event.target.value;
// this.isEmpty = true;
let dependValues = [];
if(this.selectedZone) {
// if Selected Zone is none returns nothing
if(this.selectedZone === '--None--') {
this.isEmpty = true;
dependValues = [{label:'--None--', value:'--None--'}];
this.selectedZone = null;
this.selectedState = null;
this.selectedHotel = null;
return;
}
// filter the total dependent values based on selected Zone value
this.totalDependentValues.forEach(conValues => {
if(conValues.validFor[0] === this.controlValues[this.selectedZone]) {
dependValues.push({
label: conValues.label,
value: conValues.value
})
}
})
this.dependentValues = dependValues;
// console.log('state value'+JSON.stringify(this.dependentValues));
}
}
handleStateChange(event) {
this.selectedState = event.target.value;
this.isEmpty = false;
let depend2Values = [];
if(this.selectedState) {
// if Selected state is none returns nothing
if(this.selectedState === '--None--') {
this.isEmpty = true;
depend2Values = [{label:'--None--', value:'--None--'}];
this.selectedState = null;
this.selectedHotel = null;
return;
}
// filter the total dependent values based on selected Zone value
this.totalDepHotelValues.forEach(hValues => {
if(hValues.validFor[0] === this.controlValues2[this.selectedState]) {
depend2Values.push({
label: hValues.label,
value: hValues.value
})
}
})
this.hotelvalues = depend2Values;
// console.log('on state change'+ JSON.stringify(this.hotelvalues));
}
}
handleHotelChange(event){
this.selectedHotel = event.target.value;
}
/*takeInputData(){
this.loaded = !this.loaded;
this.zone = this.template.querySelector(".zone").value;
this.state = this.template.querySelector(".state").value;
this.hotelid = this.template.querySelector(".hotel").value;
this.checkindate = this.template.querySelector(".checkin").value;
this.checkoutdate = this.template.querySelector(".checkoutdate").value;
this.bookeremail = this.template.querySelector(".bookeremail").value;
// if(test){
searchroom({hotelid:this.hotelid,cindate:this.checkindate,coutdate:this.checkoutdate})
.then(result =>{
//console.log('============result '+JSON.stringify(result));
this.roomTypeList = result;
console.log('accesskey'+ this.roomTypeList[0].accesskey);
this.loaded=true;
})
.catch(error=>{
this.loaded=true;
console.log('============search'+JSON.stringify(error));
});
// }
}
saveBooking(){
this.loaded = !this.loaded;
addtocart({accesskey:this.roomTypeList[0].accesskey,accesssecret:this.roomTypeList[0].accesssecret,rates:JSON.stringify(this.ratesIds)})
.then(result =>{
//console.log('============result '+JSON.stringify(result));
this.loaded=true;
})
.catch(error=>{
this.loaded=true;
console.log('============save booking error'+JSON.stringify(error));
});
}*/
handleChangeRegion(event) {
this.value = event.detail.value;
}
handleChangeHotel(event) {
this.id = event.detail.value;
}
ratesIds = [];
handleAddAction(event) {
if(!this.ratesIds.includes(event.currentTarget.dataset.key)){
this.ratesIds.push({value:event.currentTarget.dataset.key});
}
console.log('rates id++'+ JSON.stringify(this.ratesIds));
}
reload(){
location.reload();
}
@track value = "initial value";
handleClick(evt) {
console.log('Current value of the input: ' + evt.target.value);
const allValid = [...this.template.querySelectorAll('.zone'),...this.template.querySelectorAll('.state'),...this.template.querySelectorAll('.hotel'),...this.template.querySelectorAll('.checkin'),...this.template.querySelectorAll('.checkoutdate'),...this.template.querySelectorAll('.bookeremail')]
.reduce((validSoFar, inputCmp) => {
inputCmp.reportValidity();
return validSoFar && inputCmp.checkValidity();
}, true);
if (allValid) {
//alert('All form entries look valid. Ready to submit!');
this.loaded = !this.loaded;
this.zone = this.template.querySelector(".zone").value;
this.state = this.template.querySelector(".state").value;
this.hotelid = this.template.querySelector(".hotel").value;
this.checkindate = this.template.querySelector(".checkin").value;
this.checkoutdate = this.template.querySelector(".checkoutdate").value;
this.bookeremail = this.template.querySelector(".bookeremail").value;
// if(test){
searchroom({hotelid:this.hotelid,cindate:this.checkindate,coutdate:this.checkoutdate})
.then(result =>{
//console.log('============result '+JSON.stringify(result));
this.roomTypeList = result;
console.log('accesskey'+ this.roomTypeList[0].accesskey);
this.loaded=true;
})
.catch(error=>{
this.loaded=true;
console.log('============search'+JSON.stringify(error));
});
} else {
alert('Please update the invalid form entries and try again.');
}
}
}
I am getting a parsing error at line which is bold and underlined.
While I am reading today's date.
Please help me out to resolve this problem.
import { LightningElement, track,wire } from 'lwc';
import { getPicklistValues, getPicklistValuesByRecordType } from 'lightning/uiObjectInfoApi';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import HOTEL_OBJECT from '@salesforce/schema/Hotel_Information__c';
import searchroom from '@salesforce/apex/RoomSearch_ctrl.searchroom';
import addtocart from '@salesforce/apex/AddToCart_ctrl.addToCart';
export default class ButtonGroupBasic extends LightningElement {
@track tdate;
@track dd;
@track mm;
@track yyyy;
@track inputvalue;
@track Buttontrue=true;
@track date1;
zone;
state;
bookeremail;
hotelid;
checkindate;
checkoutdate;
@track value;
@track id;
@track roomTypeList;
@track controllingValues = []; // Zone values
@track dependentValues = []; // state values
@track hotelvalues= []; // Hotel values
@track selectedZone;
@track selectedState;
@track selectedHotel;
@track isEmpty = false;
@track error;
controlValues;
controlValues2;
totalDependentValues = []; // dependent state values
totalDepHotelValues=[]; // dependent hotel values
@track loaded= true;
dd = new Date().getDate();
mm = new Date().getMonth() + 1;
yyyy = new Date().getFullYear();
if(dd < 10){
dd = '0'+dd;
}
if(mm < 10){
mm = '0'+mm;
}
tdate = this.yyyy+'-'+this.mm+'-'+this.dd;
//console.log("date"+tdate);
handleChange(event){
this.inputvalue = event.target.value;
console.log('++++',this.inputvalue);
if(this.inputvalue > 0){
this.Buttontrue=false;
}
else{
this.Buttontrue= true;
}
}
checkindate1(event){
this.date1=event.target.value;
console.log("check in:",this.date1);
}
@wire(getObjectInfo, { objectApiName: HOTEL_OBJECT })
objectInfo;
// Picklist values based on record type
@wire(getPicklistValuesByRecordType, { objectApiName: HOTEL_OBJECT, recordTypeId: '$objectInfo.data.defaultRecordTypeId'})
zonePicklistValues({error, data}) {
if(data) {
this.error = null;
let zoneOptions = [{label:'--None--', value:'--None--'}];
// Zone Control Field Picklist values
data.picklistFieldValues.zone__c.values.forEach(key => {
zoneOptions.push({
label : key.label,
value: key.value
})
});
this.controllingValues = zoneOptions;
let stateOptions = [{label:'--None--', value:'--None--'}];
// State Control Field Picklist values
this.controlValues = data.picklistFieldValues.States__c.controllerValues;
// State dependent Field Picklist values
this.totalDependentValues = data.picklistFieldValues.States__c.values;
let hotelOptions = [{label:'--None--',value:'--None--'}];
//Hotel field picklist values
this.controlValues2 = data.picklistFieldValues.Hotel__c.controllerValues;
// Hotel dependent Field Picklist values
this.totalDepHotelValues = data.picklistFieldValues.Hotel__c.values;
}
else if(error) {
this.error = JSON.stringify(error);
}
}
handleZoneChange(event) {
// Selected Zone Value
this.selectedZone = event.target.value;
// this.isEmpty = true;
let dependValues = [];
if(this.selectedZone) {
// if Selected Zone is none returns nothing
if(this.selectedZone === '--None--') {
this.isEmpty = true;
dependValues = [{label:'--None--', value:'--None--'}];
this.selectedZone = null;
this.selectedState = null;
this.selectedHotel = null;
return;
}
// filter the total dependent values based on selected Zone value
this.totalDependentValues.forEach(conValues => {
if(conValues.validFor[0] === this.controlValues[this.selectedZone]) {
dependValues.push({
label: conValues.label,
value: conValues.value
})
}
})
this.dependentValues = dependValues;
// console.log('state value'+JSON.stringify(this.dependentValues));
}
}
handleStateChange(event) {
this.selectedState = event.target.value;
this.isEmpty = false;
let depend2Values = [];
if(this.selectedState) {
// if Selected state is none returns nothing
if(this.selectedState === '--None--') {
this.isEmpty = true;
depend2Values = [{label:'--None--', value:'--None--'}];
this.selectedState = null;
this.selectedHotel = null;
return;
}
// filter the total dependent values based on selected Zone value
this.totalDepHotelValues.forEach(hValues => {
if(hValues.validFor[0] === this.controlValues2[this.selectedState]) {
depend2Values.push({
label: hValues.label,
value: hValues.value
})
}
})
this.hotelvalues = depend2Values;
// console.log('on state change'+ JSON.stringify(this.hotelvalues));
}
}
handleHotelChange(event){
this.selectedHotel = event.target.value;
}
/*takeInputData(){
this.loaded = !this.loaded;
this.zone = this.template.querySelector(".zone").value;
this.state = this.template.querySelector(".state").value;
this.hotelid = this.template.querySelector(".hotel").value;
this.checkindate = this.template.querySelector(".checkin").value;
this.checkoutdate = this.template.querySelector(".checkoutdate").value;
this.bookeremail = this.template.querySelector(".bookeremail").value;
// if(test){
searchroom({hotelid:this.hotelid,cindate:this.checkindate,coutdate:this.checkoutdate})
.then(result =>{
//console.log('============result '+JSON.stringify(result));
this.roomTypeList = result;
console.log('accesskey'+ this.roomTypeList[0].accesskey);
this.loaded=true;
})
.catch(error=>{
this.loaded=true;
console.log('============search'+JSON.stringify(error));
});
// }
}
saveBooking(){
this.loaded = !this.loaded;
addtocart({accesskey:this.roomTypeList[0].accesskey,accesssecret:this.roomTypeList[0].accesssecret,rates:JSON.stringify(this.ratesIds)})
.then(result =>{
//console.log('============result '+JSON.stringify(result));
this.loaded=true;
})
.catch(error=>{
this.loaded=true;
console.log('============save booking error'+JSON.stringify(error));
});
}*/
handleChangeRegion(event) {
this.value = event.detail.value;
}
handleChangeHotel(event) {
this.id = event.detail.value;
}
ratesIds = [];
handleAddAction(event) {
if(!this.ratesIds.includes(event.currentTarget.dataset.key)){
this.ratesIds.push({value:event.currentTarget.dataset.key});
}
console.log('rates id++'+ JSON.stringify(this.ratesIds));
}
reload(){
location.reload();
}
@track value = "initial value";
handleClick(evt) {
console.log('Current value of the input: ' + evt.target.value);
const allValid = [...this.template.querySelectorAll('.zone'),...this.template.querySelectorAll('.state'),...this.template.querySelectorAll('.hotel'),...this.template.querySelectorAll('.checkin'),...this.template.querySelectorAll('.checkoutdate'),...this.template.querySelectorAll('.bookeremail')]
.reduce((validSoFar, inputCmp) => {
inputCmp.reportValidity();
return validSoFar && inputCmp.checkValidity();
}, true);
if (allValid) {
//alert('All form entries look valid. Ready to submit!');
this.loaded = !this.loaded;
this.zone = this.template.querySelector(".zone").value;
this.state = this.template.querySelector(".state").value;
this.hotelid = this.template.querySelector(".hotel").value;
this.checkindate = this.template.querySelector(".checkin").value;
this.checkoutdate = this.template.querySelector(".checkoutdate").value;
this.bookeremail = this.template.querySelector(".bookeremail").value;
// if(test){
searchroom({hotelid:this.hotelid,cindate:this.checkindate,coutdate:this.checkoutdate})
.then(result =>{
//console.log('============result '+JSON.stringify(result));
this.roomTypeList = result;
console.log('accesskey'+ this.roomTypeList[0].accesskey);
this.loaded=true;
})
.catch(error=>{
this.loaded=true;
console.log('============search'+JSON.stringify(error));
});
} else {
alert('Please update the invalid form entries and try again.');
}
}
}
dd = new Date().getDay();
If it helps, please mark as Best Answer to help others too.