how to get value from all fields in script task (server-side event)
Dear Community,
I am trying to copy values from a field and lookups to put it in the "Name" fields before saving.
I use the following code in the script task but I don't know how to get the value from a lookup:
Entity.Name = $"{Entity.Code } - {Entity.Description}";
Code being the lookup.
So if you create a record in a lookup it would go like this:
[Name][Code][Description]
[ ][ 001 ][Code for info]
The Name should automatically be filled with "001 - Code for info" after saving.
What is the correct way to set the script?
Thank you!
Kind regards,
Yosef
Like
Hi!
Just add on saving event in your lookup entity, and add a script
Entity.SetColumnValue("Name", string.Format("[{0}][{1}]", Entity.GetTypedColumnValue<string>("Code"), Entity.GetTypedColumnValue<string>("Descritpion"));
Dmytro Oliinyk,
Thank you but that didn't seem to work for me, this was the solution for me:
var name = Entity.GetColumnValue("Name"); var description = Entity.GetColumnValue("Description"); var esq = new EntitySchemaQuery(Entity.Schema); esq.AddColumn("Code.Name"); var CodeEntity= esq. GetEntity(UserConnection, Entity.PrimaryColumnValue); if (CodeEntity != null) { var columnUsrCodeName = CodeEntity .GetTypedColumnValue<string>("Code_Name"); string fullName= $"{name}: {columnUsrCodeName } - {description}"; Entity.SetColumnValue("Name", fullName); } return true;
Let me know if there's an easier way to do this.
Kind regards,
Yosef