0

I have created a public Site and given permissions for the guest profile with Create and Read for both Account(Only Read) and Contact. Then I have given OWD as Public Read/Write for Account and Contact.

Created a VF page, App and LWC and added VF to sites getting below error while saving the record.

You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

VF Page:

<apex:page showHeader="false" sidebar="false">
    <apex:includeLightning />    
    <div id="LightningComponentid" />    
    <script>
    $Lightning.use("c:publicsites", function() {
        $Lightning.createComponent("c:createContact",
          { 
          },
          "LightningComponentid",
          function(cmp) {
             
          });
    });
    </script>
</apex:page>

App:

<aura:application access="GLOBAL" extends="ltng:outApp" implements="ltng:allowGuestAccess">
    <aura:dependency resource="createContact"/>
</aura:application>

LWC - createContact

<template>
    <lightning-record-edit-form object-api-name="Contact" onsuccess={handleSuccess} onsubmit ={handleSubmit}>
        <lightning-messages>
        </lightning-messages>
        <lightning-input-field field-name='AccountId'></lightning-input-field>
        <lightning-input-field field-name='FirstName'></lightning-input-field>
        <lightning-input-field field-name='LastName'></lightning-input-field>
        <lightning-input-field field-name='Email'></lightning-input-field>
        <lightning-button class="slds-m-top_small" type="submit" label="Create Contact">
        </lightning-button>
    </lightning-record-edit-form>
</template>

import { LightningElement } from 'lwc';


export default class CreateContact extends LightningElement {
    handleSuccess(event) {
        console.log('onsuccess event recordEditForm',event.detail.id)
    }
    handleSubmit(event) {
        console.log('onsubmit event recordEditForm'+ event.detail.fields);
    }
}


<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="urn:metadata.tooling.soap.sforce.com" fqn="createContact">
    <apiVersion>48.0</apiVersion>
    <isExposed>true</isExposed>
    <targets> 
        <target>lightning__AppPage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__HomePage</target>
        <target>lightningCommunity__Page</target>
    </targets>
</LightningComponentBundle>
3
  • Interestingly I can see a record is created in the backend but it is showing that error message, how to avoid this?
    – Uday
    Commented Sep 23, 2020 at 9:52
  • Have you tried checking the Field Level Security, doing DML without the record edit form (an imperative call)? Commented Sep 24, 2020 at 7:44
  • Yes , it has access to fields.
    – Uday
    Commented Sep 24, 2020 at 12:44

0

You must log in to answer this question.

Browse other questions tagged .