Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - General Discussions
Answered

Error while adding lookup field into Dataverse table

(0) ShareShare
ReportReport
Posted on by 195

Hi everyone,

 

I have written a JS code to add entry into Dataverse table. It has a Lookup field to Contact table and table I have set the access type of that table as Contact so API will return data of loggedin user only..

 

Here is my Relationship for my table & contact table

 

swaminawale_0-1708044919201.png

 

 

here is my code:

 

function addData() {
 console.log('...adding data')
 var recOBj = {
 new_streetname:document.getElementById('street-name').value,
 new_streetno:document.getElementById('street-number').value,
 'new_ContactRelation@odata.bind' : '/contacts/({{user.id}})'
 };
 
 webapi.safeAjax({
 type: "POST",
 url: "/_api/new_xxxxxxxxxxxx",
 contentType: "application/json",
 data: JSON.stringify(recOBj),
 success: function (res, status, xhr) {
 alert("✅ Record Added Successfully");
 },
 });
 }

 

when I added 'new_ContactRelation@odata.bind' : '/contacts/({{user.id}})' then it is giving me error in console and if i remove that lookup code, then its working well.

 

swaminawale_1-1708045091638.png


Do I need to configure something else for this??

I did following:

1. Added realtion between my table and contact table

2. Necesary permission given

 

Let me know, Thanks 🙂

Categories:
  • Verified answer
    prudhvimunagala Profile Picture
    42 on at
    Re: Error while adding lookup field into Dataverse table

    Hi @swaminawale,

     

     you should take care of few more steps for a api skills work at portal, please follow the steps in the following link.

    https://powerusers.microsoft.com/t5/General-Discussions/Error-while-adding-lookup-field-into-Dataverse-table/m-p/2607777#M6377

     

     please mark it as answer if it worked.

  • prudhvimunagala Profile Picture
    42 on at
    Re: Error while adding lookup field into Dataverse table

    Hi @swaminawale

     

    If you want the logged in user contact should be populated in the Entity Form. You have add the Metadata to you Entity Form. Select the type as Attribute and Attribute logical name of the look up attribute of contact in which you have to populate logged in user. 

    prudhvimunagala_0-1708058942488.png

    Later scroll down to populate field section and make changes as per the below Screenshot and save the record

    prudhvimunagala_1-1708059091299.png

     

    Later Sync the configuration of portal & refresh the portal page, so that the contact lookup will be populated with the logged in user contact.

     

    Please mark this answer if it works for you. 

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >