Can we create a record for Event object through lwc in Salesforce

0 votes

This is my js code:

var fields = {'OwnerId': user,'CreatedById': user,'WhoId': this.doctorName ,'StartDateTime':this.startDate, 'EndDateTime':this.endDate, 'Departments__c': this.depName, 'Doctor_Name__c': this.doctorName};
var objRecordInput = {'apiName' : 'Event', fields};
// LDS method to create record.
createRecord(objRecordInput).then(response => {
    alert('Event created with Id: ' +response.id);
}).catch(error => {
    alert('Error: ' +JSON.stringify(error));
});

I am getting this error:

Error: {"status":400,"body":{"message":"Object Event is not supported in UI API","statusCode":400,"errorCode":"INVALID_TYPE"},"headers":{}}

I have tried using lightning-record-form earlier. I got this same error. That's why I created my own UI, but that is also not working.

Apr 1, 2022 in SalesForce by surbhi
• 3,810 points
1,783 views

1 answer to this question.

0 votes

You can check list of supported obejcts for createRecord in this All Supported Objects documentation.-

https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_all_supported_objects.htm

As you can mention, Event object is not listed here.

You'll need to create custom static Apex method and call in imperatively from your js of lwc component, in order to create Event from lwc.

answered Apr 5, 2022 by CoolCoder
• 4,400 points

Related Questions In SalesForce

0 votes
0 answers

Can we create new Search Layout in Lightning SalesForce?

I am working on the Search Layout, ...READ MORE

Mar 4, 2022 in SalesForce by surbhi
• 3,810 points
378 views
0 votes
0 answers

Can i create a sql table populated with Salesforce objects?

does Salesforce offer a way to obtain ...READ MORE

Mar 4, 2022 in SalesForce by surbhi
• 3,810 points
352 views
0 votes
0 answers

Salesforce Test Class - System.NullPointerException: Attempt to de-reference a null object

Salesforce Test Class - Facing - System.NullPointerException: ...READ MORE

Mar 1, 2022 in SalesForce by surbhi
• 3,810 points
1,874 views
0 votes
1 answer

Salesforce Test Class - System.NullPointerException: Attempt to de-reference a null object

Because testAccount.account is never set, it is ...READ MORE

answered Mar 2, 2022 in SalesForce by surbhi
• 3,810 points
2,394 views
+2 votes
2 answers

Salesforce Interview questions

Here are some questions very important for ...READ MORE

answered Jan 11, 2019 in Career Counselling by Suresh
• 720 points
2,772 views
0 votes
1 answer

How to connect to salesforce from tableau?

Hi, follow these steps to connect to Salesforce: 1. ...READ MORE

answered Mar 25, 2019 in Tableau by Cherukuri
• 33,030 points
747 views
0 votes
1 answer

Power BI - Salesforce

Hi, Follow below steps: 1. Go to Data source. 2. ...READ MORE

answered Mar 25, 2019 in Power BI by Cherukuri
• 33,030 points
486 views
0 votes
2 answers

What is the best training for Salesforce ADM-201 Exam?

Hi @Vardhan, I took Edureka's Salesforce Online Training, ...READ MORE

answered Jun 3, 2021 in Others by Jaya
• 140 points

edited Dec 22, 2021 by Soumya 548 views
0 votes
1 answer

How can we create salesforce developer account for salesforce essentials?

Developer.salesforce.com is where you can sign up ...READ MORE

answered Mar 3, 2022 in SalesForce by CoolCoder
• 4,400 points

edited Jun 19, 2023 by Khan Sarfaraz 387 views
0 votes
1 answer

how to create a custom login page in salesforce.com?

Here are a few things to consider: Is ...READ MORE

answered Apr 6, 2022 in SalesForce by CoolCoder
• 4,400 points
1,208 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP