Selected value is not highlighted.
Selected value is not highlighted.
When I edit a record the select field selected value is not highlighted. The options populate fine. I can select an option and save. Record is written correctly to DB and JSON returned(see below) successfully.
I understand for this to work the data table must match the editor field. I have attempted to do that(see below) without success. Please advise what I'm doing wrong.
Editor Field
{
label: 'Email Campaign:',
name: 'prospect.emailcampaign',
type: 'datatable',
optionsPair: {
label: 'name',
value: 'id'
},
config: {
columns: [
{
title: 'Name',
data: 'name'
}
]
}
}
Data Table Column
{ data: 'emailcampaign.name', editField: 'prospect.emailcampaign' },
Returned JSON payload on Edit
{
"data": [
{
"id": "f69a45aa-ebcb-4094-bebc-f59ffad47ee7",
"prospect": {
"linkedin": "https://www.linkedin.com/in/xxxxxxxxxxxxxxxxxxx2268/",
"email": "hello@xxxxxxxxxxxxxxpert",
"lastname": "Marunda",
"industry": "Information Communication Technology",
"city": "Harare",
"title": "Mr.",
"region": "Mashonaland",
"firstname": "Arnold Tonderai",
"avatar": "https:/xxxxxxxxxxxx/4c69647b096b7d00f350ec2b054e8082/290900378/profile.jpeg?s=",
"mobiletelephone": "xxxxxxxxxxx",
"website": "https://arnoldxxxxxxxxxxxxxxpert",
"fixedtelephone": "",
"jobtitle": "Workflow Automation Expert",
"country": "Zimbabwe",
"company": "Edenpoint Projects"
},
"emailcampaign": {
"name": null,
"id": null
},
"socialcampaign": {
"name": "No Footprint-S2C7-Linkedin",
"id": "07e6c08a-e052-486c-b049-6189dbf3d13a"
}
}
],
"options": {
"prospect.emailcampaign": [
{
"name": "Footprint-S1C7",
"id": "758a4c1f-4630-4a09-9234-0f7a4f3c10ea"
},
{
"name": "Non-Footprint-S2C7",
"id": "a3fca475-0677-474a-ad65-46ae5408afd1"
}
],
"prospect.socialcampaign": [
{
"name": "Footprint-S1C7-Linkedin",
"id": "34b4d4ce-4f60-403c-a401-c834592e79ee"
},
{
"name": "No Footprint-S2C7-Linkedin",
"id": "07e6c08a-e052-486c-b049-6189dbf3d13a"
}
]
},
"files": []
}
Screenshot of issue

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
Answers
Hi,
The way Editor is set up there is that it is being told to look for data in
prospect.emailcampaign. However, there isn't aemailcampaignfield in theprospectobject. There is aemailcampaign.id, but I'd be surprised if you wanted to edit that!Can you show me your controller code - specifically I'm looking for information about the join that is used to tell the
prospectrow, what email or social campaign it should link to. Is that a column in theprospecttable?Allan
Hi Allan,
My controller code is in Python on the Anvil.works runtime server as follows...
Build JSON payload to be returned to Editor
Update Prospect row with formdata paramatersfrom Editor
Apologies, I'm not a Python developer. I presume this has an SQL backend - so perhaps we can discuss in those terms. What links a
prospectto an email campaign? Is there anemail_campaigncolumn in the prospects table?Allan
Yes,
email_campaignandsocial_campaignare fields in the SQL DB with a one-to-one join relationship with respective tables.Not quite following your investigation into the data model. I thought Editor would just use the JSON file presented to it?
Okay, so there is a
email_campaigncolumn in theprospecttable? And that in turns holds an id that relates toemailcampaign.id?That being the case, I would expect to see a
email_campaignvalue in theprospectobject, since that is the value that you want to edit to update the reference. You wantemailcampaign.nameto display in the DataTable, that's fine, but when you actually update the record to point at a different email campaign then you need to change the value ofprospect.email_campaign.If you look at this example you'll see that there is a
users.sitevalue, which points to the id in thesitestable. I usesites.nameto display in the DataTable, but when a user's site changes, it writes the site id tousers.site.Allan
Hi Allan,
Thank you for looking at this in detail. Much appreciated.
Have followed your instruction and it works. The example was very useful.
regards,
Arnold
Awesome - great to hear you've got it working
Allan