Start a new topic
Answered

REST API: Populate a foreign key on an entity from the ID of a referenced entity

I am loading entities with the REST API. I want to populate the foreign key from the id of a referenced entity. I have a column "Content_Name" in the "Content_Edition" entity which can match the "Name" of the "Content" entity. The entities are basic and have UUID keys. Is there a way to do this on load using the REST API?


Best Answer

For the REST API, you must always have the value for FID. The API does not filter through one entity and populate the value in another. For SQL you could do something like this which can take the value from one table and populate into another.

INSERT INTO dev4_test_mdm.sa_email_plugin_test
(b_loadid, id, b_classname, email_recipient, email_body, email_subject)
select dev4_repo.get_continuous_loadid('NOTIFICATION_EMAIL'), nextval('seq_email_plugin_test'), 'EmailPluginTest', 'fathia.jama@semarchy.com', 'Changes were made by ' || b_updator , 'Changes were made to ' || t.test_name
from sa_test t;



1 Comment

Answer

For the REST API, you must always have the value for FID. The API does not filter through one entity and populate the value in another. For SQL you could do something like this which can take the value from one table and populate into another.

INSERT INTO dev4_test_mdm.sa_email_plugin_test
(b_loadid, id, b_classname, email_recipient, email_body, email_subject)
select dev4_repo.get_continuous_loadid('NOTIFICATION_EMAIL'), nextval('seq_email_plugin_test'), 'EmailPluginTest', 'fathia.jama@semarchy.com', 'Changes were made by ' || b_updator , 'Changes were made to ' || t.test_name
from sa_test t;



Login to post a comment