How to create column values dinamically

How to create column values dinamically

  
Hi,

I have a service orders entity which has several attributes: User, CreateDate, OrderType, State and Code. When I save the service order, I want to generate dinamically the values for attribute code based on OrderType and CreateDate.

OrderType is a static entity with an extra attribute 'Sigla':
  • Label: "Type A" ; Sigla: "A"
  • Label: "Type B" ; Sigla: "B"
  • Label: "TypeC" ; Sigla: "C"
An so, when a user creates a new service order, I want to fill the Code value for that record silently with, for instance, "A2011/Id". Something like this:

GetOrderType(GetServiceOrderById.List.Current.ServiceOrders.OrderType).OrderType.Sigla
+ IntegerToText(Year(GetServiceOrderById.List.Current.ServiceOrders.CreateDate)) + "/" + GetServiceOrderById.List.Current.ServiceOrders.Id

Can you help me find out how to do this Save Action?

Best Regards,
Bárbara Freitas
Hi Barbara,

Your expression sounds good. The only trick is that you might need to save it to the database twice, first to get the id, and the second to update the code.
Are using it in an assign element to put that in the Code attribute before calling the CreateOrUpdateServiceOrder action?
Maybe if you could attachch the oml it would be easier to help.

Cheers,
Tiago Simões
Hi Tiago,

Thanks for your reply! It really help me!
Like you said, I'm using the assign element to put that in the Code attribute before calling the CreateOrUpdateServiceOrder action
. But I was assigning attribute after validation (ServiceOrder.Edit) and ajax refresh elements. I just place it to before validation and it works perfectly!

Thanks again!

Best Regards,
Bárbara Freitas