Function to reduce code duplication?
Hi,
In my calendar view, I have the event title set as the 'Calendar Name' field.
I run the following code when a record is added, but also when it is updated. This creates a useful event title for me in the calendar view.
- brand_lookup = Brands [ID == input.Brand];
- type_lookup = Types [ID == input.Type];
- if (type_lookup.Type == "Special Event")
- {
- input.Calendar_Name = input.Description + " - Special Event";
- }
- else
- {
- input.Calendar_Name = brand_lookup.Brand + " - " + type_lookup.Type;
- }
Is it possible to set this code as a
function, so I don't have to repeat the code twice. I have tried, but it says that the variables are undefined.