Question
Script task process element, initialising lookup column in new record
22:59 Jul 04, 2023
I am creating a new record:
var schema = UserConnection.EntitySchemaManager.GetInstanceByName("UsrTable"); var entity = schema.CreateEntity(UserConnection); entity.SetDefColumnValues(); entity.SetColumnValue("UsrColumn", columnValue); entity.Save(); var recordId = entity.GetColumnValue("Id");
and then creating a linked record in a related table:
var schema2 = UserConnection.EntitySchemaManager.GetInstanceByName("UsrRelatedTable"); var entity2 = schema2.CreateEntity(UserConnection); entity2.SetDefColumnValues(); entity2.SetColumnValue("UsrTable", recordId); entity2.Save();
I'm getting the following error referring to the `UsrTable` lookup column in `UsrRelatedTable` table when running the process:
Terrasoft.Common.ItemNotFoundException: Value "UsrTable" was not found. at Terrasoft.Core.Entities.EntityColumnValueCollection.GetByName(String name) at Terrasoft.Core.Entities.Entity.SetColumnValue(String valueName, Object value) at Terrasoft.Core.Process.UsrImportCustomersSubMethodsWrapper.DeserialiseJSONExecute(ProcessExecutingContext context) at Terrasoft.Core.Process.ProcessScriptTask.InternalExecute(ProcessExecutingContext context) at Terrasoft.Core.Process.ProcessFlowElement.ExecuteItem(ProcessExecutingContext context) at Terrasoft.Core.Process.ProcessFlowElement.Execute(ProcessExecutingContext context)
The question is essentially how to initialise a lookup column with a record Id.
Like
2 comments
12:10 Jul 05, 2023
It seems that the issue is in the column name:
at Terrasoft.Core.Entities.EntityColumnValueCollection.GetByName(String name) at Terrasoft.Core.Entities.Entity.SetColumnValue(String valueName, Object value)
Please try UsrTableId column name
entity2.SetColumnValue("UsrTableId", recordId);
since this should be a lookup column for which the value is set.
12:30 Jul 05, 2023
Oleg Drobina,
Thank you Oleg, I should have figured that one out myself. Cheers,
Show all comments