I'm trying to create an object in LWC, without using Apex. So I found out that we can do that with CreateRecord from uiRecordApi :
But I'm trying to create a Custom Object (ClientMember__c in our example) that have a lookup on Account
I tried this (CLIENTUID_FIELD or CLIENTUID_FIELD2):
import { LightningElement } from 'lwc'; import { createRecord } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import CLM_OBJECT from '@salesforce/schema/ClientMember__c'; import CLIENTUID_FIELD from '@salesforce/schema/ClientMember__c.Client__r.Client_UID__c'; import CLIENTUID_FIELD2 from '@salesforce/schema/Account.Client_UID__c'; export default class testCreateRecordLWC extends LightningElement { handleCreateCM(){ let clientUIDInput = this.template.querySelector('lightning-input'); const fields = {}; fields[CLIENTUID_FIELD.fieldApiName] = clientUIDInput.value; const recordInput = { apiName: CLM_OBJECT.objectApiName, fields }; createRecord(recordInput) .then(cm =>{ this.dispatchEvent( new ShowToastEvent({ title: 'Success', message: 'New ClientMember__c has been created', variant: 'success', }), ); }) .catch(error => { console.log(error); this.dispatchEvent( new ShowToastEvent({ title: 'Error while creating ClientMember__c', message: error.body.message, variant: 'error', }), ); }); } }
I get : POST_BODY_PARSE_ERROR

I also tried this:
const fields = { Client__c : clientUIDInput.value };
==> Malformed ID
or this:
const fields = { Client__r : { Client_UID__c : clientUIDInput.value } };
==> Field Client__r has value of unsupported data type:
What I have to do please ??